react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

Is this Library still Active?? If not, can you cancel this.

Open gibo77 opened this issue 1 year ago • 6 comments

I used this Library and I opened a can of worms!

I followed how to install this Library. There are so many changes that it broke my program. The installation instruction is old and not anymore applicable for use.

Now I have an issue that my program can not see the react native gesture handler.

Can someone tell us if this was working for them?

What react-native-splash-screen version are you using? { "name": "smartdimmer_ios", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@react-native-community/slider": "^4.4.2", "@react-navigation/native": "^6.1.7", "@react-navigation/native-stack": "^6.9.13", "babel": "^6.23.0", "base64-js": "^1.5.1", "buffer": "^6.0.3", "react": "18.2.0", "react-native": "0.72.4", "react-native-gesture-handler": "^2.14.0", "react-native-reanimated": "^3.5.1", "react-native-safe-area-context": "^4.7.2", "react-native-screens": "^3.25.0", "react-native-size-matters": "^0.4.0", "react-native-splash-screen": "^3.3.0", "react-native-udp": "^4.1.7", "react-native-vector-icons": "^10.0.0", "upgrade": "^1.1.0" }, "devDependencies": { "@babel/core": "^7.21.4", "@babel/runtime": "^7.21.0", "@tsconfig/react-native": "^3.0.0", "@types/jest": "^29.5.1", "@types/react": "^18.0.38", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.5.0", "eslint": "8.39.0", "jest": "^29.5.0", "metro-react-native-babel-preset": "^0.76.2", "prettier": "^2.8.8", "react-native-clean-project": "^4.0.1", "react-test-renderer": "18.2.0", "typescript": "^5.0.4" }, "jest": { "preset": "react-native" }, "browser": { "dgram": "react-native-udp" }, "resolutions": { "react-native-gesture-handler": "2.12.1" } }

What platform does your issue occur on? Android

Describe your issue as precisely as possible :

  1. Steps to reproduce the issue or to explain in which case you get the issue Installed the "react-native-splash-screen": "^3.3.0" Did the instructions to change a slew of changes on the Android folders.
  2. Interesting logs Suddenly I got this problem ERROR [react-native-gesture-handler] react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).

Join a screenshot or video of the problem on the simulator or device?

Show us the code you are using?

gibo77 avatar Jan 02 '24 14:01 gibo77

you need a workaround to get this working on the latest version of react-native, like the fact that the new react-native uses koltin, not java, which differs a little in the setup for the android. there are also issues with the structure of didFinishLaunchingWithOptions on ios but having had experience with native development with both kotlin and swift, i managed to find workarounds for both issues and it's working wonderfully on 0.73.1. if you're still having problems, please share your MainActivity.kt and AppDelegate.mm files and perhaps the community will help!

mohshbool avatar Jan 07 '24 15:01 mohshbool

Hi @mohshbool , can you let me know how did you manage to use it in Kotlin for the MainActivity.kt?

package com.myappname
import com.facebook.react.ReactActivity

// import android.os.Bundle;
import org.devio.rn.splashscreen.SplashScreen;

import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate

class MainActivity : ReactActivity() {
  override fun getMainComponentName(): String = "Bottled"

  // below for splashscreen
  override fun onCreate(savedInstanceState: Bundle?) {
    SplashScreen.show(this)
    super.onCreate(null)
  }

  override fun createReactActivityDelegate(): ReactActivityDelegate =
      DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
}

obviously I have added the part

override fun onCreate(savedInstanceState: Bundle?) {
    SplashScreen.show(this)
    super.onCreate(null)
  }

but not sure this is the way to do?

and while at it since you seem to be good with the transition to kotlin, I used to have a function in mainapplication.java for codepush:

 @Override
        protected String getJSBundleFile() {
            return CodePush.getJSBundleFile();
        }

=> how could I have it in the new mainApplication.kt? I added this right before the onCreate function, not sure it's correct:

 override fun getJSBundleFile(): String? {
      return CodePush.getJSBundleFile()
  }

pierroo avatar Feb 07 '24 13:02 pierroo

hello @pierroo. what you have implemented up there with your Kotlin code is correct as long as you're adding the import statement at the top of the file. are you getting any errors?

mohshbool avatar Feb 15 '24 15:02 mohshbool

thank you @mohshbool for replying, actually I had to uncomment the "// import android.os.Bundle;" at the top of the file that was necessary :)

pierroo avatar Feb 15 '24 15:02 pierroo

Facing Same Issue, MainActivity.kt `package com.splashscreenandappiconapp

import android.os.Bundle; import com.facebook.react.ReactActivity import org.devio.rn.splashscreen.SplashScreen; import com.cboy.rn.splashscreen.SplashScreen; import com.facebook.react.ReactActivityDelegate import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled import com.facebook.react.defaults.DefaultReactActivityDelegate

class MainActivity : ReactActivity() { @Override protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this); super.onCreate(savedInstanceState); }

/**

  • Returns the name of the main component registered from JavaScript. This is used to schedule
  • rendering of the component. */ override fun getMainComponentName(): String = "SplashScreenAndAppIconApp"

/**

  • Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
  • which allows you to enable New Architecture with a single boolean flags [fabricEnabled] */ override fun createReactActivityDelegate(): ReactActivityDelegate = DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled) } `

muhammadalizkhan avatar Mar 24 '24 00:03 muhammadalizkhan

the below mentioned changes helped me resolved the issue. main changes I did related to kotlin (react native 0.74 version related is in file MainActivity.kt.

MainActivity.kt

import org.devio.rn.splashscreen.SplashScreen

class MainActivity : ReactActivity() {
  
  override fun getMainComponentName(): String = "main"

  override fun onCreate(savedInstanceState: Bundle?) {
    SplashScreen.show(this)
    setTheme(R.style.AppTheme);
    super.onCreate(null)
  }

android>settings.gradle

Add these lines.

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

android>app>build.gradle

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")


    implementation project(':react-native-splash-screen') // new line added inside dependencies

**_... rest of the code_**

Akash-Rathor avatar Jun 11 '24 15:06 Akash-Rathor