android - Android的MultiDex支持问题

标签 android gradle android-multidex

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'

最佳答案

启用multidex,如下所示:

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

创建一个这样的类
public class Multi_Dex extends Application {
    @Override
    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        MultiDex.install(this);
    }
}

现在在您的 list 文件中添加此
<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">

了解更多信息click here

关于android - Android的MultiDex支持问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45810997/

相关文章:

android - Gradle Build运行时间过长

android-studio - Android studio 使用 gradle2.5 依赖 com.android.tools.build :gradle-experimental:0. 2.1

java - 生成签名 apk 时出错,lint-results-release-fatal 中没有任何内容

android在后台加载webView并且不显示gui

android - 应用程序崩溃说 java.lang.NoClassDefFoundError : onPostExecute

java - Buck exopackage 多 dex 支持?

android - 如何删除不需要的dex文件?

android - 在任务 :transformClassesWithJarMergingAndroidTest 中构建 Android gradle 期间出现重复条目

android - Volley 失败的多部分表单数据请求

android - 如何通过解析字节模式来确定音频流类型