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

React Native 0.73 Integration

Open BenHurMartins opened this issue 1 year ago • 30 comments

This is not an issue, only a heads up, considering there are not new updates on this library and until we get the new README.

I had some issues implementing splash screen on the newest react native version, using kotlin and to update the AppDelegate.mm. So after some digging and fixing, I want to share a boilerplate I created for general purposes and it also includes the splash screen implementation.

To use it:

npx react-native init MyApp --template react-native-template-ts-redux-navigation

The GitHub Repo

BenHurMartins avatar Dec 13 '23 17:12 BenHurMartins

Could you elaborate on the setps required to implement this on an existing React Native 0.73 project?

didac-wh avatar Dec 14 '23 17:12 didac-wh

Now projects come with Kotlin. Instead of mainActivity.java there is mainActivity.kt file. I think he's talking about this problem

ahmetcangurel avatar Dec 20 '23 21:12 ahmetcangurel

MainActivity.kt

import org.devio.rn.splashscreen.SplashScreen

init {
    SplashScreen.show(this)
  }

TreasWallet avatar Dec 23 '23 12:12 TreasWallet

Its working with Emulator only. Not working with Physical Device. App crashed

vishalsohani27 avatar Dec 23 '23 15:12 vishalsohani27

same Any progress?

pipo151086 avatar Dec 27 '23 16:12 pipo151086

Same issue

dgreasi avatar Dec 28 '23 10:12 dgreasi

The problem is with the release APK in a physical device!

is there anyone checking this issue?

because a found this other package: https://github.com/zoontek/react-native-bootsplash

it looks that this package is no longer being mainteined!!!!

pipo151086 avatar Dec 28 '23 14:12 pipo151086

I moved with react native bootsplash, its working

On Thu, 28 Dec 2023, 8:03 pm pipo151086, @.***> wrote:

The problem is with the release APK in a physical device!

is there anyone checking this issue?

because a found this other package: https://github.com/zoontek/react-native-bootsplash

it looks that this package is no longer being mainteined!!!!

— Reply to this email directly, view it on GitHub https://github.com/crazycodeboy/react-native-splash-screen/issues/634#issuecomment-1871230221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR5EGHJE2M6GBQXZJ4V637TYLV7MRAVCNFSM6AAAAABATQZBUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZRGIZTAMRSGE . You are receiving this because you commented.Message ID: @.***>

vishalsohani27 avatar Dec 28 '23 16:12 vishalsohani27

same issue

jotilohana avatar Jan 02 '24 11:01 jotilohana

This is not an issue, only a heads up, considering there are not new updates on this library and until we get the new README.

I had some issues implementing splash screen on the newest react native version, using kotlin and to update the AppDelegate.mm. So after some digging and fixing, I want to share a boilerplate I created for general purposes and it also includes the splash screen implementation.

To use it:

npx react-native init MyApp --template react-native-template-ts-redux-navigation

The GitHub Repo

This worked for me, thanks 😊

tuiza avatar Jan 03 '24 13:01 tuiza

MainActivity.kt

import org.devio.rn.splashscreen.SplashScreen

class MainActivity : ReactActivity() { init { SplashScreen.show(this) }

/**

  • Other code */ }

chaudev avatar Jan 15 '24 12:01 chaudev

This is not an issue, only a heads up, considering there are not new updates on this library and until we get the new README.

I had some issues implementing splash screen on the newest react native version, using kotlin and to update the AppDelegate.mm. So after some digging and fixing, I want to share a boilerplate I created for general purposes and it also includes the splash screen implementation.

To use it:

npx react-native init MyApp --template react-native-template-ts-redux-navigation

The GitHub Repo

It worked for me, just changing from java to kotlin syntax like below

// ...
import org.devio.rn.splashscreen.SplashScreen

class MainActivity : ReactActivity() {

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

mannoeu avatar Jan 15 '24 19:01 mannoeu

@mannoeu & @chaudev Even with the mode=release APK?

pipo151086 avatar Jan 15 '24 20:01 pipo151086

mode=release APK

Yep, its works for me

mannoeu avatar Jan 16 '24 13:01 mannoeu

I'm surprised onCreate worked for you, it caused a build error for me:

> Task :app:compileDevtestnetDebugKotlin FAILED
e: file:///<redacted>/android/app/src/main/java/com/<redacted>/app/android/MainActivity.kt:26:3 'onCreate' overrides nothing

Using init however worked.

init {
  SplashScreen.show(this)
}

dominictobias avatar Jan 19 '24 17:01 dominictobias

I'm surprised onCreate worked for you, it caused a build error for me:

> Task :app:compileDevtestnetDebugKotlin FAILED
e: file:///<redacted>/android/app/src/main/java/com/<redacted>/app/android/MainActivity.kt:26:3 'onCreate' overrides nothing

Using init however worked.

init {
  SplashScreen.show(this)
}

Strange, i dont know about this

mannoeu avatar Jan 20 '24 00:01 mannoeu

IOS crashing spalsh how to solve

city0666 avatar Jan 30 '24 08:01 city0666

@mannoeu where did you added this block??

init {
  SplashScreen.show(this)
}

luis-cicada avatar Feb 05 '24 17:02 luis-cicada

@mannoeu where did you added this block??

init {
  SplashScreen.show(this)
}

I only rename from android/app/src/main/java/com/app-name/MainActivity.java to android/app/src/main/java/com/app-name/MainActivity.kt and fixing sintax from this

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

to this

// ...
import org.devio.rn.splashscreen.SplashScreen

class MainActivity : ReactActivity() {

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

But, some people commented above that this causes an error for them. They suggested using the excerpt

// ...
import org.devio.rn.splashscreen.SplashScreen

class MainActivity : ReactActivity() {

