我为我的Android应用程序编写了一个build.gradle文件。该应用程序使用AndroidAnnotations。
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.3.2'
buildscript {
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'org.androidannotations:androidannotations:3.3.2'
}
}
configurations {
apt
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName "de.xxx"
}
}
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "de.xxx"
minSdkVersion 11
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:23.1.1'
compile files('libs/acra-4.3.0.jar')
}
该脚本执行APT profecessing并生成Annotation_类。但之后脚本失败了,编译了导入语句和类似
的用法import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.EFragment;
import com.googlecode.androidannotations.annotations.ViewById;
脚本有什么问题?我知道还有改进的余地。
答案 0 :(得分:1)
使用此 build.gradle :
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
def AAVersion = '3.3.2'
buildscript {
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
resourcePackageName "de.xxx"
}
}
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "de.xxx"
minSdkVersion 11
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:23.1.1'
compile files('libs/acra-4.3.0.jar')
}
可以在guide或sample project中找到示例脚本。 更改导入语句,如:
import org.androidannotations.annotations.AfterViews;