Cleaning ActionBarSherlock creates R cannot be resolved error - android

I've recently (this morning) updated a bunch of android plugins in my eclipse environment (so I could switch over to Android Studio), however, I decided to return to Eclipse to finish something up. I had to re-import the actionbarsherlock project (4.2.0 library). After I imported, made sure it was running on Android 4.2 and as a library, I cleaned the actionbarsherlock 'library' project. Which resulted in over 200 'R cannot be resolved to a variable' problem.
I've tried all the usual suspects: couldn't find any errors in the res file, tried cleaning, refreshing, closing eclipse in various different orders.
I'm also noticing a new dependency entitled "Android Private Libraries" -- I am not positive it is new from this update, but it could be.
Other information that might be useful:
- there are no gen files (nothing is being generated)
- I also linked it to my Android Project as a library (set to the same API level)
- I've done separate cleans and a clean at once
Any help would be great, I'm stuck on this one and it's driving me nuts.

You have to check the Android Private Libraries in the java build path of the project:

Resolved by updating the API's as well as the tools and everything else I updated this morning. Very weird situation.

In my case I had the wrong Android target. To solve it:
Right click on your project, then Properties, then click on Android and select the correct Project Build Target.
I had Android 2.3.3 and I changed it to Android 4.2.2
I hope this helps to someone.

This problem was stupid(I mean this situation)... and I was using a stupid way to solve it.
update android API & SDK & anything else you can.
Open your library project's Properties window, go to [Java Build Path], [Order and Export]
Use [Up] [Down] button to make sort sequence like this:
After this, it still shows same error, so you have to re-build this single library project again.
Check top menu, [Project], [Clean...]
Clean that single library project, make it auto re-build.
That's how I solve all my library porject's same problem. (ActionBarSherlock, FacebookSDK, SlidingMenu, ViewPagerIndicator)
Sounds like a stupid solution, but just match this stupid situation.
Google, what the hell are you doing ?

In my case I am running 64 bit Linux (Linux Mint) and I had to install 32 bit libraries using sudo apt-get install ia32-libs
After installing the 32 bit libraries I restarted eclipse and cleaned the ActionBarSherlock library and all is good

Are you using the Android support library?
I had this error because I had a different version of the Android support library jar in ABS vs. the rest of my project. Make sure the support library jars you are using are identical in every project.

Strangely enough, this issue gets fixed when I add old flavors of Android SDK build tools: 18.x and 17.x
(For some reason, I uninstalled some of those)

Related

Getting GoogleCast to work

