我在我的项目中安装了react-native-maps。然后,我在物理设备react-native run-android
中运行我的应用程序,然后出现此错误。但是在我的另一个也有react-native-map的项目中,它没有得到错误。我昨天刚刚创建了这个项目,我将react本机版本从0.57.3
降级到0.57.1
,并安装了babel / runtime和babel / core,因为其他一些错误无法解决。
这是我的错误:
任务:app:transformDexArchiveWithExternalLibsDexMergerForDebug失败 D8:程序类型已经存在:android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
失败:构建失败,并出现异常。
- 出了什么问题: 任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败。 com.android.builder.dexing.DexArchiveMergerException:合并dex存档时出错:D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 0.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 1.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 2.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 3.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 4.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 5.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 6.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 7.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 8.jar,D:\ rnprojects \ PracticeProject \ android \一种pp \ build \ intermediates \ transforms \ dexBuilder \ debug \ 9.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 10.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 11.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 12.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 13.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 14.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 15.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 16.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 17.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 18.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediate s \ transforms \ dexBuilder \ debug \ 19.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 20.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \中间体\ transforms \ dexBuilder \ debug \ 21.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 22.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \中间体\ transforms \ dexBuilder \ debug \ 23.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 24.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \中间体\ transforms \ dexBuilder \ debug \ 25.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 26.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \中间体\ transforms \ dexBuilder \ debug \ 27.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 28.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \中间体\变换\ dexBuil der \ debug \ 29.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 30.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 31.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 32.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 33.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 34.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 35.jar,D:\ rnprojects \ PracticeProject \ android \ app \ build \ intermediates \ transforms \ dexBuilder \ debug \ 36.jar
这是我的package.json
:
{
"name": "PracticeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.0",
"react": "16.5.0",
"react-native": "0.57.1",
"react-native-maps": "^0.22.0"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.48.1",
"react-test-renderer": "16.6.0-alpha.8af6728"
},
"jest": {
"preset": "react-native"
}
}
这是我的项目的build.gradle(app):
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.practiceproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// 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]
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 fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.android.support:animated-vector-drawable:27.1.1"
implementation "com.android.support:support-v4:24.0.0"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
此行implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
在红色行中,这意味着有问题,但是我不知道该怎么做,这就是为什么我在Stack Overflow上发布以获得帮助的原因。谢谢!