Java 启用多索引时出错
我最近不得不在我的android studio项目中启用multidex,这是用导入的模块构建的。它在主项目中表现良好,但在使用导入(来自主项目)模块构建的项目中显示了多索引问题。我已经按照文档启用了multidex。由于Java 启用多索引时出错,java,android,android-multidex,Java,Android,Android Multidex,我最近不得不在我的android studio项目中启用multidex,这是用导入的模块构建的。它在主项目中表现良好,但在使用导入(来自主项目)模块构建的项目中显示了多索引问题。我已经按照文档启用了multidex。由于应用程序标记未被覆盖,因此我遵循了相关的方法。现在我得到了这个错误: 任务“:app:transformClassesWithMultidexlistForDebug”的执行失败。 java.io.IOException:无法写入[E:\something\SalesDemo>
应用程序
标记未被覆盖,因此我遵循了相关的方法。现在我得到了这个错误:
任务“:app:transformClassesWithMultidexlistForDebug”的执行失败。
java.io.IOException:无法写入[E:\something\SalesDemo>Updated\app\build\mediates\multi-dex\debug\componentClasses.jar](无法>读取[E:\something\SalesDemo>Updated\app\build\mediates\classes\debug(;;;;**.class)](无法读取[com]>(无法读取[smth](无法读取[infolinkplus](无法读取[some.class](重复的zip条目
[com/abc/def/some.class]()()())())())) 这是我的
构建。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 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>
...
//活动和元标记
...
更改后,我运行了干净的构建和重建,但没有结果。
我怎样才能克服这个问题?提前感谢。您必须更改
清单
以提供多索引
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
重复的邮政编码条目
[com/abc/def/some.class]
在您的项目中,必须有一个名为some.class的类将其重命名为其他名称请尝试以下代码。。。
我希望你做了这件事
multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'
为应用程序级别创建类
public class MyApplication extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
}
}
android:name="MyApplication" > // here define that class name that extends by MultiDexApplication
您是否从
多索引应用程序
扩展了应用程序
类?添加您的android清单文件code.No。我没有这样做,并试图避免它@如果您不想扩展MultiDexApplication,并且项目中没有定义应用程序类,那么可以使用。是的@维沙尔·沙马迪已经把它弄坏了。添加了有问题的清单文件。请检查。`//这里定义通过MultiDexApplication扩展的类名`-您的意思是什么?如果您按照代码进入定义行,然后在应用程序标记中定义您的包名和通过MultiDexApplication扩展的类名。我仍然无法理解您所说的。请解释你的答案。请注意,我没有扩展MultiDexApplication的类。如果扩展MultiDexApplication
中的扩展MultiDexApplication
显示为红色,该怎么办?我定义此MyApplication扩展MultiDexApplication
public class MyApplication extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
}
}
android:name="MyApplication" > // here define that class name that extends by MultiDexApplication