Error while compiling Android

Asked

Viewed 317 times

0

When compiling, the following error occurs:

:app:transformClassesWithDexForDebug FAILED
Error:1 error; aborting
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_91\bin\java.exe'' finished with non-zero exit value 1

build.Gradle:

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'
    //compile 'com.android.support:support-v4:22.1.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    targetCompatibility = '1.7'
    sourceCompatibility = '1.7'
}

}

allprojects { repositories { jcenter() } }

task clean(type: Delete) {
delete rootProject.buildDir
}
  • Can show code where error occurs?

  • The error tells you how to solve: add targetCompatibility = '1.7'and sourceCompatibility = '1.7'at the build.Gradle.

  • @ramaral I already updated the question showing how this mine build.fgradle. After adding the following error occurred Error:(11, 0) No such property: targetCompatibility for class: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated&#xA;<a href="openFile:C:\Users\LordLokon\Desktop\Arquivos\Work Android\HorarioEscolaApp\build.gradle">Open File</a>

  • It is not in this Gradle but in the module and this way: compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 }. Still I can’t guarantee it’s enough.

  • @ramaral Could you send me the complete file (for download or writing), please ??

  • The content of the file is different in each project. You have to post yours so we can try to figure out where the problem is.

Show 1 more comment

1 answer

1

Some of your project’s dependencies have been compiled with Java 8, but you’re using Java 7 in the project. Put your project to use Java 8 or recompile the library that is causing the problem after making the necessary change.

  • Before I was giving error to compile in Java 8, so I changed to 7.

  • 1

    Open a new question with the error that was giving before, because it probably has no relation to this question/ answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.