任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'Android

时间:2019-06-24 18:01:40

标签: android react-native android-gradle react-native-android android-build

我已经开发了Android应用程序。我在线查看并尝试了所有方法,但Gradle Build仍然存在问题,但由于以下错误而失败。

在项目结构中 摇篮版本-4.8 Android插件版本-3.1.3

请注意,这是一个React Native项目

关于如何解决此问题的任何建议将非常有帮助。

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
    at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:97)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$ExecuteTaskAction.execute(DefaultTaskExecutionGraph.java:262)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$ExecuteTaskAction.execute(DefaultTaskExecutionGraph.java:246)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:136)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.execute(DefaultTaskPlanExecutor.java:201)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.executeWithTask(DefaultTaskPlanExecutor.java:192)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: Error while generating the main dex list.
    at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
    at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:97)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
    ... 30 more
Caused by: com.android.build.api.transform.TransformException: Error while generating the main dex list.
    at com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:127)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
    at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
    at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    ... 43 more
Caused by: com.android.builder.multidex.D8MainDexList$MainDexListException: com.android.tools.r8.errors.CompilationError: Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
    at com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:87)
    at com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:114)
    ... 46 more
Caused by: com.android.tools.r8.errors.CompilationError: Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
    at com.android.tools.r8.utils.ProgramClassCollection.resolveClassConflictImpl(ProgramClassCollection.java:64)
    at com.android.tools.r8.utils.ProgramClassCollection.lambda$create$0(ProgramClassCollection.java:25)
    at com.android.tools.r8.utils.ProgramClassCollection.create(ProgramClassCollection.java:24)
    at com.android.tools.r8.graph.LazyLoadedDexApplication$Builder.build(LazyLoadedDexApplication.java:121)
    at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:122)
    at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:86)
    at com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:40)
    at com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:110)
    at com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:83)
    ... 47 more


* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 29s
198 actionable tasks: 184 executed, 14 up-to-date

build.gradle

   buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

ext {
    compileSdkVersion = 28
    buildToolsVersion = "27.0.3"
    minSdkVersion = 18
    targetSdkVersion = 27    
}

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

依赖项

    dependencies {
    compile project(':react-native-vector-icons')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:27.0.0"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-localization')
    compile project(':realm')
    compile project(':react-native-keychain')
    compile project(':react-native-device-info')
    compile project(':react-native-sensitive-info')
    compile project(':react-native-fs')
    //compile project(':react-native-secure-key-store')
}

gradle.properties

android.useDeprecatedNdk=true
android.enableAapt2=true
android.enableJetifier=true
android.useAndroidX=true
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=xxxx
MYAPP_RELEASE_KEY_PASSWORD=xxx

反应本机-package.json依赖项

  "dependencies": {
"create-react-class": "^15.6.3",
"crypto-js": "^3.1.9-1",
"hex-to-binary": "^1.0.1",
"moment": "^2.22.2",
"react": "^16.4.1",
"react-native": "~0.55.4",
"react-native-build-config": "github:ismaeldcom/react-native-build-config",
"react-native-device-info": "^2.1.3",
"react-native-floating-labels": "^1.1.9",
"react-native-fs": "^2.12.1",
"react-native-keychain": "^3.1.3",
"react-native-localization": "^2.1.2",
"react-native-looped-carousel": "^0.1.13",
"react-native-material-kit": "^0.5.1",
"react-native-phone-call": "^1.0.8",
"react-native-pin-view": "^2.1.0",
"react-native-responsive-screen": "^1.2.2",
"react-native-sensitive-info": "^5.2.6",
"react-native-vector-icons": "6.5.0",
"react-navigation": "^2.1.0",
"realm": "3.0.0",
"utf8": "^3.0.0"

}

将react-native-device-info的版本号更改为2.1.2后,出现以下错误

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-build-config
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-material-kit
WARNING: The following project options are deprecated and have been removed:
com.android.build.threadPoolSize
The com.android.build.threadPoolSize property has no effect


WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.3) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.3.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :realm
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.3.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Task :react-native-device-info:compileDebugJavaWithJavac
Note: C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules\react-native-device-info\android\src\main\java\com\learnium\RNDeviceInfo\RNDeviceModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-fs:compileDebugJavaWithJavac
Note: C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules\react-native-fs\android\src\main\java\com\rnfs\RNFSManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-keychain:compileDebugJavaWithJavac
Note: C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\DeviceAvailability.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-localization:compileDebugJavaWithJavac
Note: C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules\react-native-localization\android\src\main\java\com\babisoft\ReactNativeLocalization\ReactNativeLocalization.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :realm:forwardDebugPort
* daemon not running; starting now at tcp:5037
* daemon started successfully
error: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
===========================================================================
WARNING: Failed to automatically forward port 8083.
In order to use Realm in Chrome debugging mode, port 8083 must be forwarded
from localhost to the device or emulator being used to run the application.
You may need to add the appropriate flags to the command that failed:
    adb forward tcp:8083 tcp:8083
===========================================================================


> Task :realm:compileDebugJavaWithJavac
Note: C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules\realm\android\src\main\java\io\realm\react\RealmReactModule.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :app:bundleReleaseJsAndAssets
Scanning folders for symlinks in C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules (63ms)
Scanning folders for symlinks in C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules (51ms)
Loading dependency graph, done.
warning: the transform cache was reset.
bundle: Writing bundle output to: C:\Development\Dopay-Retail-ReactNative\retail-native-app\android\app\build\intermediates\assets\release\index.android.bundle
bundle: Done writing bundle output
bundle: Copying 26 asset files
bundle: Done copying assets

> Task :react-native-device-info:compileReleaseJavaWithJavac
Note: C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules\react-native-device-info\android\src\main\java\com\learnium\RNDeviceInfo\RNDeviceModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-fs:compileReleaseJavaWithJavac
Note: C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules\react-native-fs\android\src\main\java\com\rnfs\RNFSManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-keychain:compileReleaseJavaWithJavac
Note: C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\DeviceAvailability.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-sensitive-info:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Warning: The rule `-keep public class *extends java.lang.annotation.Annotation {
  *;
}` uses extends but actually matches implements.
C:\Development\Dopay-Retail-ReactNative\retail-native-app\android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigation_src_views_assets_backicon.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.

> Task :app:processReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to process resources, see aapt output above for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 19s

更改后提示这是错误日志

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-build-config
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-material-kit
WARNING: The following project options are deprecated and have been removed:
com.android.build.threadPoolSize
The com.android.build.threadPoolSize property has no effect


WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.3) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.3.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :realm
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.3.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Task :app:bundleReleaseJsAndAssets
Scanning folders for symlinks in C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules (47ms)
Scanning folders for symlinks in C:\Development\Dopay-Retail-ReactNative\retail-native-app\node_modules (57ms)
Loading dependency graph, done.
warning: the transform cache was reset.
bundle: Writing bundle output to: C:\Development\Dopay-Retail-ReactNative\retail-native-app\android\app\build\intermediates\assets\release\index.android.bundle
bundle: Done writing bundle output
bundle: Copying 26 asset files
bundle: Done copying assets
C:\Development\Dopay-Retail-ReactNative\retail-native-app\android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigation_src_views_assets_backicon.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.

> Task :app:processReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to process resources, see aapt output above for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 6s

1 个答案:

答案 0 :(得分:0)

问题与您使用的react-native-device-info版本有关。

首先取消链接并卸载当前版本的react-native-device-info,然后

只需在终端中运行此命令:

npm install react-native-device-info@2.1.2

然后运行react-native link react-native-device-info

更多信息:检出该线程

https://github.com/facebook/react-native/issues/25294