java - 无法解决 Android 错误 :Execution failed for task ':app:compileDebugJavaWithJavac'

标签 java android android-studio gradle android-gradle-plugin

仍然有以下错误:

 Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
 Compilation failed; see the compiler error output for details.

即使在 stackoverflow 上尝试了解决方案后,我仍然不知道如何解决这个问题。有人指导我如何解决这个问题吗?

当我同步我的项目时,一切正常,但当我运行应用程序时,它崩溃了。 在过去的一个月里,一切都工作得很好,但突然崩溃了。

定位 Api 22,因为 creativesdk 与此 api 配合良好,基于我在网站 Adobe Creative sdk 上看到的博客。

完整错误消息:

:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
An exception has occurred in the compiler (1.8.0_60). Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) after checking the database for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.ClassFormatError: Illegal UTF8 string in constant pool in class file com/sun/tools/javac/tree/DocTreeMaker
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)  
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.sun.tools.javac.parser.ParserFactory.<init>(ParserFactory.java:73)
at com.sun.tools.javac.parser.ParserFactory.instance(ParserFactory.java:54)
at com.sun.tools.javac.main.JavaCompiler.<init>(JavaCompiler.java:356)
at com.sun.tools.javac.main.JavaCompiler.instance(JavaCompiler.java:88)
at com.sun.tools.javac.main.Main.compile(Main.java:485)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:45)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745):app:compileDebugJavaWithJavac FAILED
Error:Execution failed for task ':app:compileDebugJavaWithJavac'
Compilation failed; see the compiler error output for details.

我的build.gradle(应用程序):

apply plugin: 'com.android.application'

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
}
}

allprojects {
apply plugin: 'maven'

tasks.withType(JavaCompile) {
    options.fork = true

    options.incremental = true
}
repositories {
    mavenCentral()
    jcenter()

    maven {
        url "${project.rootDir}/creativesdk-repo/release"  //ADD THE CORRECT LOCATION OF THE CREATIVESDK LIBRARY FILES
    }
}
}

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.example.yo.mophoto"
    minSdkVersion 21
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    renderscriptTargetApi 22
    renderscriptSupportModeEnabled true
}
signingConfigs {
    release {
        storeFile file('release.key')
        storePassword '123456'
        keyAlias 'alias'
        keyPassword '123456'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
    main {
        setRoot 'src/main'
    }

    debug {
        setRoot 'src/debug'
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled false
    }
}
packagingOptions {
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE.txt'
}
dexOptions {
    jumboMode true
    incremental true
    preDexLibraries false
    javaMaxHeapSize "4g"
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.adobe.creativesdk:image:4.0.0'
compile 'com.android.support:recyclerview-v7:22.0.0'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'org.lucasr.twowayview:twowayview:0.1.4'
compile files('libs/universal-image-loader-1.9.0.jar')
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
}

最佳答案

看来您使用的是 java 1.8。和

编译选项{ 源兼容性 JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 }

我建议你尝试使用java 1.7。 我不确定,但错误看起来像 this无法解析您的文本。

我也建议编译器中发生异常(1.8.0_60)。请在 Java Bug 数据库中提交 Bug。

关于java - 无法解决 Android 错误 :Execution failed for task ':app:compileDebugJavaWithJavac' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35046673/

相关文章:

Java 执行器和长生命周期线程

android - 如何在android中获取 View 的绝对路径?

第三方应用的Android测试记录和webview支持

java - 如何将在java上创建的新textview与其在android studio中的xml特征链接起来?

java - in 无法应用于android studio

java - 如何比较两个数组。一个数组从文件中获取,另一个数组是随机数?

Java异常处理案例

java - 如何在Android中的SQLite数据库中查找TEXT或VARCHAR类型的特定列占用的内存(大小)?

java - Android - 具有形状可绘制对象和以编程方式渐变的自定义按钮

java - 为 Java 集成测试模拟慢速 HTTP 连接?