我按照新的Android Studio建议升级Gradle和Android Build Tools,来自:
classpath 'com.android.tools.build:gradle:2.2.3'
buildToolsVersion '24.0.3'
为:
classpath 'com.android.tools.build:gradle:2.3.0'
buildToolsVersion '25.0.2'
但是在构建项目时出现错误:
Error:Could not find the AndroidManifest.xml file, using generation folder [/Users/me/StudioProjects/myproject/mymodule/build/generated/source/apt/release])
Error:Execution failed for task ':mymodule:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
我尝试将所有Android支持库升级到最新版本,我甚至尝试删除android-apt
并使用annotationProcessor
而不是apt
作为this answer建议,但它什么都没改变。
apply plugin: 'com.android.library'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.3.1'
}
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
ext {
androidAnnotationsVersion = '4.1.0'
supportLibraryVersion = '25.1.1'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
apt "org.androidannotations:androidannotations:$androidAnnotationsVersion"
compile "org.androidannotations:androidannotations-api:$androidAnnotationsVersion"
compile "com.android.support:support-v4:$supportLibraryVersion"
compile("com.android.support:recyclerview-v7:$supportLibraryVersion") {
exclude module: 'support-v4'
}
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
compile "com.android.support:cardview-v7:$supportLibraryVersion"
compile("com.android.support:design:$supportLibraryVersion") {
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
}
testCompile 'junit:junit:4.12'
}