无法更新multidex行为

时间:2016-09-18 21:24:54

标签: android android-gradle android-manifest build.gradle android-multidex

我的应用程序工作正常,但问题来自multidex android。我根据android.developers指南搜索了问题并进行了必要的更新。但是,我正在与同样的问题作斗争。应用不同的解决方案,但仍有相同的问题。一个gradle构建需要11-12分钟直接测试解决方案,我必须等待11-12分钟,这真的杀了我。我正在分享我的Gradle和清单文件。请帮忙解决这个问题。

Build.Gradle文件

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'

}

清单文件:

<?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>

2 个答案:

答案 0 :(得分:2)

您必须将此部分添加到build.gradle

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

真正的问题是您正在使用的:

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

不应该使用 compile 'com.google.android.gms:play-services:9.4.0',因为其中包含每个Google Play服务库 - 仅使用APIs you need

v4支持库的内容已被拆分为多个smaller modules.

答案 1 :(得分:1)

在您的gradle文件中添加以下依赖项

$(".bhome").click(function() {
$('html, body').animate({
    scrollTop: $("#someid").offset().top
}, 2000);

有关详细信息,请访问:https://developer.android.com/studio/build/multidex.html