Search code examples
androiddex

Error .dex exceeds 64k android studio


When i try to run the program, i get error exceeds 64k I don't know how to solve this. I had already try the resolve but it still failed and give me more error. Please help me

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.example.timslbl.geogencybaru"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'

        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.2.1'
    compile 'com.roughike:bottom-bar:1.2.1'
    compile 'com.google.http-client:google-http-client-android:+'
    compile 'com.google.api-client:google-api-client-android:+'
    compile 'com.google.api-client:google-api-client-gson:+'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:support-v4:23.2.1'
}

Manifest

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

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

    <!-- Required to show current location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- Required OpenGL ES 2.0. for Maps V2 -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <aplication
        android:name="android.support.multidex.MultiDexApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        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>
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="" />

        <activity android:name=".MapActivity" />
        <activity android:name=".MainActivity"></activity>
        <activity android:name=".LoginActivity"></activity>
        <activity android:name=".RegisterActivity"></activity>
    </aplication>
</manifest>

This is the error that i got after try the resolve enter image description here


Solution

  • I highly suggest not to compile compile 'com.google.android.gms:play-services:8.4.0' as it is,

    Which is one of the main cause of 64K method dex limit.

    The separate compilations beyond play-services itself is listed Here, Use the one you really need rather than compiling the whole play-services.