ChatGPT解决这个技术问题 Extra ChatGPT

Could not find play-services-basement.aar

Yesterday I tried building my app and everything worked fine.

Today, without any changes to the project... All of a sudden I'm greeted with this warning message telling me:

Error:Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:11.0.1). 
Searched in the following locations:
    https://jcenter.bintray.com/com/google/android/gms/play-services-basement/11.0.1/play-services-basement-11.0.1.aar

Is anyone experiencing the same sort of issue?

If you follow the link where it's searching for the package it basically gets downloaded instantly through the browser. I suppose something has changed on the server side? Perhaps naming conventions?

It looks like it's looking for: play-services-basement.aar and fetches play-services-basement-11.0.1.aar instead? Could this be a naming convention or gradle issue?

I understand it is somewhat related because it is the same error message. But I think it would be better if the question was a general building failure question and not ionic related. Since this has to do with package building and could happen with a native app (or any framework really) as well. Hence I made the other topic. I also think this is why it is more broadly viewed, since people search for this type of topic title in a more general sense.

M
Muhamed Riyas M

jcenter() has had mirrors of some libraries (I guess they are doing intentionally) that should originally available through google() or maven() repositories. When gradle build works, for any library that is used in the project the first place to look for is the repository that is listed first in repositories {.. When the jcenter() mirror does not have the release (e.g com.google.android.gms:play-services-ads:15.0.1 for my case) your gradle is looking for, the build fails with such error.

So, jcenter() should be listed at the last place in repositories {.. parts as below.

   buildscript {
    ext.kotlin_version = '1.2.50'
    repositories {
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
    }...

and

  allprojects {
    repositories {
        google()
        jcenter()
    }
  }

This solved my problems with the "could not find ...aar" files after updating to 'com.google.gms:google-services:4.0.1'. Every time I try and update this or the Play Services version I seem to run into this type of obscure and frustrating problem. Thanks for ending a 3 hour hunt to resolve this issue!
saying jcenter to be last place in cradle file is rescue my life :)
this problom suddenly happend for me, Thank you so much ur solution help just with change order of jcenter() to the last one .
just ran into this issue.
Thanks. Project was working fine and suddenly I ran into the same issue. Putting jcenter() to the last one solved the issue.
u
user846316

This is crazy!!! I faced the same issue. The builds were working fine and then suddenly started to fail with the same issue. I tried the suggestions above but it didn't work for me. Finally, this is what worked for me:

Update to latest firebase dependencies:

implementation 'com.google.firebase:firebase-core:16.0.4' implementation 'com.google.firebase:firebase-ads:17.0.0'

also, the ads services:

implementation 'com.google.android.gms:play-services-ads:17.0.0'

Note: with play-services-ads:17.0.0, it mandatory to add the following in the Manifest file, otherwise application crashes on opening.


This worked for me. I highlighted over all of the gradle depenencies giving me problems and there was a newer version available. Changed them to the newest version and it worked.
I had to update all of the firebase dependencies to get it building successfully.
This seems to be the "current" correct answer. The accepted answer of re-ordering things just doesn't seem to matter in many cases.
I understand that it is a matter of updating packages, because they will ultimately decide which packages and with which names to download from the repositories. Is it the package maintainer that should update their references when a repository decides to change their package name though? If that would be the case, that would mean each time either one of the repo's decide to change their package names, a package maintainer would have to obsolete ALL of their previous versions and move to a 'current' version that does work. The reason I don't accept this answer is exactly because I dissagree
I'd rather see the ability to allow for multiple repositories to be searchable, rather then hard failing on the single first one in the list. This way you'd be able to support older packages with different naming schemes by entering alternate sources. (Perhaps you'd even want to host your own repository with package names at some point for stability and self maintaining purposes?) I understand this means relying on older packages, which is bad. But in some cases you have a dependency issue which can not be solved because of outdated software. Supporting legacy systems should be supported IMO.
r
raiser00

UPDATE #2 2018/05/29 The issue looks to be fixed gone now, and I'm still using the same gradle configs. But I did these steps a while ago I'm not sure if these did anything or if this is a server-side issue and it got fixed/updated recently. I just noticed the issue was gone after I did the following steps:

Add the following in project-level gradle.build's buildscript > repositories and allprojects > repositories. google() maven { url 'http://jcenter.bintray.com' } Change the google-services classpath to classpath com.google.gms:google-services:4.0.1' Sync Project with Gradle Files

UPDATE #1 2018/05/29 I got around the error by downgrading my firebase dependencies to ~12.0.0 in the app-level gradle. But this will severly impact the app, still looking around for more feasible workarounds.



    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    ...
    compile 'com.google.firebase:firebase-core:12.0.0'
    compile 'com.google.firebase:firebase-database:12.0.0'
    compile 'com.google.firebase:firebase-storage:12.0.0'
    compile 'com.google.firebase:firebase-auth:12.0.0'
    compile 'com.google.firebase:firebase-crash:12.0.0'
    ...

Same here, I have experienced the same issue described by @SimbaClaws. Everything was compiling smoothly until I faced the same issue yesterday.

I have the following codes in my project-level build.gradle,



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

    buildscript {
        repositories {
            jcenter()
            maven {
                url 'https://maven.fabric.io/public'
            }
        }
        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
            //classpath 'com.google.gms:google-services:3.0.0'
            classpath 'com.google.gms:google-services:3.2.1'
            classpath 'io.fabric.tools:gradle:1.25.1'
        }
    }

    allprojects {
        repositories {
            jcenter()
            maven {
                url 'https://maven.google.com/'
            }
        }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    }

And the following codes for the app-level build.gradle



    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'

    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.1"
        defaultConfig {
            applicationId "my.secret.application"
            minSdkVersion 16 // 19
            targetSdkVersion 26
            versionCode 1
            versionName "5.0.204"
            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.google.firebase:firebase-core:15.0.2'
        compile 'com.google.firebase:firebase-database:15.0.0'
        compile 'com.google.firebase:firebase-storage:15.0.2'
        compile 'com.google.firebase:firebase-auth:15.1.0'
        compile 'com.google.firebase:firebase-crash:15.0.2'
        compile 'com.android.support:appcompat-v7:26.+'
        compile 'com.android.support:design:26.+'
        compile 'com.android.support:recyclerview-v7:26.+'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'de.hdodenhof:circleimageview:2.2.0'
        compile 'com.android.support:palette-v7:26.+'
        compile 'com.android.support:support-v4:26.+'
        compile 'com.android.support:cardview-v7:26.+'
        compile 'com.github.bumptech.glide:glide:3.7.0'
        compile 'org.greenrobot:eventbus:3.1.1'
        testCompile 'junit:junit:4.12'
        compile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
    }


    apply plugin: 'com.google.gms.google-services'

Can anyone advise if I missed anything? I'm also still looking around for possible workarounds and answers. TIA!


S
Swapnil Kadam

Had same issue, for me none of the answers mentioned here worked. So I just updated dependencies in the gradle file and whichever dependency had com.google.gms: (kept them at same version example 16.0.0)


G
George

I have also experienced this issue. The root cause, I found out was that there inconsistent build Gradle version. In the Gradle Scripts repository "if I can call it that " there are two build gradle modules. The build.gradle (Project: name of app) and the build.gradle (Module: app). Make sure that classpath 'com.android.tools.build:gradle:3.2.1' in dependencies is using the latest and same version of the tool. Inconsistencies result in issues with the build.


a
aNiKeT

In my case just added www earlier url was like url "https://jitpack.io/" after this added www started working for me. In other repositories also try to add explicit URLs.

maven {
            url "https://www.jitpack.io/"
        }