Android + Android注释 REST API

Android + AndroidAnnotations REST API

我正在尝试使用 AndroidAnnotations 创建一个简单的学习项目,它将使用 REST 调用。我已经学习了这个教程
https://github.com/androidannotations/androidannotations/wiki/Rest-API#rest

但运气不好。项目构建成功,但在运行时,我的@RestService 始终为 null,我无法让它工作。

我的结构如下:

build.gradle
应用插件:'com.android.application'

def AAVersion = '4.3.0'
dependencies {
    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    compile "org.androidannotations:rest-spring-api:$AAVersion"
    compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
    compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
}

接口(单独文件):

@Rest(rootUrl = "https://api.github.com", converters = {StringHttpMessageConverter.class})
public interface GithubClient {

    @Get("/search/repositories?q={searchString}")
    GitResult getResult(@Path String searchString);

}

主要活动:

public class MainActivity extends AppCompatActivity {

    @RestService
    GithubClient restClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Click(R.id.btn_Request)
    void requestCall(){
        searchAsync();
    }

    @Background
    void searchAsync(){
        try {
            GitResult result = restClient.getResult("angular");
        } catch (RestClientException e){
            Log.e("Rest error",e.toString());
        }

    }
}

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.com.githubbrowser">
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity_">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我是否遗漏了任何包裹,或者我在这里做错了什么?非常感谢任何帮助或建议。

所以问题是我在 build.gradle 下缺少以下依赖项:

compile "org.androidannotations:rest-spring:$AAVersion"
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'

只是为了更新这个线程,当前编译已过时,因此我使用这个

 // android annotation
implementation "org.androidannotations:androidannotations-api:4.5.2"
annotationProcessor "org.androidannotations:androidannotations:4.5.2"
implementation "org.androidannotations:rest-spring-api:4.5.2"
annotationProcessor "org.androidannotations:rest-spring:4.5.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.9.7"
implementation "org.springframework.android:spring-android-rest-template:2.0.0.M3"