В настоящее время я работаю над проектом React Native с использованием Kotlin и столкнулся с некоторыми проблемами в процессе сборки в Android Studio. В частности, я сталкиваюсь с неразрешенной ссылкой: R и неразрешенной ссылкой: ошибки BuildConfig в моих файлах Kotlin.
Версия React Native: 0.74.3
Версия Kotlin: 1.9.23Версия Gradle: 8.6
Версия Android Studio: последняя
мой MainActivity.kt
package com.thediamlaundry.diamapp
import android.os.Build
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 expo.modules.ReactActivityDelegateWrapper
class MainActivity : ReactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
// Set the theme to AppTheme BEFORE onCreate to support
// coloring the background, status bar, and navigation bar.
// This is required for expo-splash-screen.
setTheme(R.style.AppTheme);
super.onCreate(null)
}
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "main"
/**
* 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 {
return ReactActivityDelegateWrapper(
this,
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
object : DefaultReactActivityDelegate(
this,
mainComponentName,
fabricEnabled
){})
}
/**
* Align the back button behavior with Android S
* where moving root activities to background instead of finishing activities.
* @see [url=https://developer.android.com/reference/android/app/Activity#onBackPressed()]onBackPressed[/url]
*/
override fun invokeDefaultOnBackPressed() {
if (Build.VERSION.SDK_INT
Подробнее здесь: [url]https://stackoverflow.com/questions/78782726/unresolved-reference-r-and-buildconfig-in-react-native-android-project-with-kot[/url]
В настоящее время я работаю над проектом React Native с использованием Kotlin и столкнулся с некоторыми проблемами в процессе сборки в Android Studio. В частности, я сталкиваюсь с неразрешенной ссылкой: R и неразрешенной ссылкой: ошибки BuildConfig в моих файлах Kotlin. Версия React Native: 0.74.3 Версия Kotlin: 1.9.23Версия Gradle: 8.6 Версия Android Studio: последняя мой MainActivity.kt [code]
class MainActivity : ReactActivity() { override fun onCreate(savedInstanceState: Bundle?) { // Set the theme to AppTheme BEFORE onCreate to support // coloring the background, status bar, and navigation bar. // This is required for expo-splash-screen. setTheme(R.style.AppTheme); super.onCreate(null) }
/** * Returns the name of the main component registered from JavaScript. This is used to schedule * rendering of the component. */ override fun getMainComponentName(): String = "main"
/** * 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 { return ReactActivityDelegateWrapper( this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, object : DefaultReactActivityDelegate( this, mainComponentName, fabricEnabled ){}) }
/** * Align the back button behavior with Android S * where moving root activities to background instead of finishing activities. * @see [url=https://developer.android.com/reference/android/app/Activity#onBackPressed()]onBackPressed[/url] */ override fun invokeDefaultOnBackPressed() { if (Build.VERSION.SDK_INT