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

React Native 0.73 Integration #634

Open
BenHurMartins opened this issue Dec 13, 2023 · 30 comments
Open

React Native 0.73 Integration #634

BenHurMartins opened this issue Dec 13, 2023 · 30 comments

Comments

@BenHurMartins
Copy link

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

@didac-wh
Copy link

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

@ahmetcangurel
Copy link

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

@TreasWallet
Copy link

MainActivity.kt

import org.devio.rn.splashscreen.SplashScreen

init {
    SplashScreen.show(this)
  }

@vishalsohani27
Copy link

vishalsohani27 commented Dec 23, 2023

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

@pipo151086
Copy link

pipo151086 commented Dec 27, 2023

same Any progress?

@dgreasi
Copy link

dgreasi commented Dec 28, 2023

Same issue

@pipo151086
Copy link

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!!!!

@vishalsohani27
Copy link

vishalsohani27 commented Dec 28, 2023 via email

@jotilohana
Copy link

same issue

@tuiza
Copy link

tuiza commented Jan 3, 2024

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 😊

@chaudev
Copy link

chaudev commented Jan 15, 2024

MainActivity.kt

import org.devio.rn.splashscreen.SplashScreen

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

/**

  • Other code
    */
    }

@mannoeu
Copy link

mannoeu commented Jan 15, 2024

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);
  }
  // ...
}

@pipo151086
Copy link

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

@mannoeu
Copy link

mannoeu commented Jan 16, 2024

mode=release APK

Yep, its works for me

@sekoyo
Copy link

sekoyo commented Jan 19, 2024

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)
}

@mannoeu
Copy link

mannoeu commented Jan 20, 2024

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

@city0666
Copy link

IOS crashing spalsh how to solve

@luis-cicada
Copy link

@mannoeu where did you added this block??

init {
  SplashScreen.show(this)
}

@mannoeu
Copy link

mannoeu commented Feb 5, 2024

@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.

@luis-cicada
Copy link

luis-cicada commented Feb 6, 2024

@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);
  }
  // ...
}

@BenHurMartins
Copy link
Author

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.

@luis-cicada
Copy link

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

@BenHurMartins
Copy link
Author

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?

@Creativestarjsp
Copy link

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

@tuiza
Copy link

tuiza commented Feb 16, 2024

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

@FaresHamel
Copy link

@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'

@aditya-464
Copy link

@BenHurMartins thanks pal! It works perfectly!!

@deivyrene
Copy link

@BenHurMartins Thanks bro!

It helped me a lot!

@bastiantowers
Copy link

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.

@Mohamed-akmal0
Copy link

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....!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests