Android-Gradle-无法解决依赖关系

时间:2019-12-03 12:50:14

标签: react-native android-studio gradle

我有一个React Native应用已经使用了很长时间了。今天早上,当我打开android studio时,我收到了更新扩展的提示(很遗憾,我并没有对此给予太多关注)。我现在无法同步gradle文件或构建应用程序或运行该应用程序。

尝试Sync Project with Gradle Files时出现以下错误:

enter image description here

自从应用程序昨天开始工作以来,我没有进行任何更改。这是我的主要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"
    }
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.2.0'

        classpath 'io.fabric.tools:gradle:1.25.4'

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

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"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}



wrapper {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}
subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "28.0.0"
            }
        }   
    }
    afterEvaluate {
        project -> if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
                buildToolsVersion '28.0.2'
            }
        }
    }
}

这是我的android/app/build.gradle

apply plugin: "com.android.application"
apply plugin: "io.fabric"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

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

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 3
        versionName "2.0.1"
        multiDexEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a"
        }
    }
    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
            }
        }
    }

    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]
            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
            }
        }
    }
    lintOptions {
         checkReleaseBuilds false
    }
}

dependencies {
    implementation project(':react-native-fs')
    implementation project(':rn-update-apk')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-sms-retriever')
    implementation project(':react-native-text-input-mask')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-firebase')
    implementation project(':react-native-gesture-handler')
    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 project(':react-native-svg')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-image-resizer')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:28.0.0"
    implementation "com.facebook.react:react-native:+"  // From node_modules

    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation "com.google.firebase:firebase-core:16.0.6"
    implementation "com.google.firebase:firebase-firestore:17.1.5"
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation "com.google.firebase:firebase-storage:16.1.0"
    implementation "com.google.firebase:firebase-messaging:17.3.4"
    implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.5'
    implementation 'com.google.firebase:firebase-analytics:16.0.6'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
        transitive = true
    }
    implementation "com.google.android.gms:play-services-auth:16.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'
}

apply plugin: 'com.google.gms.google-services'

这是我的package.json

{
  "name": "example",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "color": "^3.1.0",
    "firebase": "^5.8.5",
    "keymirror": "^0.1.1",
    "native-base": "^2.12.0",
    "react": "16.6.3",
    "react-native": "0.58.5",
    "react-native-firebase": "^5.3.1",
    "react-native-floating-labels": "^1.1.9",
    "react-native-fs": "^2.13.3",
    "react-native-gesture-handler": "^1.1.0",
    "react-native-image-picker": "^0.28.1",
    "react-native-image-resizer": "^1.0.1",
    "react-native-iphone-x-helper": "^1.2.0",
    "react-native-keyboard-aware-scroll-view": "^0.8.0",
    "react-native-keyboard-aware-scrollview": "^2.0.0",
    "react-native-maps": "^0.23.0",
    "react-native-material-textfield": "^0.12.0",
    "react-native-material-textinput": "^1.1.0",
    "react-native-md-textinput": "^2.0.4",
    "react-native-modal": "^9.0.0",
    "react-native-progress": "^3.5.0",
    "react-native-progress-circle": "^2.0.1",
    "react-native-responsive-screen": "^1.2.0",
    "react-native-sendgrid": "file:packages/react-native-sendgrid",
    "react-native-shadow": "^1.2.2",
    "react-native-sms-retriever": "^1.0.3",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^9.4.0",
    "react-native-swiper": "^1.5.14",
    "react-native-text-input-mask": "file:packages/react-native-text-input-mask",
    "react-native-textinput-effects": "^0.5.1",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "^3.0.9",
    "react-redux": "^6.0.0",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.10.0",
    "redux-saga": "^0.16.2",
    "reduxsauce": "^1.0.1",
    "rn-update-apk": "^3.2.5"
  },
  "devDependencies": {
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "24.1.0",
    "jest": "24.1.0",
    "metro-react-native-babel-preset": "0.52.0",
    "react-test-renderer": "16.6.3",
    "reactotron-react-native": "^2.2.0"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "./src/assets/fonts/"
    ]
  }
}

如前所述,自从应用程序昨天开始工作以来,我的gradle配置都没有改变。我唯一的猜测是android studio更新了一些东西

0 个答案:

没有答案