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

Android Import not working in MainActivity.java #204

Closed
kobagapu opened this issue Feb 8, 2021 · 21 comments
Closed

Android Import not working in MainActivity.java #204

kobagapu opened this issue Feb 8, 2021 · 21 comments
Labels
bad issue template Issue template hasn't been respected

Comments

@kobagapu
Copy link

kobagapu commented Feb 8, 2021

import com.zoontek.rnbootsplash.RNBootSplash;
IOS Working fine
Screenshot 2021-02-08 at 3 17 04 PM

@tomLadder
Copy link

I have the same issue.

@maxhaider
Copy link

same here 😔

@zoontek
Copy link
Owner

zoontek commented Feb 8, 2021

@kobagapu @tomLadder @maxhaider Details please? Which version?

@zoontek zoontek added the bad issue template Issue template hasn't been respected label Feb 8, 2021
@maxhaider
Copy link

@zoontek
After installed the latest version (3.1.3) the import in MainActivity.java stopped working.
image
Downgrading the Version to 3.1.0 also didn't help.

Versions:
node: v12.14.1
react-native-bootsplash: v3.1.3 / 3.1.2 / 3.1.0

@zoontek
Copy link
Owner

zoontek commented Feb 9, 2021

@maxhaider Did you do a Gradle sync / a cache clean?

@maxhaider
Copy link

yes

@zoontek
Copy link
Owner

zoontek commented Feb 9, 2021

@maxhaider Are you opening Android studio on the /android directory (not the root one!)

@maxhaider
Copy link

yes of course x)

@zoontek
Copy link
Owner

zoontek commented Feb 9, 2021

@maxhaider I said that because I just tried it with a fresh project (RN 0.63.4, RN-bootsplash 3.1.3) and everything went fine.

Screenshot 2021-02-09 at 09 15 53

Screenshot 2021-02-09 at 09 15 30

@zoontek
Copy link
Owner

zoontek commented Feb 9, 2021

After installed the latest version (3.1.3) the import in MainActivity.java stopped working.
Downgrading the Version to 3.1.0 also didn't help.

If it worked before the rollback and as the dependencies from npm doesn't change, this cannot be related to the lib.
Try using https://github.com/pmadruga/react-native-clean-project

@maxhaider
Copy link

🤔
I cloned an existing one and installed the node modules there.

Just ran react-native-clean-project, it sadly didn't solve the problem.

@zoontek
Copy link
Owner

zoontek commented Feb 9, 2021

@maxhaider The issue is probably with the cloned project then. Which RN does it use?

@maxhaider
Copy link

v0.63.4

@zoontek
Copy link
Owner

zoontek commented Feb 9, 2021

Try with a fresh project and compare it to this existing project then.

@maxhaider
Copy link

maxhaider commented Feb 10, 2021

Update:
After manually linking the lib I could finally build the project.

The problem is, the splashscreen doesn't disappear now.
If i don't call RNBootSplash.init, it works just fine (but without the splashscreen of course)

edit:
When trying to call RNBootSplash.hide the following error occurs:
[TypeError: null is not an object (evaluating 'NativeModule.hide')]

@zoontek
Copy link
Owner

zoontek commented Feb 10, 2021

Update:
After manually linking the lib I could finally build the project.

The problem is, the splashscreen doesn't disappear now.
If i don't call RNBootSplash.init, it works just fine (but without the splashscreen of course)

edit:
When trying to call RNBootSplash.hide the following error occurs:
[TypeError: null is not an object (evaluating 'NativeModule.hide')]

The module seems not being linked. Something is wrong in your (auto)linking config

@adapptor-kurt
Copy link

I'm having the same problem in 3.1.4, and could fix it by adding the manual linking config to settings.gradle:

include ':react-native-bootsplash'
project(':react-native-bootsplash').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-bootsplash/android')

This project has yarn workspaces, and some extra resolver config in metro.config.js to find dependencies in other places, but I'd be surprised if that's the cause. We have many other RN packages and this is the only one which doesn't autolink correctly on Android. RN does add new RNBootSplashPackage() to PackageList, but just not the settings.gradle config. Autolinking works fine for iOS.

@zoontek
Copy link
Owner

zoontek commented Feb 16, 2021

@adapptor-kurt Did it worked on previous versions? And did it continue to happen when your rollback?

This might be related to a change in react-native-cli: https://github.com/react-native-community/cli

I need to investigate, but I cannot reproduce it with a clean project.

@adapptor-kurt
Copy link

@zoontek it seems to have resolved itself now. I have been switching branches so it's difficult to know what fixed it, but I would recommend anyone having this problem try an Invalidate Caches/Restart in Android Studio and/or a git clean.

@zoontek
Copy link
Owner

zoontek commented Feb 23, 2021

I'm closing this since it seems impossible to reproduce.

@zoontek zoontek closed this as completed Feb 23, 2021
@AlixH
Copy link

AlixH commented Sep 27, 2022

I'm having the same problem in 3.1.4, and could fix it by adding the manual linking config to settings.gradle:

include ':react-native-bootsplash'
project(':react-native-bootsplash').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-bootsplash/android')

This project has yarn workspaces, and some extra resolver config in metro.config.js to find dependencies in other places, but I'd be surprised if that's the cause. We have many other RN packages and this is the only one which doesn't autolink correctly on Android. RN does add new RNBootSplashPackage() to PackageList, but just not the settings.gradle config. Autolinking works fine for iOS.

With version 4.3.2, I encounter the same issue. Indeed, just adding the config in settings.gradle solved the problem. Doing the whole manual linking process causes a package declaration duplication error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad issue template Issue template hasn't been respected
Projects
None yet
Development

No branches or pull requests

6 participants