Не удалось найти aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1)

Я использую Android Studio для работы с проектом томагавк-андроид, поэтому я клонировал проект, используя git, прямо в Android Studio, где он не может быть собран, говоря:

Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
Searched in the following locations:
    https://jcenter.bintray.com/com/android/tools/build/aapt2-proto/0.3.1/aapt2-proto-0.3.1.jar

build.gradle:

apply plugin: "com.android.application"

android {
    implementationSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        renderscriptTargetApi 20
        renderscriptSupportModeEnabled true
        def name = readVersionName()
        def parts = name.split("[\\._-]")
        def code = parts[0] + parts[1]
        code = String.format("%-5s", code.substring(0, Math.min(5, code.size()))).replace(' ', '0')
        code = Integer.parseInt(code)
        versionName name
        versionCode code
        println("Using version name: $name")
        println("Using version code: $code")
    }

    lintOptions {
        abortOnError false
    }

    dexOptions {
        jumboMode true
        javaMaxHeapSize "2g"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/ASL2.0'
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('.apk')) {
                def fileName = outputFile.name.
                        replace(".apk", "-" + defaultConfig.versionName + ".apk")
                output.outputFile = new File(outputFile.parent, fileName)
            }
        }
    }

    signingConfigs {
        release
    }

    buildTypes {
        release {
            zipAlignEnabled true
            minifyEnabled true
            proguardFiles "../proguard-android.txt"
        }
        debug {
            versionNameSuffix "_debug"
            zipAlignEnabled true
        }
    }

    splits {
        abi {
            enable true
            reset()
            include 'armeabi-v7a', 'arm64-v8a', 'mips', 'x86', 'x86_64'
            universalApk true
        }
    }
}

// map for the version code
ext.versionCodes = ['armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 4, 'x86': 6, 'x86_64': 7]

android.applicationVariants.all { variant ->
    // assign different version code for each output
    variant.outputs.each { output ->
        output.versionCodeOverride =
                project.ext.versionCodes.
                        get(output.getFilter(com.android.build.OutputFile.ABI), 9) * 100000 +
                        android.defaultConfig.versionCode
        println("Using version name: $output.versionCodeOverride")
    }
    // assign different version name for each output
    variant.outputs.each { output ->
        def suffix = "_universal"
        if (output.getFilter(com.android.build.OutputFile.ABI) != null) {
            suffix = "_" + output.getFilter(com.android.build.OutputFile.ABI)
        }
        output.versionNameOverride = android.defaultConfig.versionName + suffix
    }
}

def Properties props = new Properties()
def propFile = file('signing.properties')
if (propFile.canRead()) {
    props.load(new FileInputStream(propFile))

    if (props != null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
            props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
        android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
        android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
        android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
        android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
        android.buildTypes.release.signingConfig = android.signingConfigs.release
        android.buildTypes.debug.signingConfig = android.signingConfigs.release
    }
}

buildscript {
    repositories {
        google() // here
        jcenter()
    }
    dependencies {
        implementation group: 'com.android.tools.build', name: 'aapt2-proto', version: '0.1.0'
        classpath 'com.android.tools.build:gradle:3.2.0'

        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation (name: 'circularprogressview-debug', ext: 'aar')
        implementation 'com.android.support:appcompat-v7:24.1.1'
        implementation 'com.android.support:support-v4:24.1.1'
        implementation 'se.emilsjolander:stickylistheaders:2.7.0'
        implementation('ch.acra:acra:4.7.0') {
            transitive = false
        }
        implementation 'com.google.code.gson:gson:2.5'
        implementation 'com.google.android.gms:play-services-base:8.4.0'
        implementation('com.stanfy:gson-xml-java:0.1.7') {
            exclude group: 'xmlpull', module: 'xmlpull'
        }
        implementation 'com.squareup.picasso:picasso:2.5.2'
        implementation 'com.squareup.okhttp:okhttp:2.7.2'
        implementation 'com.squareup.okhttp:okhttp-urlconnection:2.7.2'
        implementation 'com.squareup.okhttp:logging-interceptor:2.7.2'
        implementation 'com.github.castorflex.smoothprogressbar:library:1.1.0'
        implementation 'de.mrmaffen:vlc-android-sdk:1.9.8'
        implementation 'org.apache.lucene:lucene-core:4.7.2'
        implementation 'org.apache.lucene:lucene-analyzers-common:4.7.2'
        implementation 'org.apache.lucene:lucene-queryparser:4.7.2'
        implementation 'commons-io:commons-io:2.4'
        implementation 'net.sourceforge.findbugs:jsr305:1.3.7'
        implementation 'com.squareup.retrofit:retrofit:1.9.0'
        implementation 'com.sothree.slidinguppanel:library:3.2.1'
        implementation 'com.uservoice:uservoice-android-sdk:1.2.4'
        implementation 'de.greenrobot:eventbus:2.4.1'
        implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
        implementation 'org.jdeferred:jdeferred-android-aar:1.2.4'
        implementation 'org.slf4j:slf4j-android:1.7.13'
    }
}
allprojects {
    repositories {
        google() // and here
        jcenter()
    }
}

gradlew -v вывод:

------------------------------------------------------------
Gradle 4.6
------------------------------------------------------------

Build time:   2018-02-28 13:36:36 UTC
Revision:     8fa6ce7945b640e6168488e4417f9bb96e4ab46c

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM:          1.8.0_172 (Oracle Corporation 25.172-b11)
OS:           Windows 10 10.0 amd64

Спасибо!!

Может это поможет: stackoverflow.com/a/52944600/4255978

HedeH 24.10.2018 14:21
2
1
1 548
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

Спасибо @HedeH, который связал меня со своим ответом здесь, сказав:

Try moving the google() method (In all .gradle files) to the top of its execution block.

Я видел этот ответ раньше, когда искал проблему, но пропустил, что его нужно изменить "Во всех файлах .gradle".

Ответ принят как подходящий

Это связано с тем, что вы не поместили google() в качестве репозитория первый. Порядок google() имеет значение. Так что просто добавьте его вышеjcenter() решит вашу проблему.

См. https://stackoverflow.com/a/51151050/8034839

Обратите внимание, что это изменение должно быть в вашем файле build.gradle уровня ТОП. Например.

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

buildscript {

    repositories {
        google() // first one
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'


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

allprojects {
    repositories {
        google() // first one
        jcenter()
    }
}

Примечание:

Начиная с Android Gradle Plugin (AGP) версии 3.0.0 (Gradle версии 4.1+), Google представила собственный Репозиторий Google Mavengoogle(), большая часть зависимостей перенесена туда. Итак, если вы используете AGP 3.0+, вам следует сначала обратиться к этому репозиторию НОВЫЙ.

И вот некоторые объяснения о разных версиях Gradle: Что такое настоящая версия Android Studio Gradle?

Другие вопросы по теме