I'm working on a Flex Mobile app for Android with a native extension. I'm trying to use Retrofit in the Java code, but the Retrofit calls are failing.
I have the following interface defined:
public interface GitHubService {
@GET("/repos/{owner}/{repo}/contributors")
List<Contributor> contributors(
@Path("owner") String owner,
@Path("repo") String repo
);
}
Then I have an AsyncTask
invoked from the appropriate point in my Java code. Its doInBackground
method looks like this:
@Override
protected String doInBackground(String... arg0) {
Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.create();
RestAdapter restAdapter = new RestAdapter.Builder().setServer("https://api.github.com")
.setConverter(new GsonConverter(gson))
.build();
GitHubService service = restAdapter.create(GitHubService.class);
List<Contributor> contributors = service.contributors("square", "okhttp");
for (Contributor contributor : contributors) {
Log.d("FooTask", contributor.login + " - " + contributor.contributions);
}
return null;
}
From all this, I'm expecting to see a list printed in LogCat; instead I get the following exception:
FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
...
Caused by: java.lang.IllegalStateException: No Retrofit annotation found on parameter 1 of contributors
Is there a way to make Retrofit work inside a native extension with Flex Mobile?
This currently isn't possible. ADT strips all annotations from java classes in its compilation process for dalvik.