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 now use kotlin not java #638

Closed
omarker09 opened this issue Feb 16, 2024 · 10 comments
Closed

React native now use kotlin not java #638

omarker09 opened this issue Feb 16, 2024 · 10 comments

Comments

@omarker09
Copy link

omarker09 commented Feb 16, 2024

I cant include splash screen into react native project, with
old java code becuase my MainApplication file is kotlin not java !!

@LongDuong1996
Copy link

LongDuong1996 commented Feb 19, 2024

package com.amessoeurs

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

class MainActivity : ReactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
SplashScreen.show(this) // here
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 = "amessoeurs"

/**

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

Change file MainActivity.kt.
Work for me!

@ivandjordjevicidjdev
Copy link

I have the same problem. I added SplashScreen.show(this) before super.onCreate(savedInstanceState) and it still doesn't work.

@Nziranziza
Copy link

same issue

@omarker09 omarker09 reopened this Feb 20, 2024
@Nziranziza
Copy link

That's Why I will quit React native because this framework doesn't have any Official support it based on open source community I'm trying now to learn kotlin and work with android studio no more React native

Let's give it time the owner will eventually have to update to support Kotlin. Again Kotlin isn't an alternative to React Native maybe checkout Flutter instead

@AkilUnik
Copy link

package com.turtlebuddy
import android.os.Bundle;
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
// react-native-splash-screen >= 0.3.1

import org.devio.rn.splashscreen.SplashScreen;

class MainActivity : ReactActivity() {

/**

  • Returns the name of the main component registered from JavaScript. This is used to schedule
  • rendering of the component.
    */
    override fun onCreate(savedInstanceState: Bundle?) {
    SplashScreen.show(this);
    super.onCreate(null)
    }

override fun getMainComponentName(): String = "turtleBuddy"

/**

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

@santimone
Copy link

package com.turtlebuddy import android.os.Bundle; import com.facebook.react.ReactActivity import com.facebook.react.ReactActivityDelegate import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled import com.facebook.react.defaults.DefaultReactActivityDelegate // react-native-splash-screen >= 0.3.1

import org.devio.rn.splashscreen.SplashScreen;

class MainActivity : ReactActivity() {

/**

  • Returns the name of the main component registered from JavaScript. This is used to schedule
  • rendering of the component.
    */
    override fun onCreate(savedInstanceState: Bundle?) {
    SplashScreen.show(this);
    super.onCreate(null)
    }

override fun getMainComponentName(): String = "turtleBuddy"

/**

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

works like a charm, thanks!

@omarker09 omarker09 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2024
@muhammadalizkhan
Copy link

Its Not Working;
package com.splashscreenandappiconapp

import android.os.Bundle;
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate

import org.devio.rn.splashscreen.SplashScreen;

class MainActivity : ReactActivity() {

/**

Returns the name of the main component registered from JavaScript. This is used to schedule
rendering of the component.
*/
override fun onCreate(savedInstanceState: Bundle?) {
SplashScreen.show(this);
super.onCreate(null)
}
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)
}

@bkvaiude
Copy link

Following code worked for me

override fun createReactActivityDelegate(): ReactActivityDelegate {
      SplashScreen.show(this)
      return DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
  }

@shariqahmed525
Copy link

Following code worked for me

override fun createReactActivityDelegate(): ReactActivityDelegate {
      SplashScreen.show(this)
      return DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
  }

Thanks, it worked for me @bkvaiude

@i-ked-ii
Copy link

Following code worked for me

override fun createReactActivityDelegate(): ReactActivityDelegate {
      SplashScreen.show(this)
      return DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
  }

Thanks, it worked.

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

10 participants