Closed name-industry closed 7 years ago
You need to import the SplashScreen
class in MainActivity
. Read over the example file. Especially right here: https://github.com/mehcode/rn-splash-screen/blob/master/example/android/app/src/main/java/com/mehcode/reactnative/splashscreen/example/MainActivity.java#L9
Oh wow., yes. I absolutely missed that. ( not sure how, mind you... ) Works perfectly now. Thanks for the really fast help and thanks for making the component.
:)
@mehcode this is my index.android.js file....error says unexpected token at 17:20
import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; import SplashScreen from 'rn-splash-screen'
export default class animaltune extends Component { componentDidMount:function() { //HERE IS THE ERROR SplashScreen.hide(); }, render() { return (
);
} }
const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });
AppRegistry.registerComponent('animaltune', () => animaltune);
i am new to RN, so just want to use splashscreen.
@mehcode this is my index.android.js file....error says unexpected token at 17:20
import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from 'react-native'; import SplashScreen from 'rn-splash-screen'
export default class animaltune extends Component { componentDidMount:function() { //HERE IS THE ERROR SplashScreen.hide(); }, render() { return (
Welcome to React Native!
To get started, edit index.android.js
Double tap R on your keyboard to reload,{'\n'} Shake or press menu button for dev menu
); } }
const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });
AppRegistry.registerComponent('animaltune', () => animaltune);
i am new to RN, so just want to use splashscreen.
oops! replace your componentDidMount:function with componentDidMount. you dont need to use function keyword.
In MainActivity.java try to replace import file (import org.devio.rn.splashscreen.SplashScreen;) instead of (import org.devio.rn.splashscreen.SplashScreenReactPackage;)
its working..
For those still having issues, open up Android Studio and run it from there. This makes it much easier to see the logs, specifically the error causing the crash.
For me, my splash screen image was too large and I needed to remove packages.add(new SplashScreenReactPackage());
from the MainApplication.java file because it said it had already loaded it. 🤷🏼♂️
Im not well versed in JAVA, attempting to use the component and currently stuck at :
rn-splash-screen ^4.0.1 react-native v : 46 link was positive for both IOS and Android building from terminal
error: cannot find symbol SplashScreen.show(this); ^ symbol: variable SplashScreen location: class MainActivity
In the MainActivity.java file are included :
From a prior closed issue someone else had this issue but solved it via the importing of -> android.content.bundle. Sadly that didnt work for me.
In the MainApplication.java file are included :
and is triggered in :
In the MainActivity.java file the create call was added ( since its now located in the Application file as well ) and looks like this:
Last, its also correctly listed under dependancies in graddle
Any hints as to what I'm doing wrong would be greatly appreciated. Works perfect on the IOS side of things. I'm sure its something super small that I managed to mistake.