1

So I'm trying to develop an app with Android Studio. Everything was working fine. Then I wanted to run my app on the Virtual Device just as I did a few minutes before but it failed at synchronizing the Gradle build:

Error:Failed to resolve: com.google.android.gms:play-services-measurement:9.0.0 Install Repository and sync project
Open File
Show in Project Structure dialog

This is my Project Gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {   
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'com.google.gms:google-services:2.0.0-alpha6'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And this is my Module Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.stefan.myapplication"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/ECLIPSE_.RSA'
        exclude 'META-INF/ECLIPSE_.SF'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile project(':org.eclipse.paho.android.service-1.0.2')
    compile project(':org.eclipse.paho.client.mqttv3-1.0.2')

    compile project(':android-beacon-library-2.8.1')
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.google.android.gms:play-services:9.0.0'
    compile 'com.android.support:support-v4:23.4.0'
}
apply plugin: 'com.google.gms.google-services'

So I researched and tried this: https://stackoverflow.com/a/37312564/6256209 and changed com.google.gms:google-services:2.0.0-alpha6 to com.google.gms:google-services:3.0.0

After that my Gradle Build would sync just fine within 5 seconds or so.

But it fails If I want to run it on the Virtual Device. It gives me 4 Errors:

Error:java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Stefan\JEE\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2

All of them ending with finished with non-zero exit value.

So I found this: Java finished with non-zero exit value 2 - Android Gradle

And I tried to set multiDexEnabled to true and checked if I included unnecessary libs. I also clean and rebuild the app but nothing worked.

I'm really thankfull for any kind of help and advice

Community
  • 1
  • 1
nummer92
  • 31
  • 11
  • Perhaps worth a look at.. http://stackoverflow.com/questions/36698816/gradle-what-is-a-non-zero-exit-value-and-how-do-i-fix-it – OneCricketeer May 24 '16 at 12:32
  • Possible duplicate of [Java finished with non-zero exit value 2 - Android Gradle](http://stackoverflow.com/questions/29756188/java-finished-with-non-zero-exit-value-2-android-gradle) – Bharatesh May 24 '16 at 12:51
  • No sadly not. I started a new Project and did everything the same way and it works. – nummer92 Aug 18 '16 at 15:54

2 Answers2

2

At First you should call this

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.google.gms:google-services:3.0.0'

}

The Android plugin for Gradle available in Android SDK Build Tools 21.1 and higher supports multidex as part of your build configuration. Make sure you update the Android SDK Build Tools tools and the Android Support Repository to the latest version using the SDK Manager before attempting to configure your app for multidex.

Then add multiDexEnabled true

android {
     compileSdkVersion 23
     buildToolsVersion "23.0.2"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 23
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

Finally Clean-Rebuild-Sync-Run .

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

SO these are the 8 new Errors:

Error:UNEXPECTED TOP-LEVEL ERROR:

Error:java.lang.OutOfMemoryError: GC overhead limit exceeded

Error:java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Stefan\JEE\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 3

Error:com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Stefan\JEE\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 3

Error:com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Stefan\JEE\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 3

Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Stefan\JEE\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 3

Error:com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Stefan\JEE\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 3 Error:org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Stefan\JEE\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 3

nummer92
  • 31
  • 11