我已经设置了MultiDex,但似乎没有处理我的情况,我可能会缺少什么?在某个应用上有相同的设置,在那里工作。
此外,我正在使用新的Android Studio 3.0 Canary 1,如果这可能有效。
清单
<application
android:name=".Global"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
摇篮
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
useLibrary 'org.apache.http.legacy'
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'
})
...
compile 'com.android.support:multidex:1.0.1'
}
申请类别
public class Global extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
}
}
错误
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzbrq;
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzbrq;
Error: at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:608)
Error: at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:563)
Error: at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:545)
Error: at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
Error: at com.android.dx.merge.DexMerger.merge(DexMerger.java:194)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.mergeDexes(DexArchiveMergerCallable.java:66)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:54)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:37)
Error: at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error: at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error: at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error: at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error: at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzbrq;
答案 0 :(得分:2)
试试这个
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
MultiDex.install(本);此行从创建
中删除答案 1 :(得分:0)
status,weather,longitude,latitude,timestamp
ok,rainy,10.12,17.45,14569003
ok,sunny,11.34,16.78,14569000
答案 2 :(得分:0)
创建一个类
public class Multi_Dex extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}}
导入此库
compile 'com.android.support:multidex:1.0.1'
在你的gradle中设置multltidexenavbled为true
defaultConfig {
multiDexEnabled true
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
即时通讯最明确的文件定义您的应用程序名称属性如此
android:name="com.pkg.Multi_Dex"
答案 3 :(得分:0)
gradle文件.. official link
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
你的活动中的chnage。
public class YouApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}