Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodError: No static method isAtLeastR()Z

My app was running fine but suddenly I started getting this error

java.lang.NoSuchMethodError: No static method isAtLeastR()Z in class Landroidx/core/os/BuildCompat; or its super classes (declaration of 'androidx.core.os.BuildCompat' appears in /data/app/com.app.goflatmates-RZKwS2h6hav==/base.apk) at com.google.android.gms.common.util.PlatformVersion.isAtLeastR(com.google.android.gms:play-services-basement@@17.2.0:21) at com.google.android.gms.common.api.GoogleApi.zaa(com.google.android.gms:play-services-base@@17.2.0:128) at com.google.android.gms.common.api.GoogleApi.(com.google.android.gms:play-services-base@@17.2.0:23) at com.google.android.gms.common.api.GoogleApi.(com.google.android.gms:play-services-base@@17.2.0:54) at com.google.android.gms.auth.api.signin.GoogleSignInClient.(Unknown Source:3) at com.google.android.gms.auth.api.signin.GoogleSignIn.getClient(Unknown Source:3

The problem is coming in this line

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build(); 

mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
like image 818
Avin Kamboj Avatar asked Mar 23 '20 11:03

Avin Kamboj


Video Answer


2 Answers

I had this issue with React Native as well. I fixed it by setting this in my app/build.gradle:

dependencies {
    // ...
    implementation 'com.google.android.gms:play-services-base:17.1.0'
    // ...
}

It's because of a breaking change introduced by Google play-services-base library a couple days ago. If you use implementation 'com.google.android.gms:play-services-base:+' it will download the latest version of the library, introducing that bug into your app. Hope that helps.

like image 177
Aditya Gune Avatar answered Oct 18 '22 04:10

Aditya Gune


/**
     * Checks if the device is running on a pre-release version of Android R or newer.
     * <p>
     * <strong>Note:</strong> This method will return {@code false} on devices running release
     * versions of Android. When Android R is finalized for release, this method will be deprecated
     * and all calls should be replaced with {@code Build.VERSION.SDK_INT >= Build.VERSION_CODES.R}.
     *
     * @return {@code true} if R APIs are available for use, {@code false} otherwise
     */
    public static boolean isAtLeastR() {
        return VERSION.CODENAME.length() == 1 && VERSION.CODENAME.charAt(0) >= 'R'
                && VERSION.CODENAME.charAt(0) <= 'Z';
    }

Android Q is a finalised release and this method is no longer necessary. It will be removed in a future release of the Support Library.

Kindly downgrade version

 implementation 'com.google.android.gms:play-services-base:17.1.0'
 implementation 'com.google.android.gms:play-services-base:17.0.0' //OR
like image 3
IntelliJ Amiya Avatar answered Oct 18 '22 03:10

IntelliJ Amiya