0

Ich bekomme unten Fehler beim Ausführen meiner Anwendung.app: transformClassesWithDexForDebug Ausnahme und java.util.concurrent.ExecutionException

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

Ich denke, das Problem ist mit meiner .gradle-Datei. Vielleicht eine Duplizierung für die Abhängigkeit in meiner .gradle-Datei. Ich habe einen entfernt, bekomme aber immer noch den Fehler.

Meine .gradle-Datei ist wie folgt.

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.mypackagename" 
     minSdkVersion 15 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.android.support:appcompat-v7:25.0.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8' 
    compile 'com.google.android.gms:play-services:11.0.2' 
    compile 'com.android.support:design:25.0.0' 
    compile 'com.android.support:recyclerview-v7:25.0.1' 
    testCompile 'junit:junit:4.12' 
    compile 'com.squareup.retrofit2:retrofit:2.1.0' 
    compile 'com.android.support:cardview-v7:24.2.+' 

    compile 'com.google.code.gson:gson:2.6.1' 
    compile 'com.squareup.retrofit2:converter-gson:2.1.0' 
    compile 'com.squareup.okhttp:okhttp:2.6.0' 

    compile 'com.google.firebase:firebase-auth:11.0.2' 
    compile 'com.google.android.gms:play-services-auth:11.0.2' 
} 
} 

Mein Manifest-Datei:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.mypackagename"> 

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="com.roadysmart.permission.MAPS_RECEIVE" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/ic_launcher" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".SplashActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".MainActivity" 
     android:screenOrientation="portrait" 
     android:theme="@style/AppTheme.NoActionBar"></activity> 
    <activity 
     android:name=".UserProfileEditActivity" 
     android:label="User Profile" 
     android:screenOrientation="portrait" /> 
    <activity 
     android:name=".SignInActivity" 
     android:label="Sign In" 
     android:screenOrientation="portrait" /> 
    <activity 
     android:name=".SelectActivity" 
     android:label="Were here to help" 
     android:screenOrientation="portrait" /> 
    <activity 
     android:name=".SignUpActivity" 
     android:label="Sign Up" 
     android:screenOrientation="portrait" /> 
    <activity 
     android:name=".ForgotPasswordActivity" 
     android:label="Forgot Password" 
     android:screenOrientation="portrait" /> 
    <activity 
     android:name=".UserProfileActivity" 
     android:label="User Profile" 
     android:screenOrientation="portrait" /> 

    <meta-data 
     android:name="com.google.android.geo.API_KEY" 
     android:value="AIzaS0000000014789occURS5KvtKgfdreWjaDI" /> 

</application> 

+0

Mögliches Duplikat von [MultiDex NoClassDefFound error] (https://StackOverflow.com/questions/26655541/multidex-noclassdeffound-error) –

Antwort

3

Try multiDexEnabled true in defaultConfig hinzufügen.

Darüber hinaus ist es nicht empfehlenswert, com.google.android.gms:play-services:11.0.2 direkt zu verwenden, sondern die Abhängigkeiten, die Sie separat arbeiten möchten. Wenn Sie beispielsweise mit Google Maps arbeiten möchten, fügen Sie nur com.google.android.gms:play-services-maps:11.1.0 und so weiter hinzu.

+0

getan bro, danke. –

+0

Kein Problem. Freut mich, Ihnen behilflich zu sein. – fluffyBatman

1

com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

Sie die dex limit für die Anzahl der Methoden getroffen haben, die, in denen verwendet werden kann, betrifft alle Gerät unter Android 5.0(21) .

Um dies zu beheben, müssen Sie multi-dex in Ihrem Gradle aktivieren und Ihre Anwendung erweitert MultiDexApplication, um mit dem maximalen Dex-Limit umzugehen.

android { 
    defaultConfig { 
     ... 
     minSdkVersion 21 
     targetSdkVersion 26 
     multiDexEnabled true 
    } 
    ... 
} 
Verwandte Themen