4.0.0 migration guide - WonderCsabo/androidannotations GitHub Wiki
The library is now split into smaller modules. This means if you are using annotations were which split into a module, you have to add new dependencies, and change the imports for those annotations.
For using OrmLiteDao, addd these new dependencies in your build.gradle:
compile "org.androidannotations:ormlite-api:4.0.0"
apt "org.androidannotations:ormlite:4.0.0"Change your imports to
org.androidannotations.ormlite.annotations.OrmLiteDaoFor using Otto with AA, add this dependency in your build.gradle:
apt "org.androidannotations:otto:4.0.0"For using the REST client, add these new dependencies in your build.gradle:
compile "org.androidannotations:rest-spring-api:4.0.0"
apt "org.androidannotations:rest-spring:4.0.0"Change your imports to
org.androidannotations.rest.spring.annotations.Rest // etc
org.androidannotations.rest.spring.api.RestClientHeaders // etcFor using @RoboGuice, add these new dependencies in your build.gradle:
compile "org.androidannotations:roboguice-api:4.0.0"
apt "org.androidannotations:roboguice:4.0.0"Change your imports to
org.androidannotations.roboguice.annotations.RoboGuiceWe clear injected view fields (@ViewById and @ViewsById) by setting them to null in Fragment#onDestroyView(). If you access these views after this lifecycle event, you will get NullPointerExceptions. You can guard against this by the new @IgnoreWhen annotation:
@IgnoreWhen(IgnoreWhen.State.VIEW_DESTROYED)
void someMethodCalledAfterViewDestroyed() {
injectedView.setText("Hello");
}##Minimum Android version is 2.3.1
We no longer support applications with minSdkVersion below 2.3.1. It is possible your code will still work, but expect generated code may broke under lower Android versions. But you do not target ancient Android anymore, don`t you? 😉
We no longer support JDK 6 for compilation, which is end of life years ago. You can still write Java 6 source code using a newer JDK compiler.
We no longer inspect the action name from the method name if there is no annotation value specified. Also the value parameter changed to actions.
@ReceiverAction
public void simpleAction() { // AA 3.x, action = "simpleAction"
}
@ReceiverAction(actions = "simpleAction")
public void simpleAction() { // AA 4.0.0
}##@OrmLiteDao model parameter removed
This parameter was removed, but we already inspected it from the Dao class, so it was redundant.
@OrmLiteDao(helper = DatabaseHelper.class, model = Car.class) // AA 3.x
Dao<Car, Long> injectedDao;
@OrmLiteDao(helper = DatabaseHelper.class) // AA 4.0.0
Dao<Car, Long> injectedDao;##@NoTitle annotation removed
This annotations was removed, but you can get the same functionality with @WindowFeature.
@NoTitle // AA 3.x
@EActivity
public class MyActivity extends Activity {
}
@WindowFeature(Window.FEATURE_NO_TITLE) // AA 4.0.0
@EActivity
public class MyActivity extends Activity {
}We no longer support ActionBarSherlock with the options menu related annotations. You should use the AppCompat Support Library instead.
We no longer call setIntent() in the onNewIntent() method if you use these annotations. If you need this, you can call it yourself.
@Extra
int myExtra;
// AA 3.x called setIntent() in the overriden `onNewIntent()` methodTo achieve the same behavior in AA 4.0.0:
@Extra
int myExtra;
protected void onNewIntent(Intent intent) {
setIntent(intent);
}We no longer allow unannotated method parameters, you must tell the processor explicitly the meaning of each method parameter.
For the the request body:
@Rest(converters = GsonHttpMessageConverter.class)
public interface MyRestClient {
@Put
void putEvent(Event event); // AA 3.x request body is the event variable
}
@Rest(converters = GsonHttpMessageConverter.class)
public interface MyRestClient {
@Put
void putEvent(@Body Event event); // AA 4.0.0
}For the url variables:
@Rest(converters = GsonHttpMessageConverter.class)
public interface MyRestClient {
@Get("/events/{id}"
Event getEvent(int id); // AA 3.x the id method param is an url variable
}
@Rest(converters = GsonHttpMessageConverter.class)
public interface MyRestClient {
@Get("/events/{id}"
Event getEvent(@Path int id); // AA 4.0.0
}A mandatory argument, value was introduced for @DefaultStringSet, just like for the rest of the @DefaultXXX annotations. Usage:
@DefaultStringSet({ "John", "Mary" })
String<Set> names();