I am using Android Annotations for my Android project. I receive during startup of my App at my device the following exception
12-25 15:23:21.325: E/AndroidRuntime(24714): java.lang.RuntimeException:
Unable to instantiate activity
ComponentInfo{de.myproject.android/de.myproject.android.activity.MainActivity_}:
java.lang.ClassNotFoundException: Didn't find class "de.myproject.android.activity.MainActivity_"
on path: DexPathList[[zip file "/data/app/de.myproject.android-56.apk"],
nativeLibraryDirectories=[/data/app-lib/de.myproject.android-56, /vendor/lib, /system/lib]]
It seems to be that the generated Android Annotations Classes (MainActivity_) are not included in the apk file.
I am using the following Gradle build file
buildscript {
repositories {
jcenter()
mavenLocal();
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25"
defaultConfig {
minSdkVersion 16
targetSdkVersion 20
multiDexEnabled true
}
lintOptions {
abortOnError false
}
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
repositories {
jcenter()
mavenLocal()
maven {
url "https://jitpack.io"
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile 'com.firebaseui:firebase-ui-auth:1.0.1'
compile group: 'org.androidannotations', name: 'androidannotations', version: '4.1.0'
compile group: 'org.androidannotations', name: 'androidannotations-api', version: '4.1.0'
compile 'com.google.android.gms:play-services-location:10.0.0'
compile ('de.myproejct:myApi:v1-1.22.0-SNAPSHOT') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'com.google.code.findbugs'
}
compile ('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'com.google.code.findbugs'
}
compile 'net.steamcrafted:load-toast:1.0.10'
testCompile 'junit:junit:4.12'
}
The error occured for the first time when I added the following dependency
compile 'net.steamcrafted:load-toast:1.0.10'
to my build file. When I remove this dependency my app works perfect on my device.
So what is wrong with my build file or with Android Annotations?
You should use the AndroidAnnotations depency in annotationProcessor scope.