Aaria
Lost but trying
Profile
Posts: 3
Reg: Jan 30, 2015
Brisbane
30
06/12/15 04:35 PM (9 years ago)

R cannot be resolved to a variable

Hello, I am successfully able to export APK file when preparing project download with android BT V2.0 without any error (selecting google API 2.2), But unable to compile when exporting Android –BTV3.0 (selecting Android 4.0, API 14 in eclipse) Yes I am adding google play service to my project, About 200 ERROR : R cannot be resolved to a variable And 1 Error : No resource found that matches the given name (at 'src' with value '@mipmap/ic_launcher') I have tried different version of Eclipse and JAVA (including 64bit and 32 bit, JDK 7 and 8) Also I have gone thru buzz-touch installation documents very carefully but seems like its not related to setup as it’s giving same errors on my MAC I will really appreciate any help Thanks in advance
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/12/15 06:26 PM (9 years ago)
I can't say that this will work in 'every' situation, but it seems to help in a few... try 'cleaning' your project. Cheers! -- Smug
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
06/12/15 07:00 PM (9 years ago)
This happens when Android Studio (or Eclipse) cannot build the project. "R" is actually a file with a bunch of id numbers pointing to other files in your project. The files it points to are all in your "res" ("resources") directory. Almost certainly you have an issue with one of these files preventing your project from being built. I would first check to make sure your images are all named properly. They should be in all lowercase, with no whitespaces. Eclipse sometimes complains about .jpg files, so it's also wise to make them .png files. Then look at your "layout" directory for any .xml files with red x's. If you find any, open them up and see what the error is. Then try to build your project again. Also, Eclipse should tell you what the error is - sometimes you have to hunt for it, but there's a message there somewhere I promise!
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
06/13/15 12:23 AM (9 years ago)
With Eclipse, try the Problems tab, it will tell you there what is the problem. Sometimes there are thousands of errors there, then just erase them all, and run the app again. Then the Problems tab will be smaller and will usually locate the problem for you. In this particular case, the solution is this: As of lately, the code from BT server will contain a reference to a mipmap. The error you have is telling you that the mipmap folder and the mipmap image are not there. Mipmap is intentionally pronounced and spelled similar to bitmap, and you can use it if you have an exact size of an image that you want to include in the app. (Normally, Android would skew your image from drawable folders, and many people did not like that, so the notion of mipmap was included recently.) There are two solutions: -- just delete the offending line in the code and none the wiser, or -- add a mipmap folder under /res and put an image called ic_launcher.png into it. Ideally, that would be the icon of your app in an exact size.
 
Aaria
Lost but trying
Profile
Posts: 3
Reg: Jan 30, 2015
Brisbane
30
like
06/13/15 02:53 PM (9 years ago)
Thank you very much for all the reply, it really helps to understand it more Problem is now fixed as suggested by Dusko :- “-- add a mipmap folder under /res and put an image called ic_launcher.png into it. Ideally, that would be the icon of your app in an exact size.” And yes it is important to rebuild the project after applying this solution Thanks you again
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.