Error with new/old project because of AppCompat - android

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

Related

Android project suddenly full of errors because of different supporting librarys

So i wanted to add a facebook SDK to my android projects, the outcome was this:
I've decided to "undo" changes first so i removed the facebook library from my project
after:
The error is "R cannot be resolved", if im importing android's R it wont recognise the layouts anymore
for example:
My libs are:
I've tried removing support v4/v13 but neither helped. Im clueless, please help.
Copy/Paste the same latest v4 library in all the projects,

Adding Support Libraries to Android project

Why am I having such a hard time getting into the swing of Android development? I've been developing in various languages over the years and, for some reason, just can't seem to get beyond that "jeez-i-still-feel-a-total-noob" stage with Android.
So I'm trying to add an Action Bar to my Android 2.3.3 project. No problem, right? The Android developers website has a nice and clear article explaining exactly how to do it. Of course it involves adding the appcompat v7 support library. No problem, even this is documented step-by-step on this page. But, as with just about every such exercise in Android, I find that you can do exactly what the page tells you to do, it still won't work without significant amount of Googling to fix the errors that you encounter afterwards.
So I've followed the steps under "Using Eclipse" in the section "Adding libraries with resources" in the above link. The first error I get is Unable to resolve target 'android-16'. No problem, this one I could figure out for myself but I'm curious, is there anything in the documents I've been following that would have suggested to me that I need Android 4.1.2 (API16) installed? Did I just read right over it or should I have known by myself that, to do what I'm trying to do, I would need API16?
Never mind, at least I can fix that but then I get a new problem. As soon as I add the android-support-v7-compat library to my project and click the OK button, the console output lights up with errors, the first one being:
C:...\android-support-v7-appcompat\res\values-v14\styles_base.xml:24:
error: Error retrieving parent for item: No resource found that
matches the given name 'android:Widget.Holo.ActionBar'.
and the other 60 odd errors are similar but for different given names.
I would really appreciate if anyone could help me out here. Obviously I'd like to know how to solve this particular problem but if anyone could give me some tips on how to get past this very frustrating stage of learning this new development environment, I would be ever so thankful. What is it that I should have done differently not to run into these kinds of errors, other than following the instructions on the Android Developers website step by step?
OK, I guess I should post an answer as I've eventually managed to solve my own problem.
It turns out I have to use a build target of Android 4.2.2, regardless of the fact that I'm specifically developing for Android 2.3.3 - I mean, that's why I'm using support libraries after all. I imagine it might be possible that some other lower target (but higher than 2.3.3) would still work I just used the highest one I have installed and it solved the problem.
How I was supposed to know this from following the step-by-step instructions on the Android Developers website is a mystery to me. The reason I decided to try changing the targetSdkVersion was because of the final section in the page referenced in the question. It reads "If you are increasing the backward compatibility of your existing application to an earlier version of the Android API with the Support Library, make sure to update your application's manifest." Now I'm not increasing the backward compatibility of my existing application. I'm changing an existing application that targets 2.3.3 to be able to include an Action Bar (seems more like "forward compatibility"). I tried upgrading the targekSdkVersion though as I was out of ideas and lo and behold, it worked.
Don't know if it helps you at all, but I've been struggling with a similar issue for several hours and finally managed to resolve it. In my case, inside my own project's styles.xml file, I was referencing the AppCompat style in the wrong way in the parent attribute.
I was using:
<style name="AppBaseTheme" parent="android:Theme.AppCompat">
where I should have used:
<style name="AppBaseTheme" parent="#style/Theme.AppCompat">
My mistake was in the reference to the theme.
I found that setting the Android target to 2.3.3 for the library project android-support-v7-appcompat solves this issue. You don't need to set your project's target higher, but the library's target lower.
You have pinpointed the all important document and the relevant section "adding libraries with resources":
http://developer.android.com/tools/support-library/setup.html
The error suggests that your project is not able to find these resources. Please double check the following :
You have checked "is library" on the library project
You have exported the jars IN THE LIBRARY PROJECT as described in that section
You have added the library project as a reference to your app project
You have added the android-support-v4.jar to your libs folder in your app project
If this is all definitely correct, check eclipse for any error messages - is it the library project or the app project that lights up like the proverbial Christmas Tree ?
First of all check if you have done all the described steps as explained on the developers site. Then, for the errors :
Unable to resolve target 'android-16'
Make sure that you have installed API16, this errors occurs if you have mentioned your targetsdk to 16 in your Manifest while the sdk for API16 is not installed. You can either install the API or edit the targetApi of your project to the minimum required version, for the support library you are using I think API 11 is the minimum required android version.
android:Widget.Holo.ActionBar
This error should also be fixed once the targetsdk is fixed in your project. Since to use Holo.ActionBar you'l need to target your project to minimum supported api level ie. 11 or higher.
I met similar problems. Using API 18, ADT.
To solve the "Unable to resolve target 'android-16' problem", I remove the import lib project and repeat what the tutorial says.
Then I found I couldn't really "add" the library to my project. (The instruction "In the Library pane, click Add." there is not that detail.
1. In your project -> properties -> Java build path -> Libraries -> Add Library... -> Android Classpath Container -> Select the lib project
2. In your project -> properties -> Android -> add... -> choose the lib -> apply
cheers
Here is how I avoided the error, " Unable to resolve target 'android-16'", when adding v7.
First, I followed the instructions for adding support libraries with resources in eclipse. Following step 4, I clicked Finish. That's when I saw the error message, android-support-v7-appcompat] Unable to resolve target 'android-16'.
Second, I read this post. I also opened the download manager, but did not need anything updated. In order to make sure that I followed the steps exactly as correctly as I could, I deleted the android-support-v7-appcompat project and started over.
This second time I didn't check any different boxes, after all. But, I also got no errors at step 4. Who can say why?
Thanks, Dewald, you expressed in this question the same frustration I have. Is experience the only way out?
If some of your resource xml files cannot find their respective AppCompat references, make sure you also add the support libraries to your project properties. You do this by:
1.) right clicking on your project in the project
2.) Select properties. (Bottom of the menu)
3.) click Android on the left hand side menu of the new pop up window
4.) In the libraries section, click the "add button"
5.) Select the respective libraries. (If none show up, check to see if they are already displayed in the "libraries" window of the pop up menu. If there is a red x by the desired library, try and resolve that issue first.)
6.) Once there is a green checkmark next to the desired libraries, make sure the "Is Library" option in the libraries section IS NOT selected.
7.) Click apply.
8.) Close the pop up menu.
If this doesn't work, let me know and I can help you out. I spent three hours on the problem so I know pretty much all the possible things that can go wrong with the set up.
Go to Project -> uncheck Build Automatically
Go to Project -> Clean... , clean both the library project and your app project
Export your app as a signed APK while Build Automatically is still disabled

