itinance / react-native-fs

Native filesystem access for react-native
MIT License
4.89k stars 954 forks source link

Could not resolve all files for configuration ':react-native-fs:androidJdkImage'. #1216

Open Kayxue opened 5 months ago

Kayxue commented 5 months ago

I met this build error when running pnpm run android:

Execution failed for task ':react-native-fs:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':react-native-fs:androidJdkImage'.

I have already added those usage to files but it still show this error.

MainApplication.kt (Yeah Idk why it use Kotlin):

package com.audioasistanttest

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> {
          return listOf(
              MainReactPackage(), // <---- add comma
              RNFSPackage() // <---------- add package
          )
        }

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

Setting.gradle:

rootProject.name = 'AudioRecordTest'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/react-native-fs/android')

And implementation project(':react-native-fs') to build.gradle, but I still meet this error, how to solve?

birdofpreyru commented 5 months ago

#1197 — The Future of react-native-fs