Could not find aapt2-proto-0.3.1.jar (com.android.tools.build:aapt2-proto:0.3.1)(红包🧧答谢)?

我在RN项目的android目录下执行了
./gradlew clean命令进行清理,但是报了如下的错误:

  • What went wrong:
    A problem occurred configuring project ':react-native-baidu-map'.
    Could not resolve all files for configuration ':react-native-baidu-map:classpath'.
    Could not find aapt2-proto-0.3.1.jar (com.android.tools.build:aapt2-proto:0.3.1).
 Searched in the following locations:
     https://maven.aliyun.com/repository/gradle-plugin/com/android/tools/build/aapt2-proto/0.3.1/aapt2-proto-0.3.1

我已经按照网上的解决办法把google()方法置顶了,但是依旧不行。
这是我的配置文件:

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'

buildscript {
    repositories {
        google()
        mavenLocal()
        mavenCentral()
        jcenter()
        maven() {
            allowInsecureProtocol true
            url 'http://repo.lovebing.net/repository/maven-public/'
        }
        maven() { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
    }
}

repositories {
    google()
    mavenLocal()
    mavenCentral()
    jcenter()
    maven {
        allowInsecureProtocol true
        url 'http://repo.lovebing.net/repository/maven-public/'
    }
     maven {
        url 'https://maven.aliyun.com/repository/gradle-plugin/'
    }
}

android {
    compileSdkVersion safeExtGet('compileSdkVersion', 28)
    buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')

    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 21)
        targetSdkVersion safeExtGet('targetSdkVersion', 28)
        versionCode 1
        versionName "${version}"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compileOnly 'com.facebook.react:react-native:0.62.2'
    implementation files('libs/BaiduLBS_Android.jar')
    compileOnly files('src/main/assets')
}

请问各位大神,还有什么别的解决办法吗?着急中...
如果您所提供的解决方案有效,我愿意奉上一个红包作为答谢。

阅读 3.7k
2 个回答

清理Gradle缓存再重新试试:

./gradlew cleanBuildCache
检查一下build.gradle文件中配置的仓库对不对:

repositories {
    google()
    jcenter()
    // 其他仓库...
}

实在不行的话手动下载aapt2-proto-0.3.1.jar,然后放到项目的libs目录下,然后在dependencies中添加implementation files('libs/aapt2-proto-0.3.1.jar')。看看

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