gpt4 book ai didi

android - React Native Camera 导致 gradle 构建错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:35:00 25 4
gpt4 key购买 nike

我在 Android 上遇到 react-native-camera 问题。它在大约一个星期内工作正常,突然间,Gradle 无法构建并出现以下错误:

Error:Execution failed for task ':react-native-camera:processReleaseResources'.
> Error: more than one library with package name 'com.google.android.gms.license'

据我所知,这是由不止一次加载 com.google.android.gms 引起的。我遵循了 RNCamera 文档并确保我的 Gradle 文件匹配。

android/app/build.gradle:

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.phase1"
minSdkVersion 16
targetSdkVersion 22
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 {
compile (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
compile 'com.android.support:exifinterface:27.+'
}
//compile project(':react-native-camera')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}

android/settings.gradle:

rootProject.name = 'Phase1'
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':app'

android/build.gradle:

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

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'

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

allprojects {
repositories {
mavenLocal()
jcenter()

maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}

这是外部库中的所有 com.google.android.gms 条目,我没有看到任何重复项并尝试了此处的所有答案 Gradle: Error: more than one library with package name 'com.google.android.gms'

external libs

我试过删除 com.android.support:appcompat-v7 版本,创建一个新项目,卸载并重新安装 Android SDK 构建工具(23.0.1、25.0.2、26.0.1、26.0.2、27.0. 3) & Android Support Repository 已经用完了。我正在使用 Android Studio 3.0.1,gradle-2.14.1

一旦我从 Gradle 文件中删除相机引用,项目就会正常构建并按预期工作。所以我现在真的很迷茫。任何建议将不胜感激。

最佳答案

这是因为谷歌服务版本更新(12.0.0)。您应该通过编辑 android/build.gradle 文件将其指向 11.8.0:

def googlePlayServicesVersion = '11.8.0'

allprojects {
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (requested.group == 'com.google.android.gms') {
details.useVersion "$googlePlayServicesVersion"
}
if (requested.group == 'com.google.firebase') {
details.useVersion "$googlePlayServicesVersion"
}
}
}
}
}

关于android - React Native Camera 导致 gradle 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49418193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com