-1

When I compile the codes,I get 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.

This is my codes:

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>




<application
    android:allowBackup="true"
    android:icon="@drawable/police"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>
    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>


    <activity
        android:name=".MainActivity">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Ali Göktaş
  • 15
  • 1
  • 7
  • http://stackoverflow.com/questions/15209831/unable-to-execute-dex-method-id-not-in-0-0xffff-65536 – CommonsWare Apr 24 '17 at 18:25
  • 1
    Possible duplicate of [Error:Execution failed for task ':app:transformClassesWithDexForDebug'](http://stackoverflow.com/questions/33717886/errorexecution-failed-for-task-apptransformclasseswithdexfordebug) – sziraqui Apr 24 '17 at 18:26
  • Probabaly memory issues. Increase the memory in Android Manifest android:name="android.support.multidex.MultiDexApplication" or increase the heap size in build.gradle javaMaxHeapSize "4g" – sivaprakash Apr 24 '17 at 19:16

3 Answers3

0

Try adding this in you gradle

android {

    defaultConfig {
        ...

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

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

You are not using the entire Google Play Services API so instead of compiling the whole package in the build.gradle files try compiling individual services that you require for your project. From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:

compile 'com.google.android.gms:play-services:9.0.0'

with these lines:

compile 'com.google.android.gms:play-services-fitness:9.0.0'
compile 'com.google.android.gms:play-services-wearable:9.0.0'

You need to check what services you are going to require and compile them accordingly.

theSereneRebel
  • 196
  • 3
  • 16
-1

adding those play services tends to introduce dex error. First try cleaning your application through your IDE,

if that does not work add this to build .gradle

 defaultConfig {
    multiDexEnabled true
}
Vardaan Sharma
  • 1,125
  • 1
  • 10
  • 21