问题描述
我已按照Wiki指示使用最新版本的AndroidStudio设置了ActiveAndroid.我正在使用产品调味剂.这是我的gradle构建文件:
I have setup ActiveAndroid as per the wiki instructions using latest version of AndroidStudio. I am using product Flavours. This is my gradle build file:
apply plugin: 'android'
apply plugin: 'android-apt'
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName android.defaultConfig.packageName
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
a {
packageName "com.a.a"
}
b {
packageName "com.a.b"
}
c {
packageName "com.a.c"
}
}
}
dependencies {
apt "org.androidannotations:androidannotations:3.0+"
compile "org.androidannotations:androidannotations-api:3.0+"
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
为构建文件添加了分级,但是当我在设备上进行编译/调试时,会收到两个错误:
Gradle build files but when I compile/go to debug on the device I receive two errors:
错误::找不到生成的null.R类
Error:: The generated null.R class cannot be found
和
错误:任务':ml:compileADebugJava'的执行失败.
Error:Execution failed for task ':ml:compileADebugJava'.
我已经为构建文件尝试了许多设置,但终生无法正常运行.另外,当我尝试从以下位置更改我的AndroidManifest时:
I have tried numerous setups for my build file but cannot for the life of me get it work. Also when I try and change my AndroidManifest from:
android:name ="com.a.a.MainActivity"
android:name="com.a.a.MainActivity"
到
android:name ="com.a.a.MainActivity _"
android:name="com.a.a.MainActivity_"
它声明找不到类.
我正在使用最新版本的Gradle和最新版本的ActiveAndroid.
I am using latest version of Gradle and latest version of ActiveAndroid.
任何帮助将不胜感激.
推荐答案
我知道它来晚了,但它可能对某人有帮助.
I know its late, but it might help someone.
在修改applicationId时会发生这种情况.示例中提供的脚本假定您已声明"android.defaultConfig.applicationId".在大多数情况下,它为null,因此生成了null.R.您可以定义变量或将代码更改为以下内容:
This happens when you modify the applicationId. The script provided in example assumes that you have declared "android.defaultConfig.applicationId". In most of the cases its null, and hence it generated null.R. Either you can define the variable or change the code to following:
defaultConfig {
// Rest of Config
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": "<Original Package Name>"]
}
}
}
请注意,原始套件名称应与活动中R的位置相同.
Note that original Package name should be same as the location of R in your activity.
希望有帮助!
这篇关于AndroidAnnotations + Android Studio-找不到生成的null.R类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!