【问题标题】:Android run error app:transformClassesWithDexForDebugAndroid运行报错app:transformClassesWithDexForDebug
【发布时间】:2017-12-19 19:20:38
【问题描述】:

嗨,我写了一个可以在我的手机(api 23,Android 6.0.1)上运行的应用程序,但是当我想在 Geneymotion(api 17 上的虚拟 android 设备)上启动应用程序时,会出现此错误

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: 多个dex文件定义Landroid/support /v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

我为那个 api 编写了应用程序,但我不知道为什么会这样

分级

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.3'
    defaultConfig {
        applicationId "app.mma.introsliderproject"

    minSdkVersion 16
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

repositories {
    maven { url "https://jitpack.io" }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.github.halysongoncalves:pugnotification:1.8.1'
    compile 'me.tatarka.support:jobscheduler:0.1.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:support-vector-drawable:24.2.1'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.victor:lib:1.0.4'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.sd6352051:NiftyDialogEffects:v1.0.2'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.github.flavienlaurent.discrollview:library:0.0.2@aar'
    compile 'com.github.alxrm:animated-clock-icon:1.0.2'
    compile 'com.google.firebase:firebase-crash:10.0.1'
    testCompile 'junit:junit:4.12'
}


apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • multiDexEnabled true
  • 我添加了该代码,但现在我遇到了另一个错误
  • 错误:任务 ':app:transformClassesWithJarMergingForDebug' 执行失败。 > com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android/support/v4/text/BidiFormatter.class

标签: android


【解决方案1】:

在您的应用程序级别app.gradle 添加以下内容

  1. dependencies

    compile 'com.android.support:multidex:1.0.2'
    
  2. defaultConfig

    multiDexEnabled true
    

如果你使用自己的Application类的话,改成如下,

  • 扩展 Application扩展 MultiDexApplication
  • 也添加这个。

    @Override
    protected void attachBaseContext(Context newBase) {
        MultiDex.install(newBase);
        super.attachBaseContext(newBase);
    }
    

如果您不使用任何自定义Application,请更改您的AndroidManifest.xml

<application
        android:name="android.support.multidex.MultiDexApplication"
        ... >

</application>

【讨论】:

    【解决方案2】:

    在你的应用 build.gradle 中添加这个

    configurations {
        compile.exclude group:'com.android.support', module: 'support-v4'
        compile.exclude group:'com.android.support', module: 'support-annotations'
    }
    

    【讨论】:

      猜你喜欢
      • 2017-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      • 2015-04-09
      • 2017-01-10
      • 1970-01-01
      相关资源
      最近更新 更多