udacity / ud851-Sunshine

Apache License 2.0
2k stars 4.51k forks source link

Gradle build error. Seems to fail at finding something #192

Closed NanoSpicer closed 5 years ago

NanoSpicer commented 5 years ago

I started this course a year ago and finallyI have some time to get my hands on the course again. Can I get some help fixing this? Seems that a lot of stuff has been deprecated since the course started

Thanks! Here's a dump of the error


Could not find com.android.tools.build:aapt2:3.2.1-4818971. Searched in the following locations: file:/D:/Programming/Android/SDK/extras/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom file:/D:/Programming/Android/SDK/extras/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar file:/D:/Programming/Android/SDK/extras/google/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom file:/D:/Programming/Android/SDK/extras/google/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar file:/D:/Programming/Android/SDK/extras/android/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom file:/D:/Programming/Android/SDK/extras/android/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar Required by: project :app

tristanaj commented 5 years ago

I'm getting the same error. I'm trying to build S01.01-Exercise-CreateLayout on a Mac with OSX 10.14 Android studio 3.2.1. I notice there are also the following errors in the build window in addition to the "Could not find com.android.tools.build:aapt2:3.2.1-4818971" error, which are as follows:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. |  
-- | --
Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation' and 'androidTestApi'. |  
Configuration 'androidTestApi' is obsolete and has been replaced with 'androidTestImplementation'. |  
The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1. |  

Any help would be greatly appreciated. Thanks!

rbryan21 commented 5 years ago

@tristanaj

"The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1."

When you open the exercise open up the 'Project Structure' window (found under the 'File' tab on Windows) and select the 'app' module and then the 'Flavors' tab. Make sure the 'Target Sdk Version' is set to 'API 28'.

rbryan21 commented 5 years ago

@NanoSpicer

Open the 'build.gradle' in the root of your project (press Shift + Shift to bring up the file search) and add 'google()' to the repositories block within 'allprojects'.

image

Unfortunately I've had to repeat the above step for every exercise I import into Android Studio. See my response to tristanaj above too - you will probably need to update your target SDK version for the project as well.

AntonC9018 commented 5 years ago

I've been having the same problem. Devs, fix it please! Here is the question on Stack Overflow: https://stackoverflow.com/questions/52790020/build-errors-after-android-studio-3-2-1-upgrade

NanoSpicer commented 5 years ago

Now that I had some spare time I tried with what @rbryan21 suggested and that was it. Had some trouble finding the flavors and selecting the gradle files, but basically:

As a recap: In android studio select the app folder, then in MacOS: File > Project Structure... Then select the "app" module (that's why I needed to click on the app folder) > Flavors tab > Target SDK, change that to 28. [enter]

Change the gradle file of the project and add the google() thingy @rbryan21 pointed out. Sync again and then compile it. It works!

Thanks a lot @rbryan21 , closing this issue!

kjaneem commented 5 years ago

@rbryan21 solution works!