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

Error: Android cannot find symbol Leanplum.setAplicationContext(this); #68

Closed
AugustoAleGon opened this issue May 23, 2022 · 3 comments
Closed

Comments

@AugustoAleGon
Copy link

After following the Leanplum documentation on Android https://docs.leanplum.com/reference/react-native-setup
And also trying the autolink and the manual linking and both didn't work.

I still got this:

MainApplication.java:89: error: cannot find symbol
    Leanplum.setAplicationContext(this);
            ^
  symbol:   method setAplicationContext(MainApplication)
  location: class Leanplum
@hborisoff
Copy link
Contributor

Hi @AugustoAleGon,
When running the manual linking it should add a new module in your ./android/settings.gradle file, named :@leanplum_react-native-sdk.

If you want to access the SDK methods in your Android project you need to add the dependency to your ./android/app/build.gradle file:
implementation project(':@leanplum_react-native-sdk')

and if you want the FCM/MiPush/Huawei push support you need to add more dependencies such as:

implementation "com.leanplum:leanplum-fcm:${LEANPLUM_SDK_VERSION}"
implementation "com.leanplum:leanplum-mipush:${LEANPLUM_SDK_VERSION}"
implementation "com.leanplum:leanplum-hms:${LEANPLUM_SDK_VERSION}"

Note that the ${LEANPLUM_SDK_VERSION} points to the native version of our Leanplum Android SDK that is integrated in the React Native Leanplum SDK, it is mandatory to use the same version for all our native SDKs.

Check our sample project here.

@hborisoff
Copy link
Contributor

@augusto-booment
I'm sending you my sample project I created few minutes ago.
This is not the full Leanplum integration, but only to the point where you cannot compile it.

These are the commands executed:

  1. react-native init NewProject
  2. npm install
  3. npm install @leanplum/react-native-sdk
  4. npx react-native link @leanplum/react-native-sdk
  5. Added the following lines in android/app/build.gradle:
implementation project(':@leanplum_react-native-sdk')
implementation "com.leanplum:leanplum-fcm:${LEANPLUM_SDK_VERSION}"
implementation 'com.google.firebase:firebase-messaging:20.1.4'
  1. Added the following lines in onCreate method of MainApplication.java:
// Leanplum setup
Leanplum.setApplicationContext(this);
Parser.parseVariables(this);
//  For session lifecyle tracking.
LeanplumActivityHelper.enableLifecycleCallbacks(this);
  1. Run it with "yarn android" and it starts on the device

@AugustoAleGon
Copy link
Author

This was an Android issue. We can close it.

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

2 participants