Unable to compile on Android. Giving "error: cannot find symbol"
See original GitHub issueBug
Unable to successfully Compile the code on Android when run react-native run-android
ERROR LINE (in terminal):
/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceMo
dule.java:394: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
^
symbol: variable P
location: class VERSION_CODES
/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceMo
dule.java:396: error: cannot find symbol
locationEnabled = mLocationManager.isLocationEnabled();
^
symbol: method isLocationEnabled()
location: variable mLocationManager of type LocationManager
Environment info
React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Memory: 87.72 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.4.0 - ~/.nvm/versions/node/v8.4.0/bin/node
Yarn: 1.5.1 - /usr/local/bin/yarn
npm: 5.3.0 - ~/.nvm/versions/node/v8.4.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: 0.57.1 => 0.57.1
Library Version using:
"react-native-device-info": "^2.1.1",
Steps To Reproduce
- Install the Library using
yarn add react-native-device-info
- Run:
react-native link react-native-device-info
- Run
react-native run-android
What I have tried
- I have tried to comment the aforementioned lines from the code. Complies successfully but app crashes on launch.
- I have returned
true
forlocationEnabled
from the code. Same result. - Deleted the entire function, as I was unable to find it anywhere in the code. Same result.
Describe what you expected to happen:
Expected to build the debug release to run on the device or emulator installed using Android Studio on Mac OSX, like it is building and working on iOS (Working Perfectly for iOS on the same project)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:12
Top Results From Across the Web
How to Resolve The Cannot Find Symbol Error in Java - Rollbar
The cannot find symbol error refers to a situation where the Java compiler is unable to find the symbol associated with a given...
Read more >Build Fails with error: cannot find symbol class ...
The app was working fine, but suddenly I am getting build fails, with multiple 'cannot find symbol class' errors. I am pretty sure...
Read more >Different Ways to fix Cannot resolve symbol ... - GeeksforGeeks
Go to your build.gradle(Module:app) file and in the dependencies section the appcompat one, you should see something like compile 'com.android.
Read more >What can cause the "cannot find symbol" error in Java?
The “cannot find symbol” error occurs mainly when we try to reference a variable that is not declared in the program which we...
Read more >How do I resolve cannot find symbol ? android studio..
At a guess, you have a missing or extra close curly bracket somewhere just above the first line that the compiler finds an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No upgrade guide is needed, the reference in the changelog should be sufficient, it’s just that change https://github.com/react-native-community/react-native-device-info/releases/tag/v2.0.0
It looks like I may have had think-o there though, it says (or said, I will edit) ‘breaking: note that isLocationEnabled requires minCompileSdk 28’
It should say ‘breaking: note that isLocationEnabled requires compileSdkVersion 28’
That said, looks like your ext block is correct
There will be one instance of compileSdkVersion in your project (or there should be)
And it will be referenced in your android/app/build.gradle (or it should be)
Check out this repository from github Run the example It works ?
Perhaps you are not referencing the variable and it is hard coded in android/app/build.gradle
One thing to note. starting Aug 1st, you can’t even publish a new APK on Play Store without targetSdkVersion of 28 anymore, and you can’t target that without compiling against that, so I have no idea how you will be able to publish? I guess if it’s just an update you have a couple more months, but you need to move to 28. And this will work
You are for some reason compiling against and android sdk that is less than 29. You must compile against android sdk 29 from react-native-device-info 2.0.0 and higher
Every project is different so I don’t know why that’s happening for you, but as mentioned above, look at the example here and do what it does.