Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library source does not match the bytecode for class ParseFacebookUtils #1140

Closed
4 tasks done
Code-B1 opened this issue Nov 8, 2021 · 9 comments
Closed
4 tasks done
Labels
type:question Support or code-level question

Comments

@Code-B1
Copy link

Code-B1 commented Nov 8, 2021

New Issue Checklist

Issue Description

When following the instructions to implement Facebook login using the Parse SDK (instructions provided by Back4App) I have reached a hurdle where on clicking on the log in button the project has a fatal exception and crashes.

The fatal exception details the below:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.authenticationtesttwoback4app, PID: 2117
    java.lang.NoSuchMethodError: No static method logInWithInBackground(Ljava/lang/String;Ljava/util/Map;)Lbolts/Task; in class Lcom/parse/ParseUser; or its super classes (declaration of 'com.parse.ParseUser' appears in /data/app/~~y7oSz52GMdD-dfc8qNSD-Q==/com.example.authenticationtesttwoback4app-pTWUIAaWaZVSSpSG0vbGiQ==/base.apk)
        at com.parse.facebook.ParseFacebookUtils$ParseUserDelegateImpl.logInWithInBackground(ParseFacebookUtils.java:587)
        at com.parse.facebook.ParseFacebookUtils$2.then(ParseFacebookUtils.java:306)
        at com.parse.facebook.ParseFacebookUtils$2.then(ParseFacebookUtils.java:303)
        at bolts.Task$15.run(Task.java:917)
        at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
        at bolts.Task.completeAfterTask(Task.java:908)
        at bolts.Task.continueWithTask(Task.java:715)
        at bolts.Task.continueWithTask(Task.java:726)
        at bolts.Task$13.then(Task.java:818)
        at bolts.Task$13.then(Task.java:806)
        at bolts.Task$15.run(Task.java:917)
        at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
        at bolts.Task.completeAfterTask(Task.java:908)
        at bolts.Task.access$100(Task.java:32)
        at bolts.Task$11.then(Task.java:708)
        at bolts.Task$11.then(Task.java:705)
        at bolts.Task.runContinuations(Task.java:956)
        at bolts.Task.trySetResult(Task.java:994)
        at bolts.TaskCompletionSource.trySetResult(TaskCompletionSource.java:39)
        at com.parse.facebook.FacebookController$1.onSuccess(FacebookController.java:115)
        at com.parse.facebook.FacebookController$1.onSuccess(FacebookController.java:110)
        at com.facebook.login.LoginManager.finishLogin(LoginManager.java:1184)
        at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:304)
        at com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:241)
        at com.facebook.internal.CallbackManagerImpl.onActivityResult(CallbackManagerImpl.kt:44)
        at com.parse.facebook.FacebookController.onActivityResult(FacebookController.java:88)
        at com.parse.facebook.ParseFacebookUtils.onActivityResult(ParseFacebookUtils.java:159)
        at com.example.authenticationtesttwoback4app.MainActivity.onActivityResult(MainActivity.kt:130)
        at android.app.Activity.dispatchActivityResult(Activity.java:8310)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:5008)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:5056)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process: Sending signal. PID: 2117 SIG: 9

When looking within the ParseFacebookUtils.java it appears (at least the first clickable link in the error) that there is an issue relating to bolts:

Required type: bolts.Task
Provided: com.parse.boltsinternal.Task

I know this file is read-only as such unsure how I can resolve this issue. Unfortunately I am very new to Kotlin and Android Studio and searching online has not brought much luck with " similar " issues being resolved by cleaning and the project, rebuilding, changing compileSdk versions etc but none of these have worked for me and I am at a point where I am wondering if I will be able to use this SDK for Facebook login at all due to this error so could do with some assistance.

Steps to reproduce

Using the latest SDK and following the steps for implementing Facebook Login provided on the back4app tutorials.

Actual Outcome

I get this error when trying to log in

Expected Outcome

The code to execute without error and create a user in my dashboard.

Environment

Parse Android SDK

  • SDK version: 2.0.4
@parse-github-assistant
Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@mtrezza mtrezza added type:bug Impaired feature or lacking behavior that is likely assumed state:needs-investigation labels Nov 8, 2021
@mtrezza
Copy link
Member

mtrezza commented Nov 8, 2021

It seems to say that there was no such method:

java.lang.NoSuchMethodError: No static method logInWithInBackground

Is the method there and accessible? Can you try with SDK 1.26.0? The Facebook SDK and maybe some methods have been touched in #1105.

@Code-B1
Copy link
Author

Code-B1 commented Nov 9, 2021

Within ParseFacebookUtils.java there is not a " static " method for this so I guess the error is correct. I can only see an override for a public Task at the bottom of this file however, this is not static

