Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
任务的Android Studio 3.0执行失败:无法合并索引_Android_Android Studio 3.0_Build Error - Fatal编程技术网

任务的Android Studio 3.0执行失败:无法合并索引

任务的Android Studio 3.0执行失败:无法合并索引,android,android-studio-3.0,build-error,Android,Android Studio 3.0,Build Error,android studio在生成执行时出现生成错误,如下所示: 错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”的执行失败。java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex“ 我的应用程序:build.gradle文件: apply pl

android studio在生成执行时出现生成错误,如下所示:

错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”的执行失败。java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex“

我的应用程序:build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.pdroid.foodieschoice"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        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.constraint:constraint-layout:1.0.2'
    compile 'com.firebaseui:firebase-ui-auth:2.3.0'

    testCompile 'junit:junit:4.12'
}
configurations.all {
    resolutionStrategy {
        force 'com.android.support:appcompat-v7:26.0.1'
        force 'com.android.support:support-compat:26.0.1'
        force 'com.android.support:support-core-ui:26.0.1'
        force 'com.android.support:support-annotations:26.0.1'
        force 'com.android.support:recyclerview-v7:26.0.1'
    }
}

apply plugin: 'com.google.gms.google-services'
有什么解决办法吗


编辑:我已经通过firebase github网站完成了示例,并解决了尝试在gradle中添加此问题

    android {
      defaultConfig {
        multiDexEnabled true
        }
   }

只要试着做一个“构建->清理项目”。这就解决了我的问题。

你是在SDK更新还是平台更新之间? 如果是,请完全完成这些,然后尝试继续。
我通常会更新需要更新的单个软件包,以进行整个更新,有时可能会高达2.5 GB。完成此完整更新有时会失败。升级到Android Studio 3.0后,我进行了大量SDK更新,但由于所有软件包都未更新,所以出现上述错误。更新所有软件包后,我会更新所有软件包上述错误已经消失了。

< P>同样的事情发生在我身上,我发现我正处于更新的过程中,当我做了更新,清理和重建应用程序时,一切都被修复了。

< P>我把FixBaseBASE版本从2.62.0改为2.4.2,修正了问题< /P> < P>,问题是java 1.8在模块中的使用,但不在应用程序模块中。我将此添加到应用程序构建gradle中并进行了以下操作:

android{
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
对我来说,补充说

multiDexEnabled true


在应用程序级别的Build.gradle文件中解决了相同的问题。我已启用multidex: 默认配置{ 应用程序ID“xxx.xxx.xxxx” 明斯克版本24 targetSdkVersion 26 多索引启用真

我已清除缓存,运行gradle clean、rebuild、make,尝试确保导入的库中没有冲突(删除了所有可传递的依赖项),并进行了所有更新。仍然:

错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”的执行失败。 java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

结果显示构建不喜欢:
实现'org.slf4j:slf4j android:1.7.21'

当android Studio的版本为3.0.1,Gradle版本为4.1,android插件倒置为3.0.0时,它会遇到这个问题。然后我将Gradle版本降级为3.3,android版本为零,没有这样的问题。

当您添加外部库时会发生此错误ich可能与您的
编译器DKversion
不兼容

添加
外部库时要小心

我花了两天的时间解决这个问题,最后按照这些步骤解决了

  • 确保所有支持库都与
    build.gradle(模块:app)
    compileSdkVersion
    相同,在我的例子中,它是
    26

  • 在defaultConfig类别中,键入multiDexEnabled true。这是重要的部分

  • 转到文件|设置|生成、执行、部署|即时运行并尝试启用/禁用即时运行以进行热交换…然后单击确定

  • 同步
    您的项目

  • 最后,转到构建|单击重建项目

  • 注意:重建项目首先清理然后生成项目


当请求的SDK版本与依赖项不匹配时,我有此问题。您可以单击突出显示的行,然后单击红色灯泡修复此问题。无需查找实际版本,只需让IDE为您解决。然后将google repo添加到maven配置中。

我收到了相同的错误,在我的情况下,当我修复了一个生成错误,该错误与当前生成的版本不同的版本关联

我正在构建构建变体,我正在查看,没有任何错误,但是尝试调试导致了
app:transformDexArchiveWithExternalLibsDexMergerForDebug
错误。一旦切换到构建另一个构建变体,我在构建过程中发现了错误并修复了它。这似乎解决了我的
app:transformDexArchiveWi所有构建变体的XternalibsDexmergerForDebug
问题


请注意,此错误不在引用的外部模块内,而是在引用外部模块的构建变量的不同源集中。希望这对可能看到与我相同情况的人有所帮助!

对于我来说,是什么修复了此错误,改变了我应用程序的gradle依赖项中的一行

由此

compile('com.google.android.gms:play-services-gcm:+') {
    force = true
}
compile('com.google.android.gms:play-services-gcm:11.8.0') {
    force = true
}
 android {
     defaultConfig {
         ...
         minSdkVersion 15 
         targetSdkVersion 26
         multiDexEnabled true
     }
     ... }

 dependencies {   compile 'com.android.support:multidex:1.0.3' }
对此

compile('com.google.android.gms:play-services-gcm:+') {
    force = true
}
compile('com.google.android.gms:play-services-gcm:11.8.0') {
    force = true
}
 android {
     defaultConfig {
         ...
         minSdkVersion 15 
         targetSdkVersion 26
         multiDexEnabled true
     }
     ... }

 dependencies {   compile 'com.android.support:multidex:1.0.3' }

我已经完成并修复了这个问题,只是在我的代码中做了这些工作

打开->build.gradle 更改值 从


要消除这个Dex问题,只需实现一个依赖项。 当我们使用来自同一服务器的多个不同服务时会出现此问题。假设我们在一个项目中使用ads和Firestore,并且两者都有一个repository maven。因此,我们需要在repository上调用不同的数据,我们需要实现dex依赖关系。 新的更新依赖项:-

 implementation 'com.android.support:multidex:1.0.3'

我相信它将永久解决您的问题

对于基于Cordova的项目,请按照建议在重新构建之前运行
Cordova clean android

1)Please add multiDexEnabled true 2)if you get compilation error then check your app level build.gradle weather same dependencies are implemented with different versions. 3)Remove one if you find same dependencies. 希望它能正常工作:)编码快乐
还要确保你的应用程序是多索引应用程序的子类

import android.support.multidex.MultiDexApplication

class App : MultiDexApplication()
如果不是应用程序类的子类,则添加到AndroidManifest.xml

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

使用multiDexEnabled true,如下所示

{
 minSdkVersion 17
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}


这个解决方案对我很有效。

避免此类错误的最简单方法是:

-将库combilesdkversion更改为与应用程序compilesdkversion相同的版本

-将库的supportLibrary版本更改为与build.gradle(应用程序)相同的版本<
{
 minSdkVersion 17
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
implementation 'com.android.support:multidex:1.0.3'
 android {
     defaultConfig {
         ...
         minSdkVersion 15 
         targetSdkVersion 26
         multiDexEnabled true
     }
     ... }

 dependencies {   compile 'com.android.support:multidex:1.0.3' }
  android {
      defaultConfig {
          ...
          minSdkVersion 21 
          targetSdkVersion 26
          multiDexEnabled true
      }
      ... }
     dependencies {
        implementation 'com.android.support:multidex:1.0.3'
     }
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support' && requested.name != 'multidex') {
            details.useVersion "${rootProject.ext.supportLibVersion}"
        }
    }
}
cordova clean android;
ionic cordova prepare andriod;
ionic cordova run andriod;
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 28
        multiDexEnabled true
    }
    ...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}
android.enableD8=false