unable to instantiate application - ClassNotFoundException

EDIT: This problem has not already been resolved in the other suggested SO question
I had a fully working app on the market for over a year, with very few crash reports. Then recently I changed my app into a library, so that it could be included within multiple different "wrapper" projects. This was so that I could easily make different version - free, paid, non-google markets, with/without in-app purchasing etc etc.
The new "library+wrapper" app appeared to work fine. I could run it multiple times, without error. But then a day later (when presumably the OS had closed some or all of the app's activities) I tried to run it and it reported
Unable to instantiate application com.mycompany.mygamelibrary.MyGameApplicationClass: java.lang.ClassNotFoundException: com.mycompany.mygamelibrary.MyGameApplicationClass
The class it failed to find is the first class that runs when the program starts up, MyGameApplicationClass - which extends Application. This class is part of the library.
I suspect something goofy in one of the two manifest files.
The manifest of the wrapper project contains the lines...
<application android:icon="#drawable/mygame_icon"
android:screenOrientation="portrait" android:label="My Game Name"
android:name="com.mycompany.mygamelibrary.MyGameApplicationClass">
Any ideas what could have gone wrong?
EDIT: The library was referenced "the correct way" as defined by yorkw's answer to this SO question.
EDIT: I can not repeat the crash at the moment :-( I don't know what it is the OS does when the app is not used for a day or two.
There are two possibilities. Either you, like me, have a spelling error in your manifest file. Have a co-worker or friend read it to make sure the name is correct. Or you have not referenced the project correctly.
The official document describes how to properly link projects in its documentation.
Why it would first seem to work and later stop working is a bit of a mystery. However, I guess that the VM might still have had the necessary references ready to resolve the classes in the library just fine. A restart of the VM removed all those references and trying to resolve them was unsuccessful.
Update: Regarding the edits in the OP: As you confirm that you have correctly referenced the other project, you can check if the project is included in APK, just to be sure. You can rename and open an APK as any other archive (.rar works fine for me). Sometimes, it happened to me, the project is not correctly included in the APK. A cleaning of your workspace usually remedies the problem and so could a restart of your IDE depending on what you are using. To manually conduct a clean in Eclipse for example, use Project->Clean... or try Android Tools->Fix Project Properties by right-clicking on your project.
As you seem to also have fixed the problem by restarting your device, it could be that the libraries were linked incorrectly. A problem that I have never seen myself but as a very common quote says: "Have you tried turning it off and on again?".
For Android Studio:
Build --> Clean Project
Fixed issue.
Have you tried to make a new subclass of MyGameApplicationClass in your 'main' project and set it in the manifest as Application class?
I had a slew of bugs with Android Studio 3.0 Canary 4 and the way I fixed them was by editing the AndroidManifest.xml by adding in some jibberish to the application name. Then, I clicked build. Obviously, a whole mess of new error messages appeared. I changed the name back to what it should be, built the app, and it just ran.
Sometimes, I just don't know...
EDIT: Just ran into this issue on Android Studio 3.0 Canary 4 on my laptop when switching over. I again went through the same process of changing AndroidManifest.xml file to contain a typo, building, and changing back. That didn't work.
I then noticed that instant run was still enabled. Going into settings (by clicking command + , (comma key)) and typing "instant run", I was able to disable instant run, built the app, and the error of class not found went away.
Summary of Steps to Fix [FOR ME]
Invalidate cache / restart
Clean the project
Manually delete the build folder (need to be in project view for this one)
Make an intentionally errant edit to your AndroidManifest.xml file, build the app, observe the errors, remove the errant edit and build again
Disable instant run
Again, I don't mean to insinuate that this will fix everyone's error, but I have now used some combination of these steps on two different machines (MacOS Sierra) and it has been resolved for me. Hope it helps.
In my case, application id and package were mismatched. This should be same as presented in following images...
AndroidManifest.xml
app/build.gradle
In this case you can see, applicationId and package both are same that is com.mycompany.mygamelibrary
May be its a Build Path Configuration problem.I did the following to solve the issue.
1.Right click on your project and go to Java Build Path.
2.Click on Order and Export tab.
3.Check Android Private Libraries and other 3rd part libraries if you have added.
4.Press ok and clean the project.
I hope it will solve the issue.
Once I had the same error message, but maybe the cause isn't the same.
I did a code and worked for a while, then I wanted to improve it and got the same error and I couldn't run it.
I could fix the problem with
the correct Build Path order (as I can see you've already did this)
I check on the Order and Export tab the android-suppor-v4.jar
and the key was the Android SDK Managert->Upgrade everything and (next) Eclipse->Help->Check for updates.
After I upgraded to the latest android plugin and SDK my app compiled and ran again.
I hope this will help you!
I'm not very sure about this but it might be that your system's debug.keystore license validity has expired as it is valid for only 365 days. You just need to delete the debug.keystore from your computer. The debug.keystore will be generated automatically by Eclipse when you compile your Android App.
Same message seen ... this time it turned out to be different output folders for MyApp/gen and MyApp/src in the Build Path (caused by Maven integration).
Unchecking "Allow output folders for source folders" solved the problem.
I had this issue in an Android application that needed an Application class which was created in wrong path inside the Android Studio project. When I moved the class file to the correct package, it was fixed.
This all Process work for me to solve application class Exception.
Step 1: Open Run(window+R) Search -> Prefetch Remove all file (Some file not Delete)
Step 2: Open Run(window+R) Search -> %temp% Remove all file (Some File not Delete)
Step 3: Open Android Studio -> Build -> Clean Project
OR
Select File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio toolbar.
OR
Close and reopen Android project.
OR
Restart System
I ran into this issue several times and both times it seemed to be caused by some instant run feature.
In my case, deleting the application from the device and then installing it from Android Studio again resolved the issue.
I ran into this problem today. The project runs well for over a year but today it reports this issue, and cannot debug on my testing device.
I fixed it by updating to latest gradle version. Hope this can solve your problem.

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.

xmlvm - import errors compat libs in xcode

Does anyone know where the android compat libary is
located in xmlvm so I could copy it by myself to the project folder because this is
what I guess is missing, also would be provided by target=android-on-iphone but as mentioned below this target isn't available in the current build.
I had absolutely no problem installing xmlvm and getting in touch with the
demo/samples also all the demos worked perfectly for me.
But now im stuck at the last 4 errors in xcode, i migrated my android project via --
skeleton=android:migrate then cross-compiled it via --target=iphone and opened
up the project in Xcode. after few project setup changes the errors went down from
72 to 4 errors ;)
however the errors are importing file not found errors of compat libs, so this
should somehow get to be solved i think...
is it because --target=android-on-iphone wasnt used by me because this option
will copy the android compat libary to the project folder.. well i tried to use this
target mentioned in 2 documentations of xmlvm but in the actual build of xmlvm
this target however does not exist..
How to solve these errors?
Screenshots:
http://img526.imageshack.us/img526/8957/bildschirmfoto20120620u.png
http://imageshack.us/f/138/bildschirmfoto20120620u.png/
From what I can see, it looks like you are using part of the Android API which is not yet implemented.
Unfortunately it seems that you either need to rewrite your application or implement the API yourself.

Categories

Resources