I've tried, with zero success so far, to both create a new project and add GoogleCast to it and to get the given examples to work on Android Studio (currently using 0.3.2, but will upgrade if needed) on MacOSX.
Migrating to Eclipse, however, is not a valid option at this time.
I always seem to end up stuck with some reference issue, either giving me the error "No resource found that matches the given name '#style/Theme.AppCompat'." or multiple compile-time errors related to having no idea where android.support.v7 is located at.
Tried many different solutions, such as removing the #style part that someone mentioned to work or setting the v7 path as relative.
Though I wasn't able to follow through with this last one, no idea how to actively do that in AS and not enough reputation to comment there.
Then I came up to this solution Anyone get the chromecast android examples working in android studio?, which seems like a good attempt, except I can't seem to find the mentioned GoogleCastSdkAndroid.jar anywhere, so I'm stuck.
Couldn't find a truly comprehensive tutorial anywhere either, since they all seem to have no issues whatsoever adding v7 to the project.
Thanks in advance for anyone who can donate some of their time to solving this issue.
EDIT:
After upgrading to 0.4.6 (is 0.5.1 stable already? Considered how fast it came after 0.5.0...doesn't sound too good); I did what Ali Naddaf suggested, but couple extra questions popped up:
I could build the CastVideos project and import it into Studio with no problem; however, the CastVideos project structure is radically different from a new project's structure (referred to as OtherApp from now on).
The main issue that pops up when I try to mimic CastVideos on OtherApp is that it doesn't find the CastCompanionLibrary project on the OtherApp only, which I can't seem to be able to figure out where exactly should be located at (I thought the 'core' folder was the one with AndroidManifest?).
Also, how do you import modules now? The Project Structure only allows the creation of new modules.
My suggestions:
update your Android Studio
open SDK manager and make sure you have the "Android Support Repository" installed
create an empty directory on your system (referred to it as <DIR> below)
change directory to <DIR> and clone CastCompanionLibrary-android to CastConpanionLibrary
$ cd <DIR>
$ git clone https://github.com/googlecast/CastCompanionLibrary-android.git CastCompanionLibrary
$ git clone https://github.com/googlecast/CastVideos-android.git CastVideos
first make sure all is fine by building from command line:
$ cd CastVideos
$ ./gradlew build
it should do a successful build at this point.
if all is fine, open your Android Studio and select "Import Project" and point to build.gradle in the CastVideos project.
Now for any other project, you can look at the build.gradle in CastCompanionLibrary or CastVideos to see how you can set up your dependencies on the support libraries; if you don't have dependency on the CastCompnionLibrary, then it is even easier.
You very much need to upgrade Android Studio. 0.3.2 is quite old and a multitude of bugs have been fixed since then that are almost certainly affecting you.
Other than that, make sure you have the Android Support Repository installed in your SDK Manager. Between those two it should solve your support.v7 errors and #style/Theme.AppCompat issues.
This question is very old but to make it work I had to clone both Git repositories (CastCompanionLibrary & CastVideos-android). Import CCL into Android Studio as Non Android Studio Project, change the version of build tools to current 21.1.10, build the project and close it. Android Studio asked me to reopen the project. Hit yes. Do exactly the same with CastVideos-android and finally I could launch it into my smartphone.
Was really painful, took me 2 hours make sense of the error, because I was trying to open into Android Studio like Android Studio projects (they were) but there was a problem with the .idea file.
Tried this and everything worked.

Could not find class

My project ran well until I clicked "Help->Check for updates" and installed some components in Android SDK Manager.
In general, there is no error announced in my project. But when I run my project, it causes an error
could not find class com.androiquery.AQuery
I checked out again, I still can see the AQuery library in libs folder and also the reference to this library.
I also tried to clean the project and its dependencies, quite the eclipse, restart the computer, but it doesn't solve.
Do you know how to fix it?
I have had the same issue as you and have fixed it this way.
Go to Properties > Java Build Path > Order and Export and check the Android Private Libraries box.
See the screenshot below:
It may be one of the following reasons:
Setup problems: adding the jar files manually as well as setting the project type to use Google APIs. This cause problems for some reason.
You are calling activity may be inheriting some class that causes this problem.
I assume your are using ADT? if you are, you can download a .zip with all files in it. From the android developer site
Thanks #Raghunandan. The solution is right click on project. goto java build path. choose order export tab. make sure android private libraries is check. Clean and build. Also make sure you have android sdk build tools from the sdk manager

Why is my updated Eclipse / Android setup not building my APK anymore?

I had a working Eclipse setup with 3.6.2 and SDK tools from version 11, and it has been building my main project just fine for quite a while.
For a different project, I thought I needed to upgrade my SDK to the latest and greatest - at this point API 14 (ICS 4.0).
I cannot even reconstruct the steps I went through, but what happened was that my project would seem to build, but I would see that it would say that it was skipping a post-compiler step, and at the end I would have no APK.
I also noticed that it updated my .classpath so that the output path was bin/classes instead of .bin.
Along the way I tried updating my Eclipse to the latest version (Indigo 3.7.1) but this didn't help.
I solved the problem eventually with help from this post on the Google Android forum:
http://code.google.com/p/android/issues/detail?id=21031
For me personally the biggest issue seemed to be solved as follows (qutoe from comment 25 in the forum post)
"I seem to solve the problem with .apk files not being built automatically until run/debug is used (comments #10, #11 etc.). Go to Windows -> Preferences -> Android -> Build and uncheck "Skip packaging and dexing until export or launch" then restart Eclipse. Works for me."
But there is other useful material there. Different people with different projects seem to have different problems with this setup.
I still don't understand the change in the classpath, but it doesn't seem to matter.
In addition, I found a discussion of installing the ADT with Eclipse Indigo which was helpful here in Stackoverflow:
Eclipse Indigo - Cannot install Android ADT Plugin
I also found that I guess because of various uninstalls/reinstalls, for some reason it stopped excluding my .svn directories from the sources. This Stackoverflow post was helpful with that:
Why is eclipse trying to copy my .svn folders from src to bin, and how can I make it stop?
Finally: a tip for really and truly uninstalling Eclipse - everybody says there is no uninstall, and there isn't, but there is a directory that Eclipse leaves in your home directory (in windows 7 under c:\users\) called .eclipse -
Zap it if you really want to start fresh.
In addition, for less extreme measures, there is Project->Clean inside Eclipse, and you can invoke eclipse with "eclipse -clean" for additional cleansing effects. No idea what, but various helpful people along the way suggested trying that to solve problems.
Ah yes - when I first installed Indigo and tried to build, I got a warning that my Java Compiler Compliance level was not up to snuff, which was simply not true - I have only Java 1.6 installed on my machine.
See this post for somebody who had similar experience:
http://marakana.com/forums/android/general/374.html
For me, what worked was simply going to Project, Properties, Java Compiler, then click on Configure Workspace Settings, and click on Ok in the dialog. Didn't need to actually change anything. Just showed it that everything was ok!
Eventually I indeed did clean out my Eclipse and Android installations (including the aforementioned .eclipse directory, and there's also an .android directory in your home directory which you may want to erase if uninstalling the Android SDK Tools doesn't do that - this actually is uninstallable). Installed everything from scratch and then used the additional information provided above and now it's building my APK.
I hope this saves somebody the hours I spent getting my build back in shape.

How install old ADT13 in Eclipse

We do have lots of problems with our Android Apps when using SDK14/ADT14. Currently we can't build none of our complex apps with lots of libraries and dependant projects (Resources are not updated even after Clean, Refresh, Forced Save, ...). We would like to go back to SDK13/ADT13.
SDK13 is in our backup repository. But we don't have the ADT13 plugins.
How can we direct Eclipse to download the old ADT13 plugins?
Many thanks in advance.
I had to do this recently as well. Fortunately there's a hidden cache of old ADT versions, here's the link for the previous ADT release:
http://dl.google.com/android/ADT-12.0.0.zip
Then inside Eclipse you go to Help -> Install new software -> Add... -> Archive ... -> choose the downloaded zip. FYI: Unfortunately, you can't (or at least, I couldn't) revert to the previous SDK Manager and Tools version so easily (it insisted on getting itself upgraded before downloading the SDKs), I had to use an old copy of the folder I had lying around. Since you have SDK13 in your repo, you should be good to go.
You need to make sure that you've updated both the SDK AND the ADT plugin in Eclipse - I forgot to do the latter and had the problems you've described.
SDK14/ADT14 introduced a lot of changes - the old ADT won't work with the new SDK and the new ADT doesn't work with the old SDK.
If you've done both and it's still not working then moyshe's link takes you to the relevant to stuff to download (just uninstall what you have already and install the older versions)
Is your issue similar to this: http://code.google.com/p/android/issues/detail?id=21201
Basically each time I open Eclipse, I have to remove all library projects from all projects using them, apply changes. Then re-add them manually. Then I can start working!
It's very probable that it's related to http://code.google.com/p/android/issues/detail?id=21031.
This is serious issues and I can't believe no-one from Google has responded yet!
I'm posting this separate answer because of stuff I've learned from the Google Groups threads and my own experiments. I realise it's not a straight answer to the OP's question but I think it's useful here regardless.
ADT14 has changed how Android Libraries are handled in Eclipse. Instead of importing sourcecode (in LIBRARYNAME_SRC folders) it now compiles and brings over .JAR files (in a "Library Projects" folder).
To get my stuff working I built a complete new environment, installed the latest Eclipse/ADT/SDK, Imported my work and worked through all my projects from non-dependant libraries upwards - doing the following.
1 - remove all Android Libraries and 'Apply'
2 - remove all xxx_SRC folders from the Build-Path->Source tab
3 - remove any remaining xxx_SRC folders (should be empty anyway) from your Project.
4 - Add your Android Libraries back in again.
Another relates to Build Path Projects (non-Android ones). Before, ADT did not mind if you had the same Build Path Project in multiple libraries - but it sure-as-hell does now!! It crashes with "UNEXPECTED TOP LEVEL EXCEPTION"s, "java.lang.IllegalArgumentException: already added: Lcom/yourlibrarypath" and "Conversion to Dalvik Format Failed" messages.
This prevents you deploying - to solve it, go through your libraries and ensure that Projects only appear on the Build Path ONCE. I suspect that, previously, ADT actually may have need them duplicated and may even have created this duplication!?
Lastly, you have to ensure that Eclipse builds everything in the right order. Again, this didn't matter before but it's why your projects fail if you 'clean' or change anything. To do this you have 2 choices
1 - rename your projects so that they appear in alphabetical order from 'leaf' to 'root' (e.g. libraries < projects which use them).
2 - In Eclipse, use Windows->Preferences->General->Workspace->Build Order and specify all your libraries, in order. Anything not in that list is built afterwards so only libraries need be mentioned there.
Hope this helps someone

Need to configure Android libs on every Eclipse start

After several years with Eclipse and Android development this combination is driving me nuts.
On every start of Eclipse the lib settings I've configured on the page 'Project/Properties/Android' section 'Lib' need to be re-applied.
After a Eclipse restart all existing projects are marked in red. For every project I have to select that project, change to the page described above, remove all Libs, hit Apply, re-enter the same Libs and hit apply again. .classpath and .project look ok. It's the latest Android SDK and the latest Helios Eclipse release. MotoDEV is installed as plugin.
This is a stupid and time-consuming process. Please, has anybody an idea what's wrong with Eclipse (or the Android SDK) or my configuration?
Many thanks in advance.
Which OS are you using and is it 32- or 64-bit? Are you logged in as root/administrator or as a regular user? This sounds suspiciously like the ~/.eclipse folder isn't getting written correctly. We can look at this in MOTODEV Studio and see if it's something unique to us, but it definitely is strange behavior.
Update: one of the MOTODEV Studio team says this is a known bug in ADT when using linked folders. http://code.google.com/p/android/issues/detail?id=14217

Categories

Resources