Android Studio 解析失败:multidex 打开文件
Android Studio Failed to resolve: multidex Open File
解析失败:multidex
打开文件
我在同步我的项目时发现了这个错误。
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion 16
targetSdkVersion rootProject.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
def system_dependencies = rootProject.ext.system_dependencies
compile system_dependencies.appcompat_v7
testCompile 'junit:junit:4.12'
}
我添加了这个,但是它不起作用;
maven {
url 'https://maven.google.com'
}
我试了很多ways.How解决了?
在 Android 5.0 之前添加对 Multidex 支持的依赖。作为你的 minSdkVersion 16 所以你必须添加依赖来启用 multidex.
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
试试这个代码
defaultConfig {
applicationId "com.test"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
//Multidex support for devices prior to lollipop
implementation 'com.android.support:multidex:1.0.1'
}
申请class
package appUtils;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.support.multidex.MultiDex;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) MultiDex.install(this);
}
}
在项目中build.gradle
allprojects {
repositories {
/**
* This must be at the top.
*/
maven {
url 'https://maven.google.com'
}
// Others
maven { url "..." }
jcenter()
mavenCentral()
google()
}
}
解析失败:multidex 打开文件
我在同步我的项目时发现了这个错误。
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion 16
targetSdkVersion rootProject.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
def system_dependencies = rootProject.ext.system_dependencies
compile system_dependencies.appcompat_v7
testCompile 'junit:junit:4.12'
}
我添加了这个,但是它不起作用;
maven {
url 'https://maven.google.com'
}
我试了很多ways.How解决了?
在 Android 5.0 之前添加对 Multidex 支持的依赖。作为你的 minSdkVersion 16 所以你必须添加依赖来启用 multidex.
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
试试这个代码
defaultConfig {
applicationId "com.test"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
//Multidex support for devices prior to lollipop
implementation 'com.android.support:multidex:1.0.1'
}
申请class
package appUtils;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.support.multidex.MultiDex;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) MultiDex.install(this);
}
}
在项目中build.gradle
allprojects {
repositories {
/**
* This must be at the top.
*/
maven {
url 'https://maven.google.com'
}
// Others
maven { url "..." }
jcenter()
mavenCentral()
google()
}
}