ActionBarSherlock and new Android SDK - android

I had an existing project working with ActionBarSherlock and the android SDK (tools version 19 i think) i upgraded the Android SDK to the latest version (21) and suddenly all the R variable stuff is missing, example: R.layout.fragment_account_layout it claims does not exist and needs to be created. pretty much everything related to the R variable is messed up. i have tried a couple different things to fix it; cleaned the project, cleared out the workspace and re-added everything. nothing has worked. how i do resolve this issue? is it a change i need to make to my configuration?

You may need to check that your activities are not importing the wrong R file ( In this case it may be importing the R from the ActionBarSherlock instead of your application)
Worst case you may need to add manually your R into your activities.
like
import your.app.namespace.R;
within the class and delete any other R being imported

Related

Error with new/old project because of AppCompat

I know many people have asked this questions previously too. I have gone through almost all the posts available on StackO but all in vain. Trying to make it work since last 24 hours but of no use.
What I have tried till now :
1.) Fresh copy of Eclipse and ADT
2.) Deleting the .android folder and .metadata(lost all workspace properties :( ) folder.
3.) Reinstalling whole SDK and everything
4.) Deleting and adding projects(my own projects and appcompat projects) multiple times.
5.) Changed properties target platform and done everything possible
6.) etc etc
I'm not facing any issues with Google Play services...
Still getting errors in appcompat project folder and new projects. I have attached few screenshots below. Please if someone knows the exact issue and how to resolve it then let me know as I have already wasted 1 day on this troubleshooting.
The Problems tab is showing these messages : Click Me
Screenshot-1 http://tinypic.com/r/2hdocjb/8
Screenshot-2 http://tinypic.com/r/ht7axg/8
Screenshot-3 http://tinypic.com/r/or0512/8
It seems not finding Material theme, Project Build Target of library project appcompat is checked on Android 5?
It seems Android has updated all the styles and have removed the previous styles from AppCompat.
The solution is ( Recommended ) either to Update everything in SDK and update your project styles with new appcompat-21.
Other solution is to get older version of appcompat and use that.
Thanks

importing R. (android)

I have searched through Stack Overflow as I know this is a common question, but none of the solutions seemed to work for me. This included cleaning my project, deleting all imports and deleting the project and starting again entirely.
I am using the Eclipse specifically for android on mac (ADT bundle mac).
Whenever I create a new project I have errors immediatley in my src folder on the line
setContentView(R.layout.activity_main);
and also on inflate.
Any suggestions other than those stated? It is literally before I have done any programming so cannot understand what is wrong.
EDIT: Fixed. Downloaded the SDK a second time and this seems to have fixed it.
import The R class. The basic syntax is
import your_application_package_name.R;
If you have already imported it but it is not working then check if there in any error in your resource xmls. If so then r can be not generated and that error will be shown
Change your Project Build Target to the Latest
Right Click Project > Properties > Android > Change the Api to latest version
Try to update the Android_SDK. When you create or import a new Android project the SDk builds the project. The R problem is mostly an update SDK problem.

Jar file versus reference to the Android Library

You will really make my day by explaining the following nuissance.
L is a library. A is an application using L, CA is a class, declared in A extending a class CL in the library L.
Untill recently, I could just place L.jar in the lib folder of A project. But I purchased a new hard disk, reset Eclipse, ADT plugin and SDK, then transferred my project to the new location. This is when it started.
If I place in A a reference to the project L (via Project/Properties/Android/Library), everything still works all right. But with a jar file, it gives a "No Class Defintion Found" error for CA class, even though it belongs to the same class as the calling method!
To avoid some sceptical remarks:
L has no resources in it.
Compiler version is 1.6
I cleaned both projects millions of times.
Both projects are compiled with same API version.
No obfuscation was used and I checked that CL class is really present in L.jar.
Tried placing L.jar in build path, as topmost, then as bottommost - no help.
Thank you for anticipated help.
It was rather silly of me: in "Order and Export" panel of BuildPath configuration I had Android Dependencies ticked, but Android Provite Libraries unticked.
What I found out is that libraries linked through Android properties go to Android Dependencies, whereas the ones in lib folder are considered as Android Private. This explains why the first were included, while second weren't.
The most annoying thing is that Eclipse doesn't complain, the build seems to be all right, and only at the execution stage the error comes out. As a C programmer I am not quite used to that :)

