java.exe finished with non-zero exit value 2

前端 未结 2 548
谎友^
谎友^ 2020-12-03 16:03

My previous play service version is 6.5.87 and I upgraded to 7.0.0 then Got this error

com.android.ide.common.process.ProcessException: org.gradle.p

相关标签:
2条回答
  • 2020-12-03 16:49

    No one answered. I found.... The solution is multidex

    public class MyApplication extends MultiDexApplication {
    
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
    
    }
    

    in menifest file

    <application
            android:name=".MyApplication"
            android:allowBackup="true"
            android:icon="@drawable/app_icon"
            android:label="@string/app_name"
            android:largeHeap="true"
            android:theme="@style/Theme.MyAppTheme">
    

    My gradle file

    android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"
    
    defaultConfig {
        applicationId "com.winapp"
        minSdkVersion 14
        targetSdkVersion 21
        multiDexEnabled = true
    }
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    
    packagingOptions {
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
    }
    
    dexOptions {
        preDexLibraries = false
        incremental true
        javaMaxHeapSize "4g"
    }
    
    afterEvaluate {
        tasks.matching {
            it.name.startsWith('dex')
        }.each { dx ->
            if (dx.additionalParameters == null) {
                dx.additionalParameters = ['--multi-dex']
            } else {
                dx.additionalParameters += '--multi-dex'
            }
        }
    }
    }
    
    0 讨论(0)
  • 2020-12-03 16:55

    You will be able to include to your gradle only Google Play Services API that you will use. In this link you should select the URIs to compile in your project https://developers.google.com/android/guides/setup#split

    For example, if you would include only Google analytics you should add only this in your gradle project file

    compile 'com.google.android.gms:play-services-analytics:8.1.0'
    
    0 讨论(0)
提交回复
热议问题