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

[SOLVED: use react-native 0.63+ or patch locally] react-native-fbsdk-next:compileDebugJavaWithJavac #30

Closed
rukmanary opened this issue May 5, 2021 · 26 comments

Comments

@rukmanary
Copy link

Hi, months ago I use react-native-fbsdk and everything is already set. And this week I found that lib is already archived and it says to use react-native-fbsdk-next instead. So, I removed react-native-fbsdk and install react-native-fbsdk-next. I thought I don't need to follow any steps in Android Getting Started Guide because I already done that. I am able to run iOS but get an error in Android:

((my_directory_path))/node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBProfileModule.java:16: error: constructor ReactContextBaseJavaModule in class ReactContextBaseJavaModule cannot be applied to given types;
public class FBProfileModule extends ReactContextBaseJavaModule {
^
required: ReactApplicationContext
found: no arguments
reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: ((my_directory_path))/node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/Utility.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-fbsdk-next:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

I never change anything yet and get this error. Then I open my app/build.gradle and found my old code:
implementation 'com.facebook.android:facebook-core:5.+'
I tried to replace it with:
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
or
implementation 'com.facebook.android:facebook-core:[8,9)'

but it gives no effect. I also do manually linking but still the same. So can anyone help me to solve this please?

Environment

  1. "react": "16.9.0",
  2. "react-native": "0.61.1",
  3. "react-native-fbsdk-next": "^4.2.0",
@rukmanary
Copy link
Author

I think I solved this with Android Studio help because I'm not so familiar with Java...

In node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBProfileModule.java there's no constructor. And as Android Studio suggestion, I click one of it's options (just like eslint fix) and this code is automatically generated:

    public FBProfileModule(@NonNull ReactApplicationContext reactContext) {
        super(reactContext);
    }

Then in node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKPackage.java in createNativeModules function:

new FBProfileModule() is not passing anything.

So, I pass reactContext to it:
new FBProfileModule(reactContext)

is this really how to solved it? Or I am doing it wrong but it still works?

@ts-amir-shaikh
Copy link

I think I solved this with Android Studio help because I'm not so familiar with Java...

In node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBProfileModule.java there's no constructor. And as Android Studio suggestion, I click one of it's options (just like eslint fix) and this code is automatically generated:

    public FBProfileModule(@NonNull ReactApplicationContext reactContext) {
        super(reactContext);
    }

Then in node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKPackage.java in createNativeModules function:

new FBProfileModule() is not passing anything.

So, I pass reactContext to it:
new FBProfileModule(reactContext)

is this really how to solved it? Or I am doing it wrong but it still works?

Only one thing is missing in this which I already recommended in commit review
import com.facebook.react.bridge.ReactApplicationContext;

@ts-amir-shaikh
Copy link

When can we expect this fix with new release?
It works fine as expected please release this ASAP

@mikehardy
Copy link
Collaborator

You should update to at least react native 0.63 I think? 62 has no official support for the base react native framework since xcode 12.5 came out

@mikehardy
Copy link
Collaborator

@ts-amir-shaikh alternative method is to fix yourself locally until you can update to a modern react-native version - patch-package is the thing everyone uses for this - apply the patch locally and move on: https://github.com/ds300/patch-package

@rukmanary
Copy link
Author

I think I solved this with Android Studio help because I'm not so familiar with Java...
In node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBProfileModule.java there's no constructor. And as Android Studio suggestion, I click one of it's options (just like eslint fix) and this code is automatically generated:

