错误:无法解决:com.android.support:appcompat-v7:28.0.0

时间:2019-04-02 18:53:13

标签: android react-native

我不知道为什么Android会继续对我这样做。当我将gradle类路径更改为3.3.2时,我遇到了以下问题: classpath 'com.android.tools.build:gradle:3.2.1'

如果将其更改为3.2.1,则会出现此错误: classpath 'com.android.tools.build:gradle:3.2.1'

我竭尽所能,一切都可以帮助我吗?

这是我的项目build.gradle

buildscript {
ext {
    buildToolsVersion = "28.0.2"
    minSdkVersion = 21
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
    repositories {
        google()
        jcenter()
//      mavenLocal()
//      mavenCentral()

        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.10.1'
    distributionUrl = distributionUrl.replace("bin", "all")
}

这是我的应用程序build.gradle

apply plugin: "com.android.application"
import com.android.build.OutputFile

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

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

    defaultConfig {
        applicationId "com.newproject2"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  
            include "armeabi-v7a", "x86", "arm64-v8a"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {
                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.facebook.react:react-native:+"  
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

我已经尝试了本机版本0.59、0.58和0.57,并且我确定这是gradle的问题

2 个答案:

答案 0 :(得分:1)

将此添加到您的buidl.gradle(项目)

allprojects {
repositories {
...
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
...
}

}

docs中  它指出如果您使用的gradle版本低于4.1,则必须将其添加到build.gradle文件中

答案 1 :(得分:0)

尝试使“文件->使缓存无效/重新启动”上的缓存无效