6

My android app failed to sync gradle with the following error in build log:

Uninitialized object exists on backward branch 70
Exception Details:
  Location:
    com/android/build/gradle/tasks/BuildArtifactReportTask.newArtifact(Lcom/android/build/api/artifact/BuildableArtifact;)Lcom/android/build/gradle/tasks/BuildArtifactReportTask$BuildableArtifactData; @119: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: bb00 f459 2bb9 0139 0100 c000 6b2b b901
    0000010: 3d01 0001 b901 4302 0059 1301 45b8 0148
    0000020: c000 374d 3a0d 3a0c 3a0b 2c4e bb00 6859
    0000030: 2c10 0ab8 003d b700 69c0 006b 3a04 2db9
    0000040: 0054 0100 3a05 1905 b900 5a01 0099 002d
    0000050: 1905 b900 5e01 003a 0619 0419 06c0 014a
    0000060: 3a07 3a0e 1907 b901 4d01 003a 0f19 0e19
    0000070: 0fb9 0075 0200 57a7 ffcf 1904 c000 773a
    0000080: 0e19 0b19 0c19 0d19 0eb7 0150 b0       
  Stackmap Table:
    full_frame(@70,{Object[#2],Object[#109],Object[#55],Object[#55],Object[#107],Object[#86],Top,Top,Top,Top,Top,Uninitialized[#0],Uninitialized[#0],Object[#107]},{})
    same_frame(@122)

Here is my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.3'

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 111
        versionName "1.1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(":adjust")
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.google.firebase:firebase-core:11.0.1'
    compile 'com.google.firebase:firebase-messaging:11.0.1'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

I'm happy to provide more information if you need.

Sithu
  • 4,752
  • 9
  • 64
  • 110
  • 1
    Check this similar [link](https://stackoverflow.com/questions/49515100/gradle-sync-failed-with-android-studio-3-1-uninitialized-object-exists-on-backw/49518396) – Gautam Surani Jun 14 '18 at 07:41
  • Thank you for your link. It did solve the above error. But I got another error `Unable to start the daemon process. Error occurred during initialization of VM Could not reserve enough space for 1048576KB object heap` I disabled daemon by adding `org.gradle.daemon=false`, but no luck. – Sithu Jun 14 '18 at 08:44
  • [This](https://stackoverflow.com/a/30090271/1179841) solved my daemon issue – Sithu Jun 14 '18 at 09:46

3 Answers3

8

enter image description here to solve that problem permanently, go to Module Settings > SDK Location > Use embedded JDK.

This will remove dependency on the external Java installation by using the embedded JDK.

Elie Faës
  • 3,215
  • 1
  • 25
  • 41
  • This is pretty exact extract from [the link provided above by Gautam Surani](https://stackoverflow.com/a/49552113/1179841) – Sithu Jun 14 '18 at 09:48
  • 1
    On Android Studio Arctic Fox: File -> Project structure -> Gradle settings -> Gradle JDK -> Embedded JDK from dropdown – Talu Sep 28 '21 at 00:26
2

Android Studio: 3.5.3
gradle plugin: 3.5.3
gradle: 5.4.1
platform: Mac OS Mojave 10.14.6 (18G103)

I had done this:Project Structure -> SDK Location -> Select "Use embedded JDK(recommended)" but it still not working.

when I read this article,

you can add a property at gradle.properies:

org.gradle.java.home=(path to JDK home)

it works!

Blues
  • 93
  • 6
  • 1
    I got the same error in the android studio android platform, Flutter and Unity as well. What went wrong for me was that I used an external JDK 1.8 version (Not the embedded version) and it was a broken version. then I installed JDK-8u202-windows-x64.exe from the oracle site. and after that set that version as they mention in the above answers. It worked perfectly for me. – Lasitha Lakmal Aug 28 '21 at 12:50
0

I got the same error in the android studio android platform, Flutter and Unity as well. What went wrong for me was that I used an external JDK 1.8 version (Not the embedded version) and it was a broken version.

then I installed JDK-8u202-windows-x64.exe from the oracle site.

and after that set that version as they mention in the above answers. It worked perfectly for me.

Lasitha Lakmal
  • 486
  • 4
  • 17