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

How integrate with react-native use Kotlin (RN: 0.73.0) instead of Java for Android? #1214

Open
huynhttdev opened this issue Dec 7, 2023 · 5 comments

Comments

@huynhttdev
Copy link

I can integrate react-native-fs with react-native project because my project uses Kotlin instead of Java. I can not find any guide for this.

@huynhttdev huynhttdev changed the title How integrate with react-native use Kotlin instead of Java for Android? How integrate with react-native use Kotlin (RN: 0.73.0) instead of Java for Android? Dec 7, 2023
@bosz
Copy link

bosz commented Dec 9, 2023

I'm facing the same issue. Is there a solution for this?

@vikaskumar122232
Copy link

I'm also. facing the same issue

@birdofpreyru
Copy link

birdofpreyru commented Dec 11, 2023

@nvacheishvili
Copy link

package com.mobileapp

import android.app.Application
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactHost
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.flipper.ReactNativeFlipper
import com.facebook.soloader.SoLoader
import com.rnfs.RNFSPackage

class MainApplication : Application(), ReactApplication {

  override val reactNativeHost: ReactNativeHost =
      object : DefaultReactNativeHost(this) {
        override fun getPackages(): List<ReactPackage> {
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          //ADD THE FOLLOWING LINES 
          val packages = PackageList(this).packages
          // Manually add packages that cannot be autolinked
          packages.add(RNFSPackage()) // Corrected instantiation of RNFSPackage
          return PackageList(this).packages
        }

        override fun getJSMainModuleName(): String = "index"

        override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

        override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
        override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
      }

  override val reactHost: ReactHost
    get() = getDefaultReactHost(this.applicationContext, reactNativeHost)

  override fun onCreate() {
    super.onCreate()
    SoLoader.init(this, false)
    if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
      // If you opted-in for the New Architecture, we load the native entry point for this app.
      load()
    }
    ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
  }
}

@birdofpreyru
Copy link

🍺🤣🍿

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

5 participants