Could not find aapt2-proto.jar
Asked Answered
W

7

31

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
Windom answered 23/10, 2018 at 8:34 Comment(11)
Did you try any upgrades in your project?Gracegraceful
Which type of upgrades @KosalramRamaKrishnan ? ... FWIW, I just edited my comment that I am using latest version of react native and react native cli ... Its a fresh project ...Windom
Got the same error. If you follow the link you get a 404. I guess we have to wait until it is resolved by jcenter.Gurney
@Windom I doubt that you might be using incompatible SDK versions. Missing jar files usually happens a lot. Just open your project in Android Studio and it will build your project freshly based on your newer versions whatever you've used in your project. Let me know if the issue persists.Gracegraceful
Hey @KosalramRamaKrishnan android studio is already opened and seems like its a fresh build also ... see this image screenshot i.imgur.com/YY4UMzh.png ... Am I missing something sir?Windom
Like this @jstrater (see image screenshot) ?? i.imgur.com/0W1XcZa.png ... After jcenter() function execution sir?Windom
Maybe this will help: https://mcmap.net/q/195748/-android-ci-build-could-not-find-aapt2-proto-jarLacker
@M.Ricciuti It's actually a duplicate. Even I shared the same link. Thanks, Harry I learned a new thing.Gracegraceful
Thanks all of you guys ... I just successfully build it ... Thanks a lot ... Even I learned a new thing today ;)Windom
Food for Thought @KosalramRamaKrishnan ... Though it works, but would like to confirm, Is this the correct code that I have changed i.imgur.com/t795JWr.png or am I missing somethingWindom
duplicate with: https://mcmap.net/q/196776/-could-not-find-aapt2-proto-jar-com-android-tools-build-aapt2-proto-0-3-1Amused
G
49

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.

Gracegraceful answered 23/10, 2018 at 9:7 Comment(4)
Note that the order matters, if jcenter() is above google() it failed for me.Orelu
If it isn't working for you, make sure you change both locations. Also take @fejd's advice.Quotable
Indeed, place google() as the first item in repositioriesLawerencelawes
@PedroPauloAmorim it's not working for me too. do you find any other answer?Gerick
S
15

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...
    }

Suckerfish answered 23/10, 2018 at 9:38 Comment(0)
I
3

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")
}
Iow answered 24/10, 2018 at 13:52 Comment(0)
N
2

This question's answer In build.gradle change position of google() and place it first: This is how it was before, if you don't have google() add it as the first one in the buildscript:

buildscript {
       repositories {
                  jcenter()
                  google()
}

change to,

buildscript {
       repositories {
               google()
               jcenter()
}
Nabala answered 21/1, 2019 at 9:15 Comment(0)
L
1

Project -> Open Module Setting -> "Project Structure - Project"

Check your Android Plugin Repository and Default Library Repository.

Note: google(), jcenter - its default value in my project.

enter image description here

Loriloria answered 25/10, 2018 at 14:21 Comment(0)
A
0

You have to add google() to repositories in build.gradle file and put it at first position:

...
repositories {
    google()        
    jcenter()
}
...

In my case the problem was the repository order.

Ameliorate answered 30/10, 2018 at 17:44 Comment(0)
C
0

For me problem fixed just after gradle update, note that I had problem even with adding google() to repository

Commissioner answered 25/12, 2019 at 11:48 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.