ViewPager.PageTransformer cannot be resolved to a type

I am getting ViewPager.PageTransformer cannot be resolved to a type I have updated the sdk to the latest and have the latest version of android-support-v4 in my libs folder and i read this post ViewPager.PageTransformer showing error ViewPager cant rersolved to a type i am using androidsupportv4 jar revision 9 and did the same steps but it didn't work.
You should remove ViewPager. from the begginging of declaration.
So, that would looks like just PageTransformer
Plus, import android.support.v4.view.ViewPager.PageTransformer;
that worked perfect for me.
Okay, I found the solution. You need to update your Android Support Library package. But if you have it now you need to uninstall it first then install it again in order to get new one.
If you have IntellijIdea:
Open SDK Manager window from "Tools/Android/SDK Manager"
Find Exteras folder then check Android support library. If its status is
installed click "Delete 1 package..." in order to delete it.
Check this package and click on install button.
Navigate to \extras\android\support\v4 then copy
android-support-v4.jar and paste it into your Libs folder.
Idea should recompile the project automatically, however if it didn't do
that then you should recompile it manually by click on
"Build/Rebuild Project"
That's it ;)
Realized I never answered this question. To solve this I grabbed the android-support-v4 from another computer and it worked. This could have the same effect as uninstalling and re-installing but i didn't try it.
At one point I had also found myself with the same issue. Apparently it is because whenever I decide to launch the Android SDK Manager within Eclipse I had been excluding an important step in the update process.
I always 'uncheck' the 'installed' option when trying to update. It was always my assumption that since the other checkmark labelled 'new/updates' would keep the updates visible to the installation. This actually is not the case though. Once I left 'installed' check-marked I saw updates from previously installed components. Then I was able to install the missing features that I thought were already up-to-date on my computer.
Hopefully, you find this helpful for getting the latest. It was misleading to me.
--Edit--
After getting the latest however, the post you referenced was what ended up resolving the issue for me however. I did not find a quick efficient way to sync with the latest version of the compatibility library. It is probably because on creation of the application it copies int he latest version locally into a project. So, you have to manually copy over the latest compatibility library.
Be sure to copy over the latest compatibility library however to all other supporting Android libraries that it also depends on as well. Otherwise you will get build errors with the new compatibility library in you local project settings.
You will need to get the Version 18 of the Android Support Library.
Make sure to update to that version using the SDK manager and then copy "android-support-v4.jar" and "android-support-v13.jar" to "libs" folders of your project.
That should take care of the issue.
Update your android support library from sdk manager.
Copy the android-support-v4.jar from \sdk\extras\android\support\v4 to your project's libs folder.
import android.support.v4.view.ViewPager.PageTransformer
Change ZoomOutPageTransformer implements ViewPager.PageTransformer to ZoomOutPageTransformer implements PageTransformer.
Thats it all errors will be gone and the animation works really well.

R Cannot be resolved in a freshly created project

I'm completely new to Android programming and there's this thing bugging me already. I get the R cannot be resolved error in a freshly created project! Because it's freshly created, I didn't edit it at all, so I'm sure it has no errors and it should just be a hello world program.
I checked and there's no
import android.R;
there and I have no idea what else could be causing this. Because of this error I can't even attempt practice in making layouts...
Try changing the project's API level, apply the changes and then revert to the old API level, then clean your project. I'm not sure how, but this worked for me sometimes.
To clean android project....
Window -> Preferences -> General -> Keys (**Ctrl+Shift+L**)
in type filter text write build clean.
here you can bind the key. for ex Ctrl+Shift+L
Another solution. I changed the target sdk to 2.1 after creating the project. Android showed no errors in the layout, so I restarted eclipse (cleaning didn't help) and then Android marked the layout with a red x. It didn't recognize the match_parent parameter since it was introduced in Android 2.2. The solution is to change the target sdk to 2.2 or use fill_parent or wrap_content instead of match_parent.

Categories

Resources