    public FBProfileModule(@NonNull ReactApplicationContext reactContext) {
        super(reactContext);
    }

Then in node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKPackage.java in createNativeModules function:
new FBProfileModule() is not passing anything.
So, I pass reactContext to it:
new FBProfileModule(reactContext)
is this really how to solved it? Or I am doing it wrong but it still works?

Only one thing is missing in this which I already recommended in commit review
import com.facebook.react.bridge.ReactApplicationContext;

Yes, I forgot to mention it, import com.facebook.react.bridge.ReactApplicationContext;

@suchoX
Copy link

suchoX commented May 21, 2021

Can this please me mentioned in troubleshooting part of Readme?

@mikehardy mikehardy changed the title react-native-fbsdk-next:compileDebugJavaWithJavac [SOLVED: use react-native 0.63+ or patch locally] react-native-fbsdk-next:compileDebugJavaWithJavac May 21, 2021
@mikehardy mikehardy pinned this issue May 21, 2021
@mikehardy
Copy link
Collaborator

I made the title prescriptive and pinned it on the repo. At this point effectively no one should be using 0.62 or lower as it literally does not compile with current Xcode, it's broken completely.

@ts-amir-shaikh
Copy link

@ts-amir-shaikh alternative method is to fix yourself locally until you can update to a modern react-native version - patch-package is the thing everyone uses for this - apply the patch locally and move on: https://github.com/ds300/patch-package

@mikehardy Yes working with the patch for now

@thebergamo
Copy link
Owner

closing as #31 got merged

@ugrdursun
Copy link

ugrdursun commented Jun 28, 2021

@ts-amir-shaikh alternative method is to fix yourself locally until you can update to a modern react-native version - patch-package is the thing everyone uses for this - apply the patch locally and move on: https://github.com/ds300/patch-package

@mikehardy Yes working with the patch for now

How should we apply this patch ? I am not familiar with applying patches

@ugrdursun
Copy link

ugrdursun commented Jun 28, 2021

I think I solved this with Android Studio help because I'm not so familiar with Java...

In node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBProfileModule.java there's no constructor. And as Android Studio suggestion, I click one of it's options (just like eslint fix) and this code is automatically generated:

    public FBProfileModule(@NonNull ReactApplicationContext reactContext) {
        super(reactContext);
    }

Then in node_modules/react-native-fbsdk-next/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKPackage.java in createNativeModules function:

new FBProfileModule() is not passing anything.

So, I pass reactContext to it:
new FBProfileModule(reactContext)

is this really how to solved it? Or I am doing it wrong but it still works?

Hello,

I couldn't apply this because my FBProfileModule.java is not familiar with yours example.

I have this:

`package com.facebook.reactnative.androidsdk;

import com.facebook.Profile;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;

import androidx.annotation.NonNull;

/**
 * This is a {@link NativeModule} that allows JS to use FBSDKProfile info of the current logged user.
 */


@ReactModule(name = FBProfileModule.NAME)
public class FBProfileModule extends ReactContextBaseJavaModule {
    public static final String NAME = "FBProfile";

    @NonNull
    @Override
    public String getName() {
    return NAME;
  }

    /**
    * Get the current logged profile.
    * @param callback Use callback to pass the current logged profile back to JS.
    */
    @ReactMethod
    public void getCurrentProfile(Callback callback) {
        //Return the profile object as a ReactMap.
        callback.invoke(Profile.getCurrentProfile() == null
                ? null
                : Utility.profileToReactMap(Profile.getCurrentProfile()));
  }
}
`

How should i edit this ?

@mikehardy
Copy link
Collaborator

How should i edit this ?

You don't? The fix was merged so it's not necessary. Make sure you are using the current release here before attempting any troubleshooting, otherwise you may end up just chasing ghosts

@thebergamo
Copy link
Owner

you're faster than me @mikehardy :p

@mikehardy
Copy link
Collaborator

Haha just getting that first cup of coffee and rolling through notifications @thebergamo 😁☕ cheers

@ugrdursun
Copy link

How should i edit this ?

You don't? The fix was merged so it's not necessary. Make sure you are using the current release here before attempting any troubleshooting, otherwise you may end up just chasing ghosts

:) Well, i am receiving exact same error.

Hence my RN version is 0.61.5 , I use 4.2.0 and cant use 4.3.0 as the document says. So I am looking for a fix on 4.2.0

