web-dev-qa-db-ja.com

Androidx MutLidex:.dexファイル内のメソッド参照の数は64Kを超えることはできません

移行アプリケーションから .57 => 0.59 サードパーティパッケージの問題を修正する必要があり、今度はDEX問題に直面しています。

build.gradle.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28

        // supportLibVersion = "28.0.0"
        // supportVersion = "28.0.0"
        // googlePlayServicesVersion = "15.0.1"
        // facebookSdkVersion = "4.37.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.Android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.3.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        maven { url 'https://maven.google.com' }
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/Android"
        }
    }
}
 _

app/build.gradle.

apply plugin: "com.Android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.Android.build.OutputFile

project.ext.react = [
    entryFile: "index.js",
        bundleAssetName: "index.Android.bundle",
        bundleInAlpha: true,
        bundleInBeta: true
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

def readVersion() {
  def versionFile = new File(project.rootDir, 'version.properties')
  def version = new Properties()
  def stream
  try {
    stream = new FileInputStream(versionFile)
    version.load(stream)
  } catch(FileNotFoundException ignore) {
  } finally {
    if(stream != null) stream.close()
  }
  if(!version['major']) version['major'] = "1"
  if(!version['minor']) version['minor'] = "0"
  if(!version['build']) version['build'] = "0"
  return version
}

def readVersionName(){
  def version = readVersion()
  return "${version['major']}.${version['minor']}"
}

def readBuildCode(){
  def version = readVersion()
  def build = version['build'] as int
  return build
}

def incrementBuildNumber(){
  def versionFile = new File(project.rootDir, 'version.properties')
  def version = readVersion()
  def build = version['build'] as int
  build++
  version['build'] = build.toString()

  def stream = new FileOutputStream(versionFile)
  try {
    version.store(stream, null)
  } finally {
    stream.close()
  }

  println " Build number is now..." + build
  return build
}

def incrementVersionNumber(def type="minor"){
  def versionFile = new File(project.rootDir, 'version.properties')
  def version = readVersion()
  def major = version['major'] as int
  def minor = version['minor'] as int

  if(type=='major'){
    major++
    minor = 0
  } else if (type == 'minor') {
    minor++
  }

  version['major'] = major.toString()
  version['minor'] = minor.toString()

  def stream = new FileOutputStream(versionFile)
  try {
    version.store(stream, null)
  } finally {
    stream.close()
  }

  println "Version is now..." + major + "." + minor
  return major + "." + minor

}

Android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.ironark.hubapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode readBuildCode()
        versionName readVersionName()
        ndk {
            abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
        resValue "string", "build_config_package", "com.ironark.hubapp"
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
      }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-Android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.Android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation project(':bugsnag-react-native')
    implementation project(':react-native-device-info')
    implementation project(':react-native-restart')
    implementation project(':react-native-screens')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-mixpanel')
    implementation project(':react-native-iap')
    implementation project(':react-native-fs')
    implementation project(':react-native-add-calendar-event')
    implementation project(':react-native-fast-image')
    implementation project(':react-native-print')
    implementation project(':react-native-html-to-pdf')
    implementation project(':react-native-calendar-events')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-picker')
    // https://github.com/facebook/react-native/issues/25293#issuecomment-503045776
    implementation(project(":react-native-device-info"),  {
        exclude group: "com.google.Android.gms"
    })
    implementation "com.google.Android.gms:play-services-base:17.0.0"
    implementation "com.google.Android.gms:play-services-gcm:17.0.0"
    implementation 'com.google.Android.gms:play-services-maps:17.0.0'
    compile project(':react-native-share')

    // Firebase dependencies
    // implementation project(':react-native-firebase')
    // implementation "com.google.firebase:firebase-core:17.0.1"
    // implementation "com.google.firebase:firebase-messaging:19.0.1"
    // implementation 'com.google.firebase:firebase-auth:18.1.0'
    // implementation 'com.google.firebase:firebase-crash:16.2.1
    // implementation "com.google.firebase:firebase-iid:19.0.1"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-contacts')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-config')
    implementation project(':react-native-i18n')
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    // This is from https://developer.Android.com/jetpack/androidx/migrate
    // This changes is needed for migration proces
     // implementation 'com.Android.support:design:28.0.0'
    implementation 'com.google.Android.material:material:1.0.0-rc01'
    // implementation 'com.Android.support:appcompat-v7:28.0.0'
    implementation 'com.facebook.react:react-native:0.59.10'
    // implementation 'com.Android.support:support-annotations:28.0.0'
    implementation "androidx.annotation:annotation:1.1.0"
    implementation 'androidx.core:core:1.0.1'
    implementation "androidx.multidex:multidex:2.0.0"

}
 _

フルスタックトレース:

