首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >启用Multidex时出错

启用Multidex时出错
EN

Stack Overflow用户
提问于 2018-07-11 09:39:50
回答 3查看 936关注 0票数 0

我最近不得不在我的android工作室项目中启用multidex,这是用导入模块构建的。它在主要项目中做得很好,但在用导入(从主项目)模块构建的项目中显示了多重索引问题。我跟踪了文档以启用multidex。因为application标记没有被重写,所以我遵循了与方法相关的方法。现在我得到了这个错误:

任务':app:transformClassesWithMultidexlistForDebug'.执行失败java.io.IOException:不会写E:\something\SalesDemo >Updated\app\build\intermediates\multi-dex\debug\componentClasses.jar

这是我的build.gradle

代码语言:javascript
复制
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文件:

代码语言:javascript
复制
<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>

更改后,我运行干净的构建和重建,但没有结果。我怎样才能克服这个问题?提前谢谢。

EN

回答 3

Stack Overflow用户

发布于 2018-07-11 09:45:25

您必须更改您的Manifest以提供MultiDex

代码语言:javascript
复制
<?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>

或者,如果您有自定义Application类,则必须使用MultiDexApplication对其进行扩展。

代码语言:javascript
复制
public class MyApplication extends MultiDexApplication { ... }
票数 0
EN

Stack Overflow用户

发布于 2018-07-11 09:56:38

重复zip条目com/abc/def/ome.class

在您的项目中,必须有一个名为some.class的类,将其重命名为其他类。

票数 0
EN

Stack Overflow用户

发布于 2018-07-11 09:59:02

试试这个密码..。我希望你做了这件事。

代码语言:javascript
复制
        multiDexEnabled true
    compile 'com.android.support:multidex:1.0.1'

为应用程序级别创建类。

代码语言:javascript
复制
public class MyApplication extends MultiDexApplication {
@Override
public void onCreate() {
    super.onCreate();
}
}




        android:name="MyApplication" > // here define that class name that extends by MultiDexApplication
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51282126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档