@mikehardy
Copy link
Collaborator

I believe 4.3.0 was specifically released to restore compatibility with older RN versions. The document may be out of date. How did it go when you tried it?

@ugrdursun
Copy link

I believe 4.3.0 was specifically released to restore compatibility with older RN versions. The document may be out of date. How did it go when you tried it?

I did not try it hence document clearly says To use this library you need to ensure you match up with the correct version of React Native you are using..

`

FB SDK lib version Required React Native Version

= 9.3.0+ | react-native-fbsdk-next > 4.3.0 | >=0.63.3

`

So I am not talking gibberish mate

@mikehardy
Copy link
Collaborator

mikehardy commented Jul 9, 2021

Didn't say you were talking gibberish:

I did not try it

I said "The document may be out of date. " not "you're talking gibberish." You should try it, report results.

@ugrdursun
Copy link

Didn't say you were talking gibberish:

I did not try it

I said "The document may be out of date. " not "you're talking gibberish." You should try it, report results.

My apologies, you were right! Document needs a correction. It works on both android and iOS perfectly. Sorry I got you wrong. Thanks!

@mikehardy
Copy link
Collaborator

Fantastic! I was about to be really confused if it did not work actually since it was the point of the change before. But documentation frequently goes out of date, yes. I'll hit the edit button at the top of the page and propose a change to the ranges now that we are compatible again

mikehardy added a commit that referenced this issue Jul 10, 2021
After work on #30, older versions are functional again but without testing they may break again in the future. Expose this tradeoff to library consumers
@mikehardy
Copy link
Collaborator

@ugrdursun what do you think of #71 ? I tried to expose the actual technical tradeoff if old versions are used - they do work now and we are not trying to break anyway, but it could happen by accident again since old versions are out of support really, meaning no one tests on them actively

thebergamo pushed a commit that referenced this issue Jul 11, 2021
…71)

After work on #30, older versions are functional again but without testing they may break again in the future. Expose this tradeoff to library consumers
@ugrdursun
Copy link

@ugrdursun what do you think of #71 ? I tried to expose the actual technical tradeoff if old versions are used - they do work now and we are not trying to break anyway, but it could happen by accident again since old versions are out of support really, meaning no one tests on them actively

With RN 0.61.5 and library 4.3.0 I did not receive any crash reports on a live app with around 15k+ users

@kevwang19
Copy link

kevwang19 commented Aug 15, 2021

I also have RN 0.61.5 and would like to use the 4.3.0 library if it fixes issues like mentioned above, but when I tried to install it, npm gave an err saying "unable to resolve dependency tree" since the dependency is >=0.63.3

It says
Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.

Not sure if it's ok to force something like this... is this how you did it? @ugrdursun
I usually don't run into situations like this so it's the first time for me where there's a dependency conflict that's hard to get around

I guess a better question is - is it safer/better for long term stability to use 4.2.0 and just try to fix the android issue, or use 4.3.0 despite the dependency conflict?

@mikehardy
Copy link
Collaborator

use older npm or --legacy-peer-deps

but really update react-native for long term stability

@ugrdursun
Copy link

I also have RN 0.61.5 and would like to use the 4.3.0 library if it fixes issues like mentioned above, but when I tried to install it, npm gave an err saying "unable to resolve dependency tree" since the dependency is >=0.63.3

It says
Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.

Not sure if it's ok to force something like this... is this how you did it? @ugrdursun
I usually don't run into situations like this so it's the first time for me where there's a dependency conflict that's hard to get around

I guess a better question is - is it safer/better for long term stability to use 4.2.0 and just try to fix the android issue, or use 4.3.0 despite the dependency conflict?

I am using 4.3.0 with 0.61.5 for more than a month and working fine on me. I think dependency conflict is not that deeper to cause any huge problem here.

@mikehardy mikehardy unpinned this issue May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants