MainActivityDelegate cannot be converted to Activity SplashScreen.show(this);
See original GitHub issueRun react-native info
in your project and share the content.
- Node : 16.17.0
- Yarn : 1.22.19
- react : 18.1.0
- react-native : 0.70.0
What react-native-splash-screen
version are you using?
- “react-native-splash-screen”: “^3.3.0”, What platform does your issue occur on? (Android/iOS/Both)
- just checked Android only.
Describe your issue as precisely as possible :
-
Steps to reproduce the issue or to explain in which case you get the issue
-
Interesting
logs
error: incompatible types: MainActivityDelegate cannot be converted to Activity
SplashScreen.show(this);
more details of error
BUILD FAILED in 12s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/minjiseo/buyaladdin/BRApp/BuyaladdinApp/android/app/src/main/java/com/aladdin/com/aladdin/MainActivity.java:59: error: incompatible types: MainActivityDelegate cannot be converted to Activity
SplashScreen.show(this);
^
Note: /Users/minjiseo/myFolder/MyAppName/AppName/android/app/src/debug/java/com/AppName/com/AppName/ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Join a screenshot or video of the problem on the simulator or device?
Show us the code you are using?
followed the guide settings.gradle
, build.gradle
, App.tsx
and set all done.
MainActivity.java
package com.aladdin.com.aladdin;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.lockincomp.liappagent.LiappAgent;
import org.devio.rn.splashscreen.SplashScreen;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
...my other codes
super.onCreate(null);
// super.onCreate(savedInstanceState); <- this also tried but not working
}
I don’t know why I’m having this kind of error. because of React Native 0.7 version error? or what,please help…
Issue Analytics
- State:
- Created a year ago
- Comments:12
Top Results From Across the Web
react native - MainActivityDelegate cannot be converted to ...
Error. MainActivityDelegate cannot be converted to Activity SplashScreen.show(this);. MainActivity.java. ` package com.ala.
Read more >MainApplication cannot be converted to Activity · Issue #461 ...
Hi, you might want to add the SplashScreen.show(this); in MainActivity.java instead of MainApplication.java . Just like this: Screen Shot 2020- ...
Read more >Splash Screen in Android App — React Native
Step 1: Create an activity. Create a new activity which will be responsible for forwarding to main activity. In android/app/src/main/java/[packageName] create ...
Read more >How to integrate a splash screen in React Native with ...
In this shot, we will learn how to integrate splash screens in React Native for both Android and iOS. Installation. First, let's create...
Read more >react-native-splash-screen - npm
A splash screen API for react-native which can programatically hide and show the splash screen. Works on iOS and Android.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think you should move
onCreate
totally. I mean delete it in nested class and keep only in top level. I went event a little bit forward and kept only main class just to check and it worksFresh RN application MainActivity.java looks like so now:
Still have the issue
incompatible types: MainActivityDelegate cannot be converted to Activity SplashScreen.show(this);
method show goes from here
and it take Activity type, while
this
in MainActivity isMainActivityDelegate
If we move
onCreate
outside ofMainActivityDelegate
to the very top class application will be built successfully