我正在为Android项目使用Android Annotations。我在我的设备启动我的设备时收到以下异常
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]]
似乎生成的Android Annotations Classes(MainActivity_)不包含在apk文件中。
我正在使用以下Gradle构建文件
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'
}
我添加以下依赖项
时第一次出现错误 compile 'net.steamcrafted:load-toast:1.0.10'
到我的构建文件。当我删除此依赖项时,我的应用程序在我的设备上完美运行
那么我的构建文件或Android Annotations有什么问题?
答案 0 :(得分:0)
您应该在annotationProcessor范围内使用AndroidAnnotations依赖项。