I'm struggling with moving a project from Eclipse to Android Studio and getting Android Annotations to work properly.
I've used AA in various projects without too many issues, but this has me stumped. I have the usual setup in my gradle files:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
jcenter()
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
and
apply plugin: 'android'
apply plugin: 'com.neenbedankt.android-apt'
def AAVersion = '3.3.2'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':libprojects:ActiveAndroid')
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'joda-time:joda-time:2.8.2'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.1.3'
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
// java.srcDirs = ['.apt_generated','src'] // We had big build issues with this left in, but it builds OK with it commented out
resources.srcDirs = ['.apt_generated','src']
aidl.srcDirs = ['.apt_generated','src']
renderscript.srcDirs = ['.apt_generated','src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE'
}
}
apt {
arguments {
// Mark - This looks like it's not actually needed, as it builds fine without and throws up a warning when it's included.
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
}
}
The app seems to build OK, but I get a ClassNotFoundException immediately upon running. I've checked the build directory and no ClassName_ classes seem to be generated. Also my androidannotations.log file only has the following line:
20:11:45.159 [Daemon worker Thread 30] INFO o.a.AndroidAnnotationProcessor:83 - Initialize AndroidAnnotations 3.3.2 with options {androidManifestFile=/Users/marky/myapp/android/build/intermediates/manifests/full/debug/AndroidManifest.xml}
Whereas another app I've build has a much longer log:
20:11:58.93 [Daemon worker] INFO o.a.AndroidAnnotationProcessor:83 - Initialize AndroidAnnotations 3.3.2 with options {androidManifestFile=/Users/marky/anotherapp/app/build/intermediates/manifests/full/debug/AndroidManifest.xml}
20:11:58.164 [Daemon worker] INFO o.a.AndroidAnnotationProcessor:107 - Start processing for 18 annotations on 26 elements
20:11:58.215 [Daemon worker] DEBUG o.a.h.AndroidManifestFinder:98 - AndroidManifest.xml file found with specified path: /Users/marky/anotherapp/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
...loads more lines
So it looks like AA is not running fully, but I'm not sure why. I've searched all day on SO and other places for a solution but I can't see one.