React Native: CLI fails to install app on android emulator

A few months ago, I started a react-native project on my windows pc. At some point, I pushed it all to my github repository, and intended to continue working on it on my linux laptop. However, it never worked on my linux system.

The Issue

When running npm run android, the installation of the app on my android emulator fails. However, that is only the case when executing it on my project repository. If I use npx react-native init ALT_PROJECT to setup a new react-native project, and run the command there, it works without issue.

Things I have verified / already tested

  • My code has no issues, as copying all the code files to a new react-native project does not hinder npm run android in installing the app.
  • Updating react-native from 0.72.5 -> 0.73.2 did not change anything
  • Running chmod 755 android/gradlew allowed for installation to start, but it still fails. Error changed from
error Failed to install the app. Command failed with EACCES: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
spawn ./gradlew EACCES.

to

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
e: file:///home/oliver/Documents/Coding/testTodoApp2/alt/frontend/project/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt:391:46 Unresolved reference: attr

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-screens:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 57s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
e: file:///home/oliver/Documents/Coding/testTodoApp2/alt/frontend/project/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt:391:46 Unresolved reference: attr FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native-screens:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details
  • Making sure $ANDROID_HOME is set
  • Making sure $PATH includes $ANDROID_HOME/emulator and $ANDROID_HOME/platform-tools
  • Running npx react-native doctor gives me only a single error, that Android Studio couldn’t be found. I have, however, read that that always happens when Android Studio hasn’t been installed in the default directory, and that it does not affect functionality (Since I DO have Android Studio installed)

Tech Details

  • OS: Linux Mint 20.3

Please help me out, I have sunk a dozen hours into this specific problem, and I just don’t know how to continue. Tell me if you need more information. Thank you.

Leave a Comment