【问题标题】:React Native: Error while building projectReact Native:构建项目时出错
【发布时间】:2018-05-14 06:32:32
【问题描述】:

最初,一切正常,我正在尝试更新 build:gradle 和 SDK 版本

我在构建项目时得到以下信息

Gradle sync failed: More than one variant of project :react-native-fetch-blob matches the consumer attributes:
            - Configuration ':react-native-fetch-blob:debugApiElements' variant android-aidl:
            - Found artifactType 'android-aidl' but wasn't required.
            - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
            - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
            - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
            - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
            - Configuration ':react-native-fetch-blob:debugApiElements' variant android-classes:
            - Found artifactType 'android-classes' but wasn't required.
            - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
            - Found com.android.build.api.attributes.VariantAttr 'debug' but wa... (show balloon)

下面是 react-native-fetch-blob 的 build.gradlew 文件

apply plugin: 'com.android.library'

repositories {
    mavenCentral()
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile 'com.facebook.react:react-native:+'
    //{RNFetchBlob_PRE_0.28_DEPDENDENCY}
}

我不知道发生了什么

期待大家的帮助

谢谢

【问题讨论】:

  • 您的google-services 版本是什么?
  • 嘿@MRFrhn 谢谢你的回复,classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.google.gms:google-services:3.3.0'
  • 我已将主build.gradlew 文件中的com.android.tools.build:gradle:3.1.2 更改为2.3.3,现在我没有收到该错误,但是如何将build.gradlew 升级到新版本而不会出现任何错误
  • 保留 gradle 版本,将 google-services 更改为 classpath 'com.google.gms:google-services:3.2.1' 并重试。 3.3.0版本好像有问题
  • 谢谢!效果很好。我可以使用play-services:15.0.1吗?目前我使用的是 11.8.0。

标签: android react-native mobile react-native-fetch-blob


【解决方案1】:

google-services 3.3.0 似乎存在问题

将其更改为classpath 'com.google.gms:google-services:3.2.1',它应该可以正常工作。

【讨论】:

  • 好的,现在我收到了这个错误,Gradle sync failed: Could not find com.android.tools.build:gradle:3.1.2. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.jar Required by: project :react-native-fetch-blob Consult IDE log for more details (Help | Show Log) (20s 292ms)
  • 将 gradle 更改为 3.2.1
  • 如果使用 com.android.tools.build:gradle:2.3.3 一切正常
猜你喜欢
  • 2021-04-13
  • 1970-01-01
  • 2018-08-28
  • 1970-01-01
  • 2022-06-22
  • 2022-08-03
  • 2016-12-29
  • 1970-01-01
  • 2020-09-25
相关资源
最近更新 更多