@Override public Task<ParseUser> logInWithInBackground(String authType, Map<String, String> authData) { return ParseUser.logInWithInBackground(authType, authData);

I have tried with SDK 1.26.0, cleaned and rebuild the project but still the exact same error, I wonder if there is any way around this ?

@mtrezza
Copy link
Member

mtrezza commented Nov 9, 2021

Let's go one step back and look at your code. Parse.User has a static method logInWithInBackground, but ParseFacebookUtils has a logInInBackground. The methods are different, because ParseFacebookUtils is an abstraction of managing the lower level logInWithInBackground with Facebook auth. You may simply be calling the wrong method in your code, please check the docs on how to use ParseFacebookUtils.

@mtrezza mtrezza added type:question Support or code-level question and removed type:bug Impaired feature or lacking behavior that is likely assumed state:needs-investigation labels Nov 9, 2021
@Code-B1
Copy link
Author

Code-B1 commented Nov 9, 2021

I keep trying to go over the code however I cannot identify where I may be calling the wrong method or an alternative, I apologize as I am not well versed in Kotlin or Android Studio but I have copied the code (with the method suggested) from the ParseFacebookUtils documentation and still receive the same error, the code is as below:

val login = findViewById<Button>(R.id.buttonLogin)
        login.setOnClickListener {
            val dlg = ProgressDialog(this)
            dlg.setTitle("Please, wait a moment.")
            dlg.setMessage("Logging in...")
            dlg.show()
            val permissions: List<String> = listOf("public_profile", "email")
 
            ParseFacebookUtils.logInWithReadPermissionsInBackground(
                this, permissions
            ) { user, err ->
                if (user == null) {
                    Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.")
                } else if (user.isNew) {
                    Log.d("MyApp", "User signed up and logged in through Facebook!")
                } else {
                    Log.d("MyApp", "User logged in through Facebook!")
                }
            }

The method being called is logInWithReadPermissionsInBackground which is the method suggested in the documentation and seems to error at the point of selecting 'Continue' on the Facebook login page. It is very possible I may be missing something here but I am unsure what it may be.

@mtrezza
Copy link
Member

mtrezza commented Nov 10, 2021

You could set a breakpoint and debug step through the code to see what is going on. As you can see in the SDK, logInWithInBackground is defined publicly in ParseUserDelegateImpl:

interface ParseUserDelegate {
void registerAuthenticationCallback(String authType, AuthenticationCallback callback);
Task<ParseUser> logInWithInBackground(String authType, Map<String, String> authData);
}
private static class ParseUserDelegateImpl implements ParseUserDelegate {
@Override
public void registerAuthenticationCallback(
String authType, AuthenticationCallback callback) {
ParseUser.registerAuthenticationCallback(authType, callback);
}
@Override
public Task<ParseUser> logInWithInBackground(
String authType, Map<String, String> authData) {
return ParseUser.logInWithInBackground(authType, authData);
}
}

And it's also defined in Parse.User:

public static Task<ParseUser> logInInBackground(String username, String password) {

Unless your proguard config removes that method, I can't think of a reason it couldn't be called. Maybe paste your SDK implementation from gradle here to take a look at.

@Code-B1
Copy link
Author

Code-B1 commented Nov 14, 2021

I've tried stepping through the code but without a real understanding of what's happening its hard to determine what is going on.

I can see that it appears to be running onActivityResult from within ParseFacebookUtils.java at the point it seems to crash is when it try's to run this code from the FacebookController.java

callbackManager = facebookSdkDelegate.createCallbackManager();
        manager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                AccessToken accessToken = loginResult.getAccessToken();
                Map<String, String> authData = getAuthData(accessToken);
                tcs.trySetResult(authData);
            }

(more specifically at the point of trySetResult, the getAuthData itself seems to have populated with values).

My list of gradle dependencies are as below:

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation 'com.facebook.android:facebook-android-sdk:latest.release'

    implementation "com.github.parse-community.Parse-SDK-Android:parse:2.0.4"
    implementation "com.github.parse-community:ParseFacebookUtils-Android:1.14.0"

    implementation "com.parse.bolts:bolts-tasks:1.4.0"
    implementation "com.parse.bolts:bolts-applinks:1.4.0"

Proguard is set up as it is by default:

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }
    }

@azlekov
Copy link
Contributor

azlekov commented Nov 14, 2021

Some time everything was consolidated into the Android SDK repository and published together.

@Code-B1 you should use

implementation "com.github.parse-community.Parse-SDK-Android:facebook:$parseVersion"

instead of the deprecated and archived

implementation "com.github.parse-community:ParseFacebookUtils-Android:1.14.0"

@Code-B1
Copy link
Author

Code-B1 commented Nov 14, 2021

@L3K0V Thank you so much, changing this code seems to stop the application from crashing and I can see I now have a user created inside back4app so seems to have resolved the issue.

@mtrezza Thank you also for taking so much time to help assist me with this one.

@Code-B1 Code-B1 closed this as completed Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

3 participants