Mudasir Sharif
Mudasir Sharif

Reputation: 731

Not able to update the multidex behavior

My application was working fine but that problem came which is related to multidex android. I searched for the problem and did the essential update according to android.developers guide. But its been hours i am fighting with the same problem. Applied different solutions but still the same issue is there. One gradle build is taking 11-12 minutes straight away and to test a solution i have to wait 11-12 minutes which is really killing me. I am sharing my Gradle and manifest file. Please help regarding this issue.

Build.Gradle File

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.mudasir.login"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions{
        exclude'META-INF/NOTICE.txt'
        exclude'META-INF/NOTICE'
        exclude'META-INF/notice.txt'
        exclude'META-INF/LICENSE.txt'
        exclude'META-INF/LICENSE'
        exclude'META-INF/license.txt'

    }
    dexOptions{
        preDexLibraries = false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    //compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.google.android.gms:play-services:9.4.0'

}

Manifest File:

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

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

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality. 
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        android:name="android.support.multidex.MultiDexApplication">
        <activity
            android:name=".SignUpActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".MainScreenActivity"
            android:label="@string/title_activity_main_screen_activity"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SignInActivity"
            android:label="@string/title_activity_signin_"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".sidemenu_Activity"
            android:theme="@style/AppTheme.NoActionBar">


        </activity>

        <!--
             The API key for Google Maps-based APIs is defined as a string resource.
             (See the file "res/values/google_maps_api.xml").
             Note that the API key is linked to the encryption key used to sign the APK.
             You need a different API key for each encryption key, including the release key that is used to
             sign the APK for publishing.
             You can define the keys for the debug and release targets in src/debug/ and src/release/. 
        -->
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity
            android:name=".MapsActivity"
            android:label="@string/title_activity_maps">
        </activity>
    </application>

</manifest>

Upvotes: 1

Views: 154

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363765

You have to add this part to your build.gradle

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

But the real issue is that you are using:

compile 'com.android.support:support-v4:24.2.0'
compile 'com.google.android.gms:play-services:9.4.0'

You shouldn't ever be using compile 'com.google.android.gms:play-services:9.4.0' as that includes every Google Play services library - only use the APIs you need.

The same for the v4 Support Library that has been split into several smaller modules.

Upvotes: 2

abhishesh
abhishesh

Reputation: 3316

add following dependency in your gradle file

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

For more information, visit : https://developer.android.com/studio/build/multidex.html

Upvotes: 1

Related Questions