Execution failed for task ':app:compileDebugJavaWithJavac' Android Studio 3.1 Update

后端 未结 13 832
广开言路
广开言路 2020-12-08 06:44

I am getting error after updating the version of Android Studio 3.1 Canary 6

I don\'t why its happen, before that it\'s running successfully.

<
相关标签:
13条回答
  • 2020-12-08 06:58

    Not sure if this solution works for you or not but just want to heads you up on compiler and build tools version compatibility issues.

    This could be because of Java and Gradle version mismatch.

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
    

    Gradle 4.4 is compatible with only Java 7 and 8. So, point your global variable JAVA_HOME to Java 7 or 8.

    In mac, add below line to your ~/.bash_profile

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home

    You can have multiple java versions. Just change the JAVA_HOME path based on need. You can do it easily, check this

    0 讨论(0)
  • 2020-12-08 07:02

    This worked for me!

    App/build.gradle

    //Add this....Keep both version same

    compileOptions {                                                          
        sourceCompatibility JavaVersion.VERSION_1_8 
        targetCompatibility JavaVersion.VERSION_1_8
    } 
    
    0 讨论(0)
  • 2020-12-08 07:07

    I had similar issue and no errors shown in Compilation. I have tried to clean and rebuild without any success. I managed to find the issue by using Invalidate Caches/Restart from file Menu, after the restart I managed to see the compilation error.

    0 讨论(0)
  • 2020-12-08 07:07

    I'm on Android Studio 3.1 Build #AI-173.4670197, built on March 22, 2018 JRE: 1.8.0_152-release-1024-b02 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.

    I had the same issue and it only worked after changing my build.grade file to

        compileOptions {                                                          
        sourceCompatibility JavaVersion.VERSION_1_8 
        targetCompatibility JavaVersion.VERSION_1_8
    
    
    }
    

    Prior to this change nothing worked and all compiles would fail. previously my settings were

    sourceCompatibility JavaVersion.VERSION_1_7 
    targetCompatibility JavaVersion.VERSION_1_8
    
    0 讨论(0)
  • 2020-12-08 07:09

    I solved it by deleting "/.idea/libraries" from project. Thanks

    0 讨论(0)
  • 2020-12-08 07:09

    I have resolved this issue after selecting the "Target Compatibility" to 1.8 Java version. File -> Project Structure -> Modules.

    0 讨论(0)
提交回复
热议问题