Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find aapt2-proto.jar

See this link (as I suspected) has the POM file and no jar.

Important Notes:

  • I am using latest version of react native ... v0.57.3 and also latest version of react-native-cli ... v2.0.1 at this time.
  • I have Java 11 installed in my computer.
  • I am using latest gradle release at this time ... v4.10.2
  • I am using Mac OSX Mojave

The distribution url is:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

Here is the error

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'AwesomePlacesApp'.
> Could not resolve all artifacts for configuration ':classpath'.
   > 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
like image 714
Harry Avatar asked Oct 23 '18 08:10

Harry


3 Answers

It seems like AAPT2(Android Asset Packaging Tool 2) is available in Google's maven repository.

You need to include google() under repositories in build.gradle file as shown:

buildscript {
  repositories {
      google() // here
      jcenter()
  }
  dependencies {
      classpath 'com.android.tools.build:gradle:3.2.0-alpha12'
  }
} 
allprojects {
  repositories {
      google() // and here
      jcenter()
}

Take a look at this link for more in detail.

Note: Order also matters, if jcenter() is above google() it fails.

like image 153
Kosalram Rama Krishnan Avatar answered Oct 18 '22 17:10

Kosalram Rama Krishnan


This seems to be a jCenter issue. Until the issue is fixed you can temporarily change Android Gradle Plugin version to 3.1.0 within root build.gradle file:


    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        // other imports here...
    }

like image 15
azizbekian Avatar answered Oct 18 '22 18:10

azizbekian


I changed the order of this file: android/build.gradle

For me is working with this order:

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        google()        
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
          url "$rootDir/../node_modules/react-native/android"
        }        
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}
like image 3
Fernando Poli Avatar answered Oct 18 '22 18:10

Fernando Poli