0
votes

The code doesn't run in my device, please help...!

G:\React\blawblaW>react-native run-android
info JS server already running.
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...

Task :app:compileDebugJavaWithJavac FAILED

G:\React\blawblaW\android\app\src\main\java\com\blawblaw\MainActivity.java:23: error: class, interface, or enum expected
  protected ReactActivityDelegate createReactActivityDelegate() {
            ^
G:\React\blawblaW\android\app\src\main\java\com\blawblaw\MainActivity.java:26: error: class, interface, or enum expected
      protected ReactRootView createRootView() {
                ^
G:\React\blawblaW\android\app\src\main\java\com\blawblaw\MainActivity.java:28: error: class, interface, or enum expected
      }
      ^
G:\React\blawblaW\android\app\src\main\java\com\blawblaw\MainActivity.java:30: error: class, interface, or enum expected
  }
  ^
4 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.

  • 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 1s 24 actionable tasks: 1 executed, 23 up-to-date error Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

1
As the error says do you have emulator running.Thakur Karthik
yes I'm sure that my phone is connectedmustafa-hsz
Can you open another console and run command adb devices and see if it lists your device there?blaz
@blaz List of devices attached ce041714519f6c990d device yes It shows my devicemustafa-hsz
Run adb unistall [package.name] Replace package name with your package name for example com.test.app etc. It may have a previously installed version lying around somewhere.JRK

1 Answers

0
votes

Eject your app using react-native CLI. from your app root run this commands

react-native eject

and then link your package

react-native link

Ejecting app will reset your cache and other linked dependencies.