8
C:\Users\Alex\testing\firsttry>react-native run-android
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Configure project :react-native-splash-screen
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation' and 'testApi'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Task :app:compileDebugJavaWithJavac
C:\Users\Alex\testing\firsttry\android\app\src\main\java\com\firsttry\MainApplication.java:5: error: cannot find symbol
import com.facebook.react.ReactApplication;
                         ^
symbol:   class ReactApplication
location: package com.facebook.react
C:\Users\Alex\testing\firsttry\android\app\src\main\java\com\firsttry\MainApplication.java:9: error: cannot find symbol
import com.facebook.react.ReactNativeHost;
                         ^
  symbol:   class ReactNativeHost
  location: package com.facebook.react
C:\Users\Alex\testing\firsttry\android\app\src\main\java\com\firsttry\MainApplication.java:17: error: cannot find symbolpublic class MainApplication extends Application implements ReactApplication {
                                                        ^
  symbol: class ReactApplication
C:\Users\Alex\testing\firsttry\android\app\src\main\java\com\firsttry\MainApplication.java:19: error: cannot find symbol  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
                ^
  symbol:   class ReactNativeHost
  location: class MainApplication
C:\Users\Alex\testing\firsttry\android\app\src\main\java\com\firsttry\MainActivity.java:7: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity
       ^
C:\Users\Alex\testing\firsttry\android\app\src\main\java\com\firsttry\MainApplication.java:19: error: cannot find symbol  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
                                                       ^
  symbol:   class ReactNativeHost
  location: class MainApplication
C:\Users\Alex\testing\firsttry\android\app\src\main\java\com\firsttry\MainApplication.java:41: error: method does not override or implement a method from a supertype
 @Override
 ^
8 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.

I am pretty sure I did not touch anything in the MainApplication.java & MainActivity.java And I am running it on a virtual Android phone.

C:\Users\Alex\testing\firsttry>npm -v 6.4.1

C:\Users\Alex\testing\firsttry>react-native -v react-native-cli: 2.0.1 react-native: 0.57.1

Can anyone help me with this problem/error? Thank you so much!

Update 1: on 25/11/2018 (GMT+8)

Solved WARNING of obsolete by replacing all 'compile' to 'implementation'

More detail of the error Unresolved Dependencies ./node_modules/react-native-splash-screen/android/build.gradle

Please click on the link to view the image.

build.gradle of react-native-splash-screen/android

Android Studio SYNC Error

Update 2: I did something by going to Android Studio > Gradle, Untick Offline Work

Now I got the same error of cannot find symbol but different error show in Android Studio.

Cannot find symbol CMD

Android studio cannot find symbol

Error of app:compileDebugJavaWithJavac error

Alex Chong
  • 341
  • 2
  • 5
  • 9
  • read the error message Alex. You are using compile instead of implementation, and testCompile instead of testImplementation – eli Nov 24 '18 at 14:16
  • 1
    @eLi Actually if you read it more carefully, you would see that what you are referring to is not an error message, it's a warning. – romin21 Nov 24 '18 at 15:26
  • Try opening your React Native project in Android Studio and let it build. This will also set the `ANDROID_HOME` environment variable. Afterwards, close the server and run `react-native run-android`. – romin21 Nov 24 '18 at 15:32
  • Thank you @eLi for the suggestion. I changed the all 'compile' to 'implementation', it solves the obsolete warning. – Alex Chong Nov 25 '18 at 05:33
  • @romin21 , AndroidStudio found an error for 'Unresolved dependencies' of /react-native-splash-screen/android/build.grade Unable to resolve dependency for ':react-native-splash-screen@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12. Disable offline mode and sync project Open File Show Details I will edit the thread and show more detail of the error. – Alex Chong Nov 25 '18 at 05:33
  • 1
    Update 2: I did something by going to Android Studio > Settings > Build, Exeuction, Deplyoment, Gradle, Untick Offline Work – Alex Chong Nov 25 '18 at 06:12
  • Glad you were able to resolve the issue @AlexChong. – romin21 Nov 25 '18 at 15:23
  • No @romin21, the problem of cannot find symbol is still there. I only manage to solve the obsolete warning. Do you have any clue on how can I solve the problem? Besides that, I am not able to create a clean Expo project. Is it the same problem causing another error like this? More details please visit this link> https://stackoverflow.com/questions/53456639/error-spawn-cmd-enoent-in-expo-init-project – Alex Chong Nov 26 '18 at 03:24
  • I have the same error and cannot figure out a way to solve it. Have you found any solution yet? @AlexChong :) – David Sundström Dec 05 '18 at 08:34

1 Answers1

0

First: install all dependencies using yarn or npm;

Second: use the code below to link native dependencies on iOS and Android native code;

  • react-native link

Third: this error can occur because your RN version is different from Android's build.gradle version. When you create a react-native app probably create an android app like:

android/app/build.gradle

  • implementation "com.facebook.react:react-native:+"

So, inspect your node_modules folder, look for the react-native folder and look for a folder with a number, that numbers are the react-native version. For me it's 0.64.0 then update android/app/build.gradle:

  • implementation "com.facebook.react:react-native:0.64.0"

It's All.