> Task :app:transformDexArchiveWithDexMergerForDebug FAILED
Java.lang.RuntimeException: Java.lang.RuntimeException: com.Android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.Android.com/tools/building/multidex.html
        at Sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at Sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.Java:62)
        at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:45)
        at Java.lang.reflect.Constructor.newInstance(Constructor.Java:423)
        at Java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.Java:593)
        at Java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.Java:677)
        at Java.util.concurrent.ForkJoinTask.join(ForkJoinTask.Java:720)
        at com.google.common.collect.ImmutableList.forEach(ImmutableList.Java:407)
        at com.Android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.Java:244)
        at com.Android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.Java:239)
        at com.Android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.Java:235)
        at com.Android.builder.profile.ThreadRecorder.record(ThreadRecorder.Java:102)
        at com.Android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.Java:230)
        at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
        at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
        at Java.lang.reflect.Method.invoke(Method.Java:498)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.Java:103)
        at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.Java:46)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.Java:41)
        at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.Java:25)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.Java:28)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.Java:404)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.Java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.Java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.Java:393)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:376)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.Java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.Java:213)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.Java:32)
        at Java.util.Optional.map(Optional.Java:215)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.Java:32)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.Java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.Java:58)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.Java:35)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.Java:48)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.Java:33)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.Java:39)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.Java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.Java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.Java:35)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.Java:51)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.Java:45)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.Java:31)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.Java:201)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.Java:70)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.Java:45)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.Java:49)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.Java:43)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.Java:32)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.Java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.Java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.Java:96)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.Java:89)
        at Java.util.Optional.map(Optional.Java:215)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.Java:54)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.Java:38)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.Java:77)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.Java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.Java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.Java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.Java:90)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.Java:48)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.Java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.Java:120)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.Java:75)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.Java:62)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.Java:108)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.Java:67)
        at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.Java:46)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.Java:94)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.Java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.Java:95)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.Java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.Java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.Java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.Java:73)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.Java:52)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.Java:49)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.Java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.Java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.Java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.Java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.Java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.Java:49)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.Java:43)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.Java:355)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.Java:343)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.Java:336)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.Java:322)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.Java:134)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.Java:129)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.Java:202)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.Java:193)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.Java:129)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.Java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.Java:46)
        at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1142)
        at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:617)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.Java:55)
        at Java.lang.Thread.run(Thread.Java:745)
Caused by: Java.lang.RuntimeException: com.Android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.Android.com/tools/building/multidex.html
        at Java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.Java:1431)
        at Java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.Java:289)
        at Java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.Java:1056)
        at Java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.Java:1692)
        at Java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.Java:157)
Caused by: com.Android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.Android.com/tools/building/multidex.html
        at com.Android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.Java:131)
        at com.Android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.Java:118)
        at com.Android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.Java:102)
        at com.Android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.Java:37)
        at Java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.Java:1424)
        ... 4 more
Caused by: com.Android.tools.r8.CompilationFailedException: Compilation failed to complete
        at com.Android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.Java:81)
        at com.Android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.Java:45)
        at com.Android.tools.r8.D8.run(D8.Java:94)
        at com.Android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.Java:116)
        ... 7 more
Caused by: com.Android.tools.r8.utils.AbortException: Error: null, Cannot fit requested classes in a single dex file (# fields: 66857 > 65536)
        at com.Android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.Java:101)
        at com.Android.tools.r8.utils.Reporter.fatalError(Reporter.Java:72)
        at com.Android.tools.r8.dex.VirtualFile.throwIfFull(VirtualFile.Java:193)
        at com.Android.tools.r8.dex.VirtualFile$MonoDexDistributor.run(VirtualFile.Java:428)
        at com.Android.tools.r8.dex.ApplicationWriter.distribute(ApplicationWriter.Java:200)
        at com.Android.tools.r8.dex.ApplicationWriter.write(ApplicationWriter.Java:221)
        at com.Android.tools.r8.D8.run(D8.Java:215)
        at com.Android.tools.r8.D8.lambda$run$1(D8.Java:97)
        at com.Android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.Java:62)
        ... 10 more


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.Android.build.api.transform.TransformException: Java.lang.RuntimeException: Java.lang.RuntimeException: com.Android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
  The number of method references in a .dex file cannot exceed 64K.
  Learn how to resolve this issue at https://developer.Android.com/tools/building/multidex.html
 _

gradle.properties 私は持っている

Android.useAndroidX = true
Android.enableJetifier = true
 _

Docsから、AndroidXを使用していない場合は、 この が設定できますが、アプリを移行して追加しました

implementation "androidx.multidex:multidex:2.0.0" _

dEXをサポートするために、私はcleanを持っていて、プロジェクトを再構築することができますが、私はまだ同じエラーを持っています、誰かがこのエラーを克服するのを手伝ってくれることができます、ありがとう。

7
copser
Android {
    defaultConfig {
        ...
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        multiDexEnabled true // This added
    }
    ...
}

dependencies {
  implementation 'com.Android.support:multidex:1.0.3' // This added
}
 _

これは卒業の後に私のために働いています

アプリケーションを実行する前に常に卒業クリーンを実行してください。

0
nipunravisara