我从Github接了一个项目并尝试在我的Android Studio(2.1.3)中运行,但它给我一个错误:
错误:任务执行失败 ':agendacalendarview:compileDebugJavaWithJavac'。编译失败; 有关详细信息,请参阅编译器错误输出。
我使用的是Java 1.8,Build工具版 - “24.0.3”,compileSdkVersion - 24.
我从StackOverFlow和其他来源尝试了很多相关的解决方案,但遗憾的是没有解决方案对我有用。
这里我附加了我的Gradle文件,
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.efftronics.android.samplecustomcalendar"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//avoid duplicate files during packaging of APK
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'LICENSE.txt'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
incremental true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.0.0'
// Other libraries
compile 'com.jakewharton:butterknife:7.0.0'
compile project(':agendacalendar')
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
android {
lintOptions {
abortOnError false
}
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs = ['assets']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
// Google libraries
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
// other libraries
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'io.reactivex:rxjava:1.1.1'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
//--> To Avoid JavaC Compilation Errors
tasks.withType(JavaCompile) {
configure(options) {
incremental = true
}
}
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Information:Gradle tasks [clean, :agendacalendar:generateDebugSources, :agendacalendar:generateDebugAndroidTestSources, :agendacalendar:mockableAndroidJar, :agendacalendar:prepareDebugUnitTestDependencies, :agendacalendar:compileDebugSources, :agendacalendar:compileDebugAndroidTestSources, :agendacalendar:compileDebugUnitTestSources, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources]
Observed package id 'build-tools;20.0.0' in inconsistent location 'C:\Android\Android_SDK\build-tools\android-4.4W' (Expected 'C:\Android\Android_SDK\build-tools\20.0.0')
Jack is required to support java 8 language features.
Jack is required to support java 8 language features.
:clean
:agendacalendar:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:mergeDebugAndroidTestShaders
:app:compileDebugAndroidTestShaders
:app:generateDebugAndroidTestAssets
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:mockableAndroidJar
:agendacalendar:preBuild UP-TO-DATE
:agendacalendar:preDebugBuild UP-TO-DATE
:agendacalendar:checkDebugManifest
:agendacalendar:preDebugAndroidTestBuild UP-TO-DATE
:agendacalendar:preDebugUnitTestBuild UP-TO-DATE
:agendacalendar:preReleaseBuild UP-TO-DATE
:agendacalendar:preReleaseUnitTestBuild UP-TO-DATE
:agendacalendar:prepareComAndroidSupportAnimatedVectorDrawable2400Library
:agendacalendar:prepareComAndroidSupportAppcompatV72400Library
:agendacalendar:prepareComAndroidSupportDesign2400Library
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:incrementalDebugJavaCompilationSafeguard
:agendacalendar:prepareComAndroidSupportRecyclerviewV72400Library
:app:compileDebugNdk UP-TO-DATE
:app:incrementalDebugAndroidTestJavaCompilationSafeguard
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:incrementalDebugUnitTestJavaCompilationSafeguard UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:processDebugUnitTestJavaRes UP-TO-DATE
:agendacalendar:prepareComAndroidSupportSupportV42400Library
:agendacalendar:prepareComAndroidSupportSupportVectorDrawable2400Library
:agendacalendar:prepareSeEmilsjolanderStickylistheaders270Library
:agendacalendar:prepareDebugDependencies
:agendacalendar:compileDebugAidl
:agendacalendar:compileDebugRenderscript
:agendacalendar:generateDebugBuildConfig
:agendacalendar:mergeDebugShaders
:agendacalendar:compileDebugShaders
:agendacalendar:generateDebugAssets
:agendacalendar:mergeDebugAssets
:agendacalendar:generateDebugResValues UP-TO-DATE
:agendacalendar:generateDebugResources
:agendacalendar:mergeDebugResources
:agendacalendar:processDebugManifest
:agendacalendar:processDebugResources
:agendacalendar:generateDebugSources
:agendacalendar:prepareDebugAndroidTestDependencies
:agendacalendar:compileDebugAndroidTestAidl
:agendacalendar:compileDebugNdk UP-TO-DATE
:agendacalendar:compileLint
:agendacalendar:copyDebugLint UP-TO-DATE
:agendacalendar:incrementalDebugJavaCompilationSafeguard
:agendacalendar:compileDebugJavaWithJavac
:agendacalendar:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
An exception has occurred in the compiler (1.8.0_92). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.lang.invoke.MethodType not found
:agendacalendar:compileDebugJavaWithJavac FAILED
Error:Execution failed for task ':agendacalendar:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 48.612 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
感谢。
答案 0 :(得分:0)
我注意到您正在使用Java 8 language features requires Jack enabled
,您需要将以下内容添加到您的gradle文件中(如上所示):
jackOptions {
enabled true
}
因此您必须在build.gradle
文件中添加此内容。然后尝试clean
和rebuild
项目。