Sapan Diwakar

Software developer

Follow me on Twitter Check out my code on GitHub View some of my designs on Dribbble Take a look at my Linked In profile

Building AndroidAnnotations project with Android Studio

Ever since the announcement of Android Studio, I had been wanting to try it out. But I tried very briefly to port one of my existing projects from Eclipse to Android Studio and had to give up finally. It has come a long way since and it will only get better. So for a new project, I made up my mind that I will get it set up in Android Studio before starting up.

Its a bit painful if you are using gradle for the first time. What took me the most time was to set up Android Annotations with the build system and getting it to generate the subclasses based on my Annotations. But once everything was setup, its a huge leap forward from Android development in Eclipse.

There is a Gradle AndroidAnnotations Plugin is available to use AndroidAnnotations in Gradle project. But, for me (and at least a few others on StackOverflow), it doesn't work out of the box. There is a bit of configuration required to get it to work. Here's a sample gradle build file that I use

With this gradle build file, you are ready to start annotating your activities, fragments and rest clients. Don't forget to rebuild the project once and mark build/source/apt_generated/debug as Sources root.

In addition to including AndroidAnnotations, it also includes some other libraries that you probably might want to include in your project. Its also really simple to include external jars in the project using gradle like we do for the Endless Adapter. If you are looking for some more wonderful Android libraries to get you going, you should check this out.