Good morning.
I am creating a "Android Application Project" and I get an error "R can not be resolved to a variable". The error I get nothing and create the blueprint (the "Hello World") without adding any thing more (the basic example).
Thank you.
PS: Platform SDK: API 17; Android SDK Tools: 22.0.1, Build-Android SDK Tools: 17.
As stated here:
After updating to SDK Tools to rev. 22 for the first time, you may need to relaunch Android SDK Manager again and install a new item: Android SDK Build-tools.
After installing this, clean your projects and rebuild.
'R' isn't generated if there are any errors in your XML files. So check all your XML files. Check for errors in naming the XML files. No capital letters etc.
If you're using Eclipse, it helps if you delete your gen folder and add it using Project > Properties > Java Build Path > Source tab > Add Source > Select gen and then Clean and Build your project
Related
I am coding a Xamarin application and these are the errors that I am getting when building my application:
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5206: Please install package: 'Android Support Library' available in SDK installer. Android resource directory C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/appcompat doesn't exist. (XA5206) (SimpleOnePageViewPager)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/appcompat/libs/android-support-v7-appcompat.jar doesn't exist. (XA5207) (SimpleOnePageViewPager)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5206: Please install package: 'Android Support Library' available in SDK installer. Android resource directory C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/mediarouter doesn't exist. (XA5206) (SimpleOnePageViewPager)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/mediarouter/libs/android-support-v7-mediarouter.jar doesn't exist. (XA5207) (SimpleOnePageViewPager)
I have added the Android Support Library v4 as a component and in the Android SDK Manager I seem to have everything installed correctly.
Can I please have some help to get my code building successfully?
Thanks in advance
EDIT
I have added the Android Support Library v7 AppCompat as a component and am now getting these two errors:
Error XA5206: Please install package: 'Android Support Library' available in SDK installer. Android resource directory C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/mediarouter doesn't exist. (XA5206) (SimpleOnePageViewPager)
Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/mediarouter/libs/android-support-v7-mediarouter.jar doesn't exist. (XA5207) (SimpleOnePageViewPager)
in case your "embedded" folder is missing, just downloading and extracting the android_m2repository_r10.zip does not solve the issue.
I deleted the entire C:\Users\\AppData\Local\Xamarin\Android.Support.v4\23.0.1.3 folder and then rebuild as described here:
[Error after updating the Android.Support Library v7 AppCompat to the 21.0.3 version
I solved all of the 'Please install Android Support Library' errors, although I'm not sure which step exactly solved it. However, this is what I did in case someone has the same trouble as I did:
Download "https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip " and paste it in "C:\Users\YourUserName\AppData\Local\Xamarin\Android.Support.v4\21.0.3\". For mac users change the path pre-Xamarin to \Users\YourUserName\ .local\share\Xamarin (Overwrite as needed, but create backup just in case)
Extract the contents of the android_m2repository_r10.zip archive into {...}\Android.Support.v4\21.0.3\content folder (create content folder if it doesn't exist, overwrite as needed and take same precautions as above)
Repeat the steps above but this time for the {...}\Android.Support.v4\22.2.0 folder instead of the 21.0.3
Make sure you have your packages updated to the latest version by right clicking on the Package folder of your solution and clicking Update (At least on Xamarin Studio).
Make sure you also have the latest version of Android Support Library on the Android SDK Manager
In case everything fails, try the AppCompat Android component from Xamarin (your milage may vary with the last one)
I was facing same problem and i followed following link and it is working like a charm.
https://forums.xamarin.com/discussion/56627/xamarin-android-support-v7-cardview-error-depite-being-installed
Just suppress the zip in Xamarin\zips{zip} and rebuild your solution .
In Addition to #sgarcia the answer there are another steps that fixes the problem.
1- Renaming the android_m2repository_rnn.zip file to it's MD5 hash of url.Here is a list of some of them:
android_m2repository_r33.zip --> 5FB756A25962361D17BBE99C3B3FCC44
android_m2repository_r32.zip --> F16A3455987DBAE5783F058F19F7FCDF
android_m2repository_r31.zip --> 99A8907CE2324316E754A95E4C2D786E
android_m2repository_r30.zip --> 05AD180B8BDC7C21D6BCB94DDE7F2C8F
android_m2repository_r29.zip --> 2A3A8A6D6826EF6CC653030E7D695C41
android_m2repository_r28.zip --> 17BE247580748F1EDB72E9F374AA0223
android_m2repository_r27.zip --> C9FD4FCD69D7D12B1D9DF076B7BE4E1C
android_m2repository_r26.zip --> 8157FC1C311BB36420C1D8992AF54A4D
android_m2repository_r25.zip --> 0B3F1796C97C707339FB13AE8507AF50
android_m2repository_r24.zip --> 8E3C9EC713781EDFE1EFBC5974136BEA
android_m2repository_r23.zip --> D5BB66B3640FD9B9C6362C9DB5AB0FE7
android_m2repository_r22.zip --> 96659D653BDE0FAEDB818170891F2BB0
android_m2repository_r21.zip --> CD3223F2EFE068A26682B9E9C4B6FBB5
android_m2repository_r20.zip --> 650E58DF02DB1A832386FA4A2DE46B1A
android_m2repository_r19.zip --> 263B062D6EFAA8AEE39E9460B8A5851A
android_m2repository_r18.zip --> 25947AD38DCB4865ABEB61522FAFDA0E
android_m2repository_r17.zip --> 49054774F44AE5F35A6BA9D3C117EFD8
android_m2repository_r16.zip --> 0595E577D19D31708195A83087881EE6
You can find the list here: https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/#Manually_Downloading_m2repository
If the problem still exists the best way is to follow this link's instructions.
Manually Downloading and Installing m2repository Files
user998066, simonbassey and sgarcia.dev - thanks.
Just to update, you don't have to manually download those zip's and extract them in your appdata folder. Just delete them and rebuild your solution. Visual Studio will download and do the rest. It doesn't show that its downloading/extracting/watever in the output window (one thinks its frozen and will kill the VS instance.. dont do it as this is where your download is interrupted and the zip file is corrupt and keeps giving those errors.) and takes a lot of time. If you go to C:\Users\\AppData\Local\Xamarin\zips you will see the zips getting downloaded while you are building your solution. Its a huge file and your first build will certainly take a lot of time until its downloaded..
Ensure the following:
1- Open Android SDK Manager
2- Under Tools Tab --> Find the folder "Extras"
3- Make sure that "Android Support Repository" is installed
Upgrade Xamarin.Android.Support.v4 to 22 or higher. I went on with 25.4.0.2.
Install Xamarin.Android.Support.v7 and everything just works fine.
You have to add android-support-v7-appcompat as library project. It's it sdk android extras.
If you are still facing this problem , try following these steps to resolve it. it did the magic for me
Goto the Xamarin installation folder path . on windows you can find it here C:\Users\simonbassey\AppData\Local\Xamarin
Next delete the zips folder therein (it may have been corrupt or not an updated version of the support library). Also delete every other Xamarin.Android.Support.* folder there.
Head on to the visual studio solutions folder for the project and delete the bin/ and debug/ folders.
Restart visual studio and rebuild your project.
See this thread for more details
What fixes in my case was:
1- Open Android SDK Manager
2- Find the folder "Extras"
3- Make sure that "Android Support Repository" is installed
Then in VS:
1- clear the obj and bin folder
2- clean and rebuild the solution
Following two links helped me with all jdk and droid project related problems. In case it may help other guys also.
Cleaning particular zips
Setting java version
After I updated form 0.2.2 to 0.2.3, I create new project failed.
Error message is below:
下午 08:51:58 Gradle 'NotifyViaGoogleMapsProject' project refresh failed:
The SDK directory 'C:\Program Files (x86)\Android\android-studio\bin\Program Files (x86)Androidandroid-studiosdk' does not exist.
Build file 'F:\AndroidStudioDevelop\NotifyViaGoogleMapsProject\NotifyViaGoogleMaps\build.gradle' line: 9
NotifyViaGoogleMapsProject is my project name,and my android studio is install in default path(C:\Program Files (x86)\Android\android-studio), there has no same error in 0.2.2.
I've figured out the problem.
Open 'local.properties' in your project using a text editor.
sdk.dir=..\\sdk
Save and Close
Now Import your project into Android Studio.
Make sure that the SDK folder you mention exists - I'm not sure if it is a typo or not but the path you specified is a bit weird - it should be
C:\Program Files (x86)\Android\android-studio\sdk
On the menu go to File -> Project Structure, then choose SDKs under Platform Settings. Check that the path for the Android Platform you use is correct, and if not, change it to the correct path. Also make sure that the Project is set to use the correct Android Platform.
I have the same problem.
http://i.stack.imgur.com/pPOOi.png
The SDK is correct in Platform Settings, I have no idea what's causing this problem.
http://puu.sh/3TAFi.png
When I create a new android project in Eclipse, and I choose to have a default main activity, my R.java file does not get generated.
I have seen some questions online and on this site about R.java not being generated but all are due to some manual action/mistake that had to be corrected during the development of the application.
However, does anyone know why R.java would not get generated for a brand new android project, where I have made no manual modifications whatsoever?
I think your problem is just the latest update of the SDK.
Test the following operations on two projects :
In the project properties (eclipse) -> java build path -> order and export make sure that all your jars in the libs folder are checked.
And "Android Tools -> Fix Project Properties"
And "Project -> Clean"
I hope you have helped!
ADT version 22 requires that you install "build tools". To get it to work i had to update:
SDK Tools
Platform Tools
Then install:
Build Tools
This link recommends you add build tools to your environment path. I had to do the following before the R.java was generated:
Append build tools to PATH environment variable
Restart Eclipse.
Make sure your project is free of errors and problems. You can use Windows-View to find and rectify them. Common mistakes are in the layout files.
Check the AndroidManifest file and see if the activity names match the classes in your source folder. Clean and rebuild.
R.java creates every time when you create android project first time r.java created by default
so check for the errors and clean the project.
I'm trying to use the SlidingMenu library. As described, I created a new Android project using the library directory, tried "Project > Clean" to generate the R.java but doesn't work.
The curious fact is that if I open the project properties and uncheck the "Is Library" all will work and R.java file is generated without errors. Besides the errors with the lack of R.java file, the tab "Problems" presents this:
Unparsed aapt error(s)! Check the console for output.
If I remove, as suggested in several responses, it appears again when I clean the project.
I appreciate any suggestion.
Un-checking and re-checking and "is library" helped for me.
Under Preferences > Android (for that lib project)
There are many thing to get back R.java
clean project
Build project from project
change the api of ex 2.2 to 4.0 and 4.0 to other version it will (re)create R.java file
finaly yet you cannot able to get R.java file then copy R.java file from other project paste it into gen folder then just build project.
eclipse -> project -> build automatically -> check it
If it is already checked, uncheck it and check it again.
Solved.
I do not know exactly what the reason, but the solution was to remove the Eclipse, the Android SDK and use the ADT Bundle from this link: http://developer.android.com/sdk/index.html
Before I was using a standard Eclipse IDE with the ADT plugin.
Thanks for the replies.
I have installed Android V4.0 and V3.2 SDK in my machine, when i try to create a project in my eclips it says Manifest file not found.
Manifest file is not at all getting generated. Normal android projects are getting created properly but if i create a project by pointing to ABS lib, it fails..
I have tried almost all the possible steps like, setting compiler version to 1.6, restarting etc...i'm sure i have latest ADT..
Kindly help me, what is the reason causing the problem
Try to get from git: https://github.com/JakeWharton/ActionBarSherlock
File > Import > Projects from git > Clone > URI: https://github.com/JakeWharton/ActionBarSherlock.git > Next > Finish
You are probably giving eclipse the incorrect project source folder. Check out this tutorial to correctly install ActionBarSherlock