  // ...
  init {
    SplashScreen.show(this)
  }
  // ...
}

In my case it was not necessary. Only the syntax adjustment worked.

mannoeu avatar Feb 05 '24 18:02 mannoeu

@mannoeu thanks brother! It did work with

// ...
import org.devio.rn.splashscreen.SplashScreen

class MainActivity : ReactActivity() {

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

luis-cicada avatar Feb 06 '24 16:02 luis-cicada

Hi, I only saw all the messages now, like 2 months later, well I didn't try on physical device, so I can't tell.

BenHurMartins avatar Feb 08 '24 17:02 BenHurMartins

@BenHurMartins I just tried on physical device and it is working fine!

luis-cicada avatar Feb 08 '24 18:02 luis-cicada

awesome, good to know @luis-cicada , thanks. Just to be sure, did you tried the boilerplate I shared or another solution proposed here? and, iOS or android?

BenHurMartins avatar Feb 08 '24 18:02 BenHurMartins

anyone share me full guide of MainApplication.Kt and MainActivity.kt files Code? for me init { SplashScreen.show(this) } and
override fun onCreate(savedInstanceState: Bundle?) { SplashScreen.show(this); super.onCreate(null) }

both are not working app getting crashed while opening

Creativestarjsp avatar Feb 16 '24 04:02 Creativestarjsp

This is not an issue, only a heads up, considering there are not new updates on this library and until we get the new README.

I had some issues implementing splash screen on the newest react native version, using kotlin and to update the AppDelegate.mm. So after some digging and fixing, I want to share a boilerplate I created for general purposes and it also includes the splash screen implementation.

To use it:

npx react-native init MyApp --template react-native-template-ts-redux-navigation

The GitHub Repo

@Creativestarjsp you can follow this template

tuiza avatar Feb 16 '24 11:02 tuiza

@luis-cicada still work with you because I get this error What went wrong: Execution failed for task ':react-native-splash-screen:writeDebugAarMetadata'.

Failed to create parent directory '....../node_modules/react-native-splash-screen/android/build' when creating directory '...../node_modules/react-native-splash-screen/android/build/intermediates/aar_metadata/debug'

FaresHamel avatar Feb 23 '24 22:02 FaresHamel

@BenHurMartins thanks pal! It works perfectly!!

aditya-464 avatar Mar 14 '24 15:03 aditya-464

@BenHurMartins Thanks bro!

It helped me a lot!

deivyrene avatar Apr 10 '24 12:04 deivyrene

For those like me that has MainActivity.kt with no override of the function onCreate at all, maybe this would help.

The lines you need to add exactly are these, in your MainActivity.kt:

After all imports you have already, add these two lines:

import android.os.Bundle; // Avoid Bundle crashing
import org.devio.rn.splashscreen.SplashScreen // react-native-splash-screen lib

Then, no mather where, the rest:

class MainActivity : ReactActivity() {
/* the rest of the code */
 override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(null)
      SplashScreen.show(this)
  }
}

This is working for me using react-native 0.74.

Hope this help someone still blocked using this library in newer version on RN.

bastiantowers avatar Jun 21 '24 16:06 bastiantowers

For those like me that has MainActivity.kt with no override of the function onCreate at all, maybe this would help.

The lines you need to add exactly are these, in your MainActivity.kt:

After all imports you have already, add these two lines:

import android.os.Bundle; // Avoid Bundle crashing
import org.devio.rn.splashscreen.SplashScreen // react-native-splash-screen lib

Then, no mather where, the rest:

class MainActivity : ReactActivity() {
/* the rest of the code */
 override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(null)
      SplashScreen.show(this)
  }
}

This is working for me using react-native 0.74.

Hope this help someone still blocked using this library in newer version on RN.

thanks @bastiantowers.... you saved me....!!!

Mohamed-akmal0 avatar Jul 05 '24 13:07 Mohamed-akmal0