【发布时间】:2018-07-11 09:39:50
【问题描述】:
我最近不得不在我的 android studio 项目中启用 multidex,这是用导入的模块构建的。它在主项目中表现良好,但在使用导入(来自主项目)模块构建的项目中显示多索引问题。我已经按照this 文档启用了multidex。由于application 标签没有被覆盖,所以我遵循了相关的方法。现在我收到此错误:
任务“:app:transformClassesWithMultidexlistForDebug”执行失败。 java.io.IOException: Can't write [E:\something\SalesDemo >Updated\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't >read [E:\something\SalesDemo >更新\app\build\intermediates\classes\debug(;;;;;;**.class)](看不懂[com]>(看不懂[smth](看不懂[infolinkplus])看不懂
[some.class](重复的 zip 条目
[com/abc/def/some.class]))))))
这是我的build.gradle:
apply plugin: 'com.android.application'
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 25
// buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.abc.def.somethingotherthing"
multiDexEnabled true
minSdkVersion 16
//noinspection OldTargetApi
targetSdkVersion 22
versionCode 16
versionName "0.0.16"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//implementation 'com.android.support:multidex:1.0.3'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.3'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'joda-time:joda-time:2.3'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile project(':infolinkplus')
}
还有manifest 文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.abc.def.somethingotherthing">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
...
//ACTIVITIES AND META-TAGS
...
</application>
</manifest>
更改后,我运行干净的构建并重新构建,但没有结果。 我该如何克服这个问题?提前致谢。
【问题讨论】:
-
您是否从
MultiDexApplication扩展了您的Application类? -
添加你的android清单文件代码。
-
没有。我没有,并试图避免它。 @安东
-
如果您不想扩展 MultiDexApplication 并且您的项目中没有定义 Application 类,那么您可以使用 .
-
我做到了。 @Vishalsharma
标签: java android android-multidex