配置Android注释非常麻烦。但是我终于找到了解决方案,并希望与大家分享。
最佳答案
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
repositories {
mavenCentral()
}
ext.androidAnnotationsVersion = '3.0.1';
configurations {
apt
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
useOldManifestMerger true
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
}
dependencies {
compile 'com.android.support:support-v4:20.0.+'
compile 'com.android.support:appcompat-v7:20.0.+'
apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "org.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
compile fileTree(dir: 'libs', include: '*.jar')
}
apt {
arguments {
resourcePackageName 'com.yourpackage.name'
androidManifestFile variant.processResources.manifestFile
}
}