我尝试了来自 google 和 stackoverflow 的许多选项。 安卓工作室 0.4.6 和 aa 2.7.1。 我的 build.gradle 看起来像这样
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
ext.daggerVersion = '1.0.0';
ext.androidAnnotationsVersion = '2.7.1';
configurations {
apt
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
apt "com.squareup.dagger:dagger-compiler:${daggerVersion}"
compile "com.squareup.dagger:dagger:${daggerVersion}"
}
我也检查了 AndroidManifest.xml 中的 Activities_。
如果这个问题没有因为其他“类似”问题而被禁止,我更喜欢使用完全相同的 as
版本的人的答案。我知道会有下一个版本的问题,也许还有新问题,但这看起来有点棘手恕我直言。尽管使用 aa 的 android 开发非常强大。
“将项目与 gradle 文件同步”、清理、重建等没有任何效果。
编辑:
我试过
ext.daggerVersion = '1.2.0';
ext.androidAnnotationsVersion = '3.0.1';
但是没有结果。
切换到之后: 类路径 'com.android.tools.build:gradle:0.8.+' 和 ext.daggerVersion = '1.2.0';
它构建成功但输出:
Default Activity not found
我检查了Error: Default Activity Not Found没有效果。
最佳答案
看起来您需要在 BuildScript 依赖项中添加 android-apt 依赖项,并让 gradle 知道将其用作插件。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
}
}
apply plugin: 'android'
apply plugin: 'android-apt'
这是我的 apt 配置部分,您可能需要其他设置,但这应该可以帮助您入门
apt {
arguments {
resourcePackageName android.defaultConfig.packageName
androidManifestFile variant.processResources.manifestFile
}
}
关于java - 是否可以将 android 注释与 android studio 0.4.6 集成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22027982/