VM具有Multidex支持,MultiDex支持库已禁用 [英] VM has multidex support, MultiDex support library is disabled

查看:181
本文介绍了VM具有Multidex支持,MultiDex支持库已禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误.

致命异常:主要

  • 2.1.0版的VM具有multidex支持
  • 安装
  • VM具有multidex支持,MultiDex支持库已禁用.
  • 安装
  • VM具有multidex支持,MultiDex支持库已禁用.
  • 关闭VM

这是我的build.gradle,我在android部分启用了multidex,

here is my build.gradle,i have enables the multidex in the android part,

apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion '23.0.0'

defaultConfig {
    applicationId "com.mycompany.newlogin"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

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

}
useLibrary 'org.apache.http.legacy'
}



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.guava:guava-jdk5:17.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
//compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'

}

我的清单文件是

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.newlogin" >
<uses-permission android:name="android.permission.INTERNET"/>


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

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Login"
        android:label="@string/title_activity_login" >
    </activity>
    <activity
        android:name=".Register"
        android:label="@string/title_activity_register" >
    </activity>
</application>
</manifest>

推荐答案

创建一个类,将其命名为 App 并从 MultiDexApplication 进行扩展,如下所示:

create a class lets name it App and extend from MultiDexApplication like this:

import android.support.multidex.MultiDexApplication;

public class App extends MultiDexApplication {
    //you can leave this empty or override methods if you like so the thing is that you need to extend from MultiDexApplication
}

在清单中添加 App 作为应用名称,就像这样

in your manifest add App as your application name just like this

<application
        android:name=".App" // <<< this is the important line!
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">

添加完所有内容后,进行一个干净的构建,它现在应该可以工作了:).

After adding everything make a clean build and it should work now :).

这篇关于VM具有Multidex支持,MultiDex支持库已禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