• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android Studio Native App says "Cannot resolve symbol 'R'"

Cofyka3

Lurker
So I simply opened the Android Studio, clicked File>New>New Project. And then I created an app with "Include C++ support" box checked. When my project was built, with no changes I got red line below every 'R' (resources) symbol in MainActivity.java. And when hovered the message says 'Cannot resolve symbol 'R''. There is literally no answer to this problem on the internet. But now I opened 'Messages Gradle Sync' tab and in the process as I can see there are some fails with Cmake. Here's the screenshot.
fgRoAG2.png

yMkA1id.png

Thanks :).
 
'R' is an auto-generated class, based on your screen layout XML description files. If there's any problem with these, then R won't be generated.
In your case, the project seems to have other build problems, which I would recommend sorting out.
Generally any failure of the build process will have a knock-on consequence of not generating the required 'R' class, which explains why your code can't reference this class.
 
'R' is an auto-generated class, based on your screen layout XML description files. If there's any problem with these, then R won't be generated.
In your case, the project seems to have other build problems, which I would recommend sorting out.
Generally any failure of the build process will have a knock-on consequence of not generating the required 'R' class, which explains why your code can't reference this class.
Thank you for your answer, I searched on the internet for a solution and found out it was somewhere in CMake, but since I'm noobish with these things I don't where to run this piece of code the guy posted on stackoverflow 'yum install gcc gcc-c++'. Apparently that code should install me gcc-c++ for cmake. Thanks
 
Well if you actually read the error log shown in your first post, you could go a long way to working out what the problem is here.

To start with, it says: "Invalid Android ABI: armeabi (armeabi is no longer supported. Use armeabi-v7a)"
What's an ABI? Well having not developed a native C++ app before, I don't know, so I went to Google search and typed "Android ABI" into my web browser, and here's the top hit it came up with

https://developer.android.com/ndk/guides/abis

So this explains what an ABI is, and why you need it for a native application. The information also includes the fact that armeabi will be deprecated in r16, and removed in r17.
Which seems to agree with what the compiler tells me in the error message.

It also tells me how to configure the build for a particular ABI. The relevant file is Application.mk

Generating Code for a Specific ABI
By default, the NDK targets for all non-deprecated ABIs. You can target a single ABI by setting APP_ABI in your Application.mk file. The following snippet shows a few examples of using APP_ABI


APP_ABI := arm64-v8a # Target only arm64-v8a
APP_ABI := all # Target all ABIs, including those that are deprecated.
APP_ABI := armeabi-v7a x86_64 # Target only armeabi-v7a and x86_64.

It appears that all you need to do here is set the APP_ABI parameter in this file, using a value of "armeabi-v7a", and re-build the project.
 
Back
Top Bottom