I’m trying to generate an Android build of my project with react-native(npx expo run: android
), but I’m getting some errors. One of them is the one below, I didn’t understand it very well because I received a generic error in the compilation log:
> Task :app:compileDebugJavaWithJavac FAILED
C:Projetosschool-frontendandroidappsrcmainjavabrcomschoolmobileinspellMainApplication.java:65: error: cannot find symbol
ReactFeatureFlags.unstable_useRuntimeSchedulerAlways = false;
^
symbol: variable unstable_useRuntimeSchedulerAlways
location: class ReactFeatureFlags
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainActivity.java:19: error: package R does not exist
setTheme(R.style.AppTheme);
^
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainActivity.java:39: error: cannot find symbol
return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate(
^
symbol: variable BuildConfig
location: class MainActivity
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainApplication.java:29: error: cannot find symbol
return BuildConfig.DEBUG;
^
symbol: variable BuildConfig
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainApplication.java:48: error: cannot find symbol
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
^
symbol: variable BuildConfig
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainApplication.java:53: error: cannot find symbol
return BuildConfig.IS_HERMES_ENABLED;
^
symbol: variable BuildConfig
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainApplication.java:66: error: cannot find symbol
if (!BuildConfig.REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS) {
^
symbol: variable BuildConfig
location: class MainApplication
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainApplication.java:67: error: cannot find symbol
ReactFeatureFlags.unstable_useRuntimeSchedulerAlways = false;
^
symbol: variable unstable_useRuntimeSchedulerAlways
location: class ReactFeatureFlags
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainApplication.java:69: error: cannot find symbol
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
^
symbol: variable BuildConfig
location: class MainApplication
C:Projetosschool-frontendandroidappsrcmainjavaischoolmobileMainApplication.java:73: error: cannot find symbol
if (BuildConfig.DEBUG) {
^
symbol: variable BuildConfig
location: class MainApplication
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
10 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Meu arquivo dentro de ./android/build.grsdle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.22'
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "26.1.10909125"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.4.2'
classpath('com.android.tools.build:gradle:7.4.2')
classpath('com.facebook.react:react-native-gradle-plugin')
}
}
allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
}
google()
mavenCentral()
maven { url 'https://www.jitpack.io' }
maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" }
}
}
- yarn upgrade –latest
- .gradlew clean
- ./gradlew :app:assembleRelease