Build errors after Android Studio 3.2.1 upgrade - android

I am building a sample project from Udacity. This was working fine till now, but after upgrading to Android Studio 3.2.1, I am facing the build error below.
Gradle version: 4.6
Project link: https://github.com/udacity/ud851-Sunshine/tree/student/S02.02-Solution-Menus
Could not find com.android.tools.build:aapt2:3.2.1-4818971**. Searched in the following locations:
file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom
file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar
file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom
file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar
file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom
file:/C:/Users/sandeepk2/AppData/Local/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
How can I fix it?

For Android Studio 3.2.1 update
Just add google() in root level build.gradle
buildscript {
repositories {
google() // <--here
jcenter()
}
}
allprojects {
repositories {
google() // <-- here
jcenter()
}
}
and see the magic - error is gone.

The project gradle version is pretty old:
classpath 'com.android.tools.build:gradle:2.2.3'
And you are using Android Studio v3.2.1 so, update the gradle:
classpath 'com.android.tools.build:gradle:3.2.0' // or 3.2.1 maybe
Also, as you can see, it was looking for some packages in :
file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom
Which means you probably forgot to add google() as the top level repository. Just add google()
to your repositories in your root build.gradle.

To get this solved
Firstly download the missing Jar file from the link below. I see you are missing version 3.2.1-4818971
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar
Switch your folder structure from Android to Project.
Now navigate to the libs folder inside the app - build folder. (If the libs folder does not exist, you can create it by right clicking on the app folder - select New - select Directory.)
Paste the downloaded.jar file inside libs folder. Right click on the jar file and at the bottom click on Add as library. This will take care of adding implementation files('libs/library_name.jar') in build.gradle [You don't have to manually enter this in your build file].
Everything should be okay once you sync after doing the above.
Here is the source link to this solution: https://developer.android.com/studio/command-line/aapt2#download_aapt2
Let me know if you run into any other issues whilst doing the above.

Yeah, as d4rkcon said download https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar
But you can do simplier - just put this file in directory where Andoid Studio is trying to find it. If you don't have directories like /tools/build/aapt2/3.2.1-4818971/ in AndroidSDK folder just create them and then put aapt2-3.2.1-4818971-windows.jar file in.

Add Google repository in your build.gradle(Project:xxxxx)
allprojects {
repositories {
google()
}
}

clear gradle cache
rm -rf $HOME/.gradle/caches/
and resync to download all dependencies

Change your build.gradle as follows.
android {
compileSdkVersion 26
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "your package name here"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:26.1.0'
}

add google() on your build script > repositories
add google on allprojects > repositories
use implementation as replacement of compile keyword,
also on your filetree.
EX.
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:design:25.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:25.3.1'

For Android Studio 3.6.3 update : just adding google maven tag in buildscript and all projects repositories in build.gradle file of project file solves the issue.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Related

How to use local aar inside flutter plugin?

I've create a flutter plugin with:
flutter create --template plugin flutter_plugin
I've put my aar file inside flutter_plugin/android/src/main/libs folder
I've modified flutter_plugin/android/build.gradle
and changed rootProject.allprojects section to
rootProject.allprojects {
repositories {
google()
jcenter()
flatDir {
dirs "src/main/libs"
}
}
}
And added dependencies section, after android {}:
dependencies {
implementation (name:"mylib",ext:"aar")
}
but when i try running with: flutter run
I get gradle exception, apparently it tried to look for my mylib.aar inside example directory: example/src/main/libs/mylib.aar and failed.
I can put my lib inside example dir, but i don't think it's the right way,
as i want my aar to be part of the plugin.
My solution to add local .aar depencies to a flutter plugin is as follows (based on the instructions here How to add .aar dependency in library module?):
create a libs folder in your android plugin source code (<plugin_name>/android/libs) (on top level of your plugin, not in the example project)
add your .aar files in this folder (e.g. myFirstDependency.aar)
add your .aar dependencies (without the .aar extension) to your plugins build.gradle file (<plugin_name>/android/build.gradle) e.g.
dependencies {
...
implementation (name: 'myFirstDependency', ext: 'aar')
implementation (name: 'myOtherDependency', ext: 'aar')
}
in order for gradle to be able to find these dependencies you need to instruct gradle to search in the libs folder inside of the plugin. Therefore add the following to your plugins build.gradle (<plugin_name>/android/build.gradle, same as for your dependencies) under rootProject.allprojects repositories section.
(NOTE: there is also a buildscripts a repositories section which you should not change for this).
rootProject.allprojects {
repositories {
google()
jcenter()
//Add this below <plugin_name> is whatever your plugin is called eg. url_launcher
flatDir {
dirs project(':<plugin_name>').file('libs')
// e.g. dirs project(':url_launcher').file('libs') - don't miss the ':'
}
}
}
With that, you don't have the .aar library dependencies directly in your plugin.
I created a libs directory in the android directory of my plugin. I placed the aar I generated in the libs directory:
I updated the build.gradle file for the android code to include the following:
rootProject.allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
And in the dependencies section:
implementation fileTree(dir: 'libs', include: ['*.aar'])
In my experience, adding direct plugin aar in another plugin project (flutter plugin's android project) is either very difficult or not allowed, so in that case, you have two options,
If your aar dependancy is available on gradle, use gradle that in your build file. You can search for it here
Or if you are building aar yourself from another project, then you can publish aar to your local maven and use that dependency in your flutter plugin by adding "mavenLocal()" to your plugins build file.
For example here is what I did to fix same issue:
My dependancy's build.gradle
group 'com.companyname.artifactname'
version '1.0-SNAPSHOT'
buildscript {
repositories {
mavenLocal()
google()
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
apply plugin: 'com.android.library'
uploadArchives {
repositories {
mavenLocal()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 2
versionName "2.0.1"
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
}
apply plugin: 'maven-publish'
publishing {
publications {
library(MavenPublication) {
version "1.1"
artifact(bundleRelease)
}
}
}
Then just run following command to publish it to local maven repository
gradlew publishToMavenLocal
And then just add mavenLocal() in your flutter plugin's repositories section and add dependancy as
compile 'com.companyname.artifactname:libraryname:1.1#aar'
With the flatDir solution you will get a warning when you try to sync your project with the Gradle files:
using flatDir should be avoided because it doesn't support any meta-data formats.
You can put this in your build.gradle instead to get rid of the warning:
android {
sourceSets {
main.jniLibs.srcDirs += project(':<plugin_name>').file('libs')
}
}
dependencies {
implementation files('libs/<dependency_name>.aar')
}
Unfortunately, with both solutions you'll get this error when you try to build the project:
Direct local .aar file dependencies are not supported when building an AAR.
The resulting AAR would be broken because the classes and Android resources from any local .aar
file dependencies would not be packaged in the resulting AAR. Previous versions of the Android
Gradle Plugin produce broken AARs in this case too (despite not throwing this error).
The accepted answer seems to be correct. I put the library inside the app's project instead because both options of the accepted answer were not possible in my case.
For this I had to create a new directory in the android directory of my app (i.e. example/android/<dependency_name>) and put my .aar file and a new build.gradle in that directory.
android/build.gradle:
dependencies {
implementation project(':<dependency_name>')
}
example/android/<dependency_name>/build.gradle:
configurations.maybeCreate("default")
artifacts.add("default", file('<dependency_name>.aar'))
example/android/settings.gradle:
include ':<dependency_name>'
i managed to make it work by adding
maven { url("${project(':test_flutter_plugin').file('libs').path}/my_lib") }
into rootProject.allprojects
of plugin/android/build.gradle

How to add design dependency in android studio 3.0. its not working in standard way

apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.rohit.ironman"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:design:26.1.1'
}
I have also tried-
Implementation 'com.android.support:design:26.1.1'
instead of
compile 'com.android.support:design:26.1.1'
but still the gradle sync fails
my gradle version is 4.1
android plugin version is 3.0.1
Use The method to add Android default librarys like support,design,core,.. library
Open your project in Android Studio
Right-click your app in project view and select "Open Module Settings"
Click the "Dependencies" tab and then the '+' button
Select "Libary Dependency"
Select Required Library fom the List
add this in build gradle of app
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}
and in build script of whole app
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
for more info about what changes are made just read here https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
You are using Google's support library as dependancy. And when you upgrade to Android Studio 3.0, Google's maven repository central is required if you want to use these library.
See this link for more details: https://developer.android.com/studio/build/dependencies.html#google-maven
Simply follow the migration instruction, add google() in the build.gradle file and sync again.
allprojects {
repositories {
google()
// If you're using a version of Gradle lower than 4.1, you must instead use:
// maven {
// url 'https://maven.google.com'
// }
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
Try to add the missing code from here
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
}
google()
}
}
and add this to your build.gradle(Module:app)
dependencies {
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.android.support:design:27.0.1'
compile 'com.android.support:support-v4:27.0.1'
}
just refractor it
Refractor<<migrate to android X
Just to improve on #Tomin B Azhakathu answers to tackle design library particularly. Follow these steps:
Right-click your app in project view and select
Select Open Module Settings
Click the "Dependencies" tab
Then click the '+' button on below the "Declared Dependencies"
Select "Libary Dependency"
Enter "design" on the search form and hit enter key
On the returned result select the Library with Artifact = "design" and Group ID = "com.android.support"
Click on ok and Synch your grade if need be.
PS: This is Legacy Library now, you may need to migrate to AndroidX
You can't add design dependency in implementation, instead of we can use material dependency:
implementation 'com.google.android.material:material:1.2.1'

Gradle build error: Failed to resolve:

I just downloaded Android Studio and created a new project and I'm getting gradle build errors:
Failed to resolve: com.android.support.test.espresso-core:2.2.2
and
Failed to resolve: com.android.support.appcompat-v7:25.3.1
This error was resolved reinstalling the SDK Tools + Repository + API when launching android studio as admin.
I've installed API Level 25 which what I want to build on and have downloaded the SDK Build-Tools. I have also already download the support repository
Here's my app file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.jtsalas.mirrorcontrol"
minSdkVersion 25
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
From the SDK manager, make sure you have both the Android Support Repository and Google Repository installed and up to date. You should then be able to find the relevant artifacts in sub folders of your /extras/android/m2repository directory
From your error it seems that you are not including espresso libraries. The solution to this is adding espresso core library which is part Android Testing support library which is hosted in the google's Maven repository think this as kind of git repository but for dependencies.
So we tell the gradle build system to look in the Maven repository for dependencies by specifying its URL.
This is done by adding Maven url in the application level build.gradle file under repositories block
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
and in the module level build.gradle file mention the dependencies that you want from the maven repository by mention their name as follows:
dependencies{
//other dependencies go here
//testing dependencies
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
}
That is the reason for including Maven repository url in the app level build.gradle file, hope this helps.
In project.gradle file, the allprojects root align this way:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
jitpack is used as the dependency for multiple libraries, if you're not using any sort of library that don't requires it then not include maven line.
Well, I don't know the perfect answer but..... how about comparing with my SDK Tools?
I solved it by uninstalling Android Studios and deleting old versions of Android Studios in my C:\Users[Username] and reinstalled Android Studio as administrator.
It seems like you updated android studio and opening previous project in it.The simplest way is create new project and copy
1. compileSdkVersion 26
2. buildToolsVersion "26.0.1"
3. targetSdkVersion 26
4. compile 'com.android.support:appcompat-v7:26.+'
and paste them in appropriate places in app level build gradle.
it will ask to update to take advantages .. allow it to update.
best luck ... It worked for me.
if your project is Flutter,
clean project [by 'flutter clean' command]
In project.gradle file add [ google() ]
in Android studio: File Menu -> Invalidate...
project.gradle:
allprojects {
repositories {
google()
jcenter()
}
}

android : cannot build project after upgrading Android Studio to 2.3

So, happily updated my Android Studio from stable version 2.2 to canary channel 2.3.
But, unfortunately, it has serious bug. Project is not able to build.
I tried opening my previous projects and also tried creating new sample application, I got same below error:
Gradle 'MyApplication' project refresh failed
Error:A problem occurred configuring project ':app'.
build.gradle(project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.chint.myapplication"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:design:25.0.0'
testCompile 'junit:junit:4.12'
}
Am I the only one with this issue ?
So, be careful while this dialog appears:
Choose "Remind me later" and NOT "Update"
Stay with the build version you already have.
Incase, you pressed Update, so just rollback your Android Gradle Plugin classpath in build.gradle(project) to below one:
classpath 'com.android.tools.build:gradle:2.2.2'
This worked for me.
You should update your Android Studio gradle manually.
1° Step:
Follow this path and get your gradle version
C:\Users\[USER_NAME]\.gradle\wrapper\dists
Here you will get "gradle-X.X" (X- is version) in my case it was "gradle-3.3-all"
2° Step:
Go to the following link :
https://services.gradle.org/distributions/
Download your respective version zip file and just past it in the last folder with long random name.
C:\Users\[USER_NAME]\.gradle\wrapper\dists\gradle-x.x\55gk2rcmfc6p2dg9u9ohc31212 HERE
Now open the Android studio, I hope this will work.
I fought a similar issue and resolved it with the addition of 2 characters...
And after updating the gradle-wrapper.properties to target 3.2.1 everything was great for me
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip
If you import external libraries apply changes for "allprojects"
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Android Studio could not find any version that matches com.android.support:appcompat-v7:+

Running a project in Android Studio fails with this error: could not find any version that matches com.android.support:appcompat-v7:+
How can I fix this error?
From Android Studio go to:
Tools >> Android >> SDK Manager
Select and install "Extras|Android Support Repository"
For me it worked after changing the version from 7:27.+ to 7:+
In Project > app > build.gradle file replace the line
implementation 'com.android.support:appcompat-v7:+'29.+'
with
implementation 'com.android.support:appcompat-v7:+'
and line
implementation 'com.android.support:design:29.+'
with
implementation 'com.android.support:design:+'
Then clean build
Also as as said on How to update Android platform-tools in a headless linux?
android list sdk
android update sdk --no-ui --filter extra
It is very simple.
Kindly update and replace the below code in build.gradle(Project :App Name).
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
After installing Extras|Android Support Repository, It does not work for me. Then I change v7:1.6 to v7:1.8 in the app build.gradle file.
com.android.support:appcompat-v7:1.8.+! and It works for me.
Open SDK Manager.exe in your Android Studio folder and install a matching API.
I found all these answers incorrect for me. Instead in your android studio look below on the left. There will be some help for this.
For example, you will notice
This support library should not use a different version (32) than the compilesdkVersion (23)
Then you change the version of to 23 like this
compile 'com.android.support:support-v4:23'
Now, you will see a message
A newer version of com.android.support-v4 than 23 is available 23.4.0.
Thats how I knew that the correct version is 23.4.0
If you see this after you've just created a new project in Intellij then try to recreate it again with "Use AndroidX artifacts" checked
To whom came here for same error but version 29, change your support library to version 28:
build.gradle(app):
dependencies {
...
implementation 'com.android.support:appcompat-v7:28.+'
...
}
None of googled solutions worked for me. Then I saw Android has only support library up to version 28. It is weird that I got this error in an out-of-box created Android Studio project.
I'm not sure which Android Studio version was, cause I upgraded Studio after got error. Now in Android Studio 3.6.3, new projects coming with 'androidx.appcompat:appcompat:1.0.2'.
This worked for me to build and run this project.
I had to add google in both sections.
build.gradle (project)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "29.0.2" //25.0.2"
defaultConfig {
applicationId 'com.github.nkzawa.socketio.androidchat'
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
////noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:25.0.+'
////noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:25.0.+'
implementation ('io.socket:socket.io-client:0.8.3') {
exclude group: 'org.json', module: 'json'
}
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
}
Got the same error but version 26.
Downloading the libraries through the SDK Manager is no longer supported. The support libraries are now available through Google's Maven repository.
Solution:
In build.gradle (project) inside both buildscript/repositories and allprojects/repositories add this:
maven {
url 'https://maven.google.com/'
name 'Google'
}
Result:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
It worked for me.

Categories

Resources