我知道存在类似的主题,但实际上没有一个能够 100% 工作。
关于如何将最新的 android 注释
附加到最新的 android studio
版本的提示/脚本。
环境:Ubuntu x64、gradle 2.0、android studio 0.8.2
问候
编辑:
该解决方案还适用于 AndroidStudio 1.0
。
最佳答案
我使用 Android Studio 0.8.14。
我的主“应用程序”模块的 build.gradle 如下所示:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
String packageName = "mateuszklimek.aaexample"
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId packageName
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName packageName
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt "org.androidannotations:androidannotations:3.2"
compile "org.androidannotations:androidannotations-api:3.2"
}
不要忘记配置顶级 build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
allprojects {
repositories {
jcenter()
}
}
我已将示例项目推送到 Github 。
您可以通过 gradlew assembleDebug 在控制台中构建它。
关于java - 如何附加android注释v3+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24892865/