简体   繁体   English

Android的MultiDex支持问题

[英]MultiDex Support issues Android

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
 com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex 'C:\Users\faisal\.android\build-cache\b8fc169a71d6759757864b00f302f95b66921263\output\jars\classes.jar' to 'C:\Users\faisal\Desktop\application-app-search-global\app\build\intermediates\transforms\dex\debug\folders\1000\10\classes_abbf8d2bb1ffecc7fb77ef565c2873fc6625cf3d'

enable multidex as following: 启用multidex,如下所示:

android {    
    defaultConfig {
        // Enabling multidex support.
        multiDexEnabled true
    }  
}
dependencies {
    // add dependencies for multidex
    compile 'com.android.support:multidex:1.0.1'
}

create one class like this 这样创建一个类

public class Multi_Dex extends Application {
    @Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        MultiDex.install(this);
    }
}

now in your manifiest file add this 现在在您的清单文件中添加此

<application
    android:name=".Multi_Dex" <!-- this line enable multi-dex application -->
    android:allowBackup="true" <!-- rest of them doesen't matter to enable multi-dex -->
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

for more detail click here 有关更多详细信息, 请单击此处

There was no issue with MultiDex library support. MultiDex库支持没有问题。 The main problem was with version of google.gms play-services. 主要问题是google.gms播放服务的版本。

compile 'com.google.android.gms:play-services-analytics:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'

which made the app to crash. 导致应用崩溃。 All I had to was to update my google services via the android sdk manager. 我所要做的就是通过android sdk管理器更新我的Google服务。 Then change the version number from 11.0.1 to 11.0.4. 然后将版本号从11.0.1更改为11.0.4。 This was just the plugin version issue which crashed the app and muddled error messages. 这只是插件版本问题,导致应用程序崩溃并使错误消息混乱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM