The other day I explained how to use Android Annotations with Gradle on Android Studio. There was a lot of Groovy to write before starting to program. I discover the android-apt plugin for Gradle which reduces my last post to boilerplate code. The excilys team advices to use it for building android annotations with Gradle.
This plugin does not target android annotations specifically but it helps you to work with android and annotation processors and make life easier on Android Studio.
Starting a new android application with Gradle and android annotations is simple:
I switched for some days from iOS to Android to start a new project and refresh a little bit my knowledge about the Android toolchain.
I’m not a first hour user of Java and I have to admit that I do not follow all news about new Java tools or features. I discovered IntelliJ and Gradle only 8 months ago. This was a very good discover and makes me forget old and disapointing experiences with Ant, Eclipse/Netbeans and XML configuration. I really thought XML was a part of the language. The announcement of Android Studio at the last Google I/O sounded like a resurrection of some of old projects on my hard drive disk.
Another bad experience with Android was the lot of boilerplate Java you have to write anytime you code GUI stuffs. In French GNU/Linux magazine I discovered the amazing android annotated library android annotations which do a million more than just avoid you to call the findViewById method.
After a lot of time reading the Gradle documentation and browsing Stack Overflow topics about this building tool, I succeed in having a working environment with Android Studio, Gradle and AndroidAnnotations on my laptop (OSX 10.9). I’ll try to share and explain my build.gradle in this post.
Pay attention to the version of Android Studio, Android SDK tools and Gradle you’re using !
Here I am using Android Studio v0.4.2, Android SDK tools 19.0.1 and Gradle 1.9.
I notice some problems by using the Gradle version provided with Android Studio. I rather download Gradle somewhere on my hard drive disk and configure Android Studio to use it (Android Studio -> Preferences).
Until here no magic, we tell Gradle we need some specifics dependencies to build our project.
The configuration statement defines a dependency group1. A named dependency group allows you to pick some informations later about the dependencies you define in this group. It is reprensented by an object implementing the Configuration interface 2.
This interface inherits a method named getAsPath which returns the classpath of the dependencies defined in the group as a String. We’ll use this method later to get the classpath of androidannotation annotation compiler.
We create a aptdependency group, to refer to the annotation processor dependencies.
Here we define the dependencies we need in each dependency groups. Within the compile group we add the libraries we need in our builded program. In the aptdependency groups, we add the library needed to process the androidannotations’ annotations.
For each variant, we access to the gradle java compilation task 5 of each variant and add some arguments to the compiler. Notice the call to getAsPath method as explained before to retrieve the classpath of the androidannotation’s compiler processor. We also set up, the output of processint to aptOutput
I discover this beautiful project on Github this morning that permits to inject dynamically code with Xcode4 without restarting the app. The project has a website where you can download the bundle for XCode 4. More explanation on how it’s working could be found here.
I was searching a way to edit or add GPS metadata of JPEG files without using an external library inside a Mac Application. After looking on internet and reading the ImageIOKit documentation, I found an interesting post on the Apple Mailing List talking about this topic and an old bug related to it. It includes a code sample that is apparently working now (Mac Os X 10.8). I just wanted to add some details about it :
The values corresponding to the kCGImagePropertyGPSLatitudeRef/kCGImagePropertyGPSLongitudedRef keys are expected to be of type NSString.
The values corresponding to the kCGImagePropertyGPSLatitude/kCGImagePropertyGPSLongitude keys are expected to be of type NSNumber.
I use Cocoapods for managing my Cocoa’s project dependencies. I had an issue with the RegexKitLite. I got an ‘unrecognized selectro send to instance’ issue when I wanted to use a method declared in a category added by RegexKitLite in the NSString interface.
To fix it, add the flags ‘-all_load’ in the Build settings under the ‘Other Linker Flags’ section.
Lors d’une petite session de programmation iOS, j’ai voulu créer une vue personnalisée composée de différentes subviews. Je souhaitais gérer les comportements des vues enfants en fonction de leur tags respectifs et mon programme ne réagissait pas comme je le souhaitais. Après un long moment à fouiner dans la doc sans avoir de réponse (si quelqu’un trouve une info, je suis preneur), j’ai trouvé la réponse à mon problème.
Le selecteur addSubview de la classe UIView modifie la valeur des tags des différentes vues que vous passez en arguments. Il vous faut fixer la valeur des tags des différentes vues APRÈS avoir utilisé la méthode addSubview.