Error while importing android samples to eclipse. - android

I have imported Support4Demos project from Android SDK (from directory extras/android/support/samples/Support4Demos/) into eclipse.
Initially I got more than 800 errors.
After adding android-support-v4.jar library to build path still more than 100 errors exist.
Probably all of them have the same cause - R class is not generated due to error in XML file.
error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo'.
As I understood - Holo Theme is missing..
Project is imported "as is" - no modifications were made. So I expect that should work.
Where is the Holo Theme? It is not part of Android SDK?
Which file should I copy to which directory?
Or should I add some reference?

The problem is very likely that Holo theme is for Android SDK 4.x and above and you are using some older SDK in your project. You are probably importing samples from a recent API and your project is using an older one.
Solutions are (descending order of how good the solution is):
Import samples targeted at the SDK you wish to use.
or
Change the theme of the sample.
or
Set up your project with a newer Android API (eg. +4.x).
You can also check this question: Trying to use holo theme in Android not working

Problem solved... I mean.
When project is imported into eclipse project.properties file is created. My eclipse creates file with target=8 inside. Probably it is lowest version which is installed. But I am not sure.
Holo theme is not part of Android Support Library so project should be compiled with Project Build Target set to platform version containing Holo Theme (3.0 or higher - API 11 or higher). It can be done via eclipse menu Project->Properties->Android or directly in project.properties file. eclipse automatically updates reference to the right version of android.jar platform library. Note that targetSdkVersion in AndroidManifest.xml has no effect (or?). I have this unchanged line in AndroidManifest.xml:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13" />
I have installed platforms of version 8, 10, 13 and 16. Project cannot be compiled with API level 13 due to another compatibility problem in AndroidManifest.xml.
So I can successfully build project only with platform version 4.1 (API level 16) - in other words with target=16 in project.properties file.
Small problem with running application - eclipse shows only Android 4.1 AVD (others are considered as incompatible and are hidden. My Samsung Galaxy Y Duos is showing also as incompatible, but application can run on it.

Related

adding android:widgetCategory="keyguard|home_screen" while still supporting older sdk

I am trying to modify my widget so that it supports being placed on 4.2 lockscreens. However I still want to support older SDK's.
I added
android:widgetCategory="keyguard|home_screen"
to my appwidget-provider in res/xml, but eclipse complains that there is "no resource identifier found for attribute widetCategory in package android'
If I raise the minSdkVerion to 17 everything works fine, but I want to still support older SDKs.
I have tried using resource qualifiers creating a separte res/xml-v17/mywidget.xml and only adding the tag there, but the error still appears.
Thanks for any help.
Edit:
I figured it out. using a res/xml-v17/ folder is the answer. I just had to change the build target for my project to 17 / 4.2.
I think that setting targetSdk to 17 is enough. XML elements that do not make sense on older SDKs are simply ignored.
No need to put mywidget.xml into res/xml-v17 folder
Put a copy of your mywidget.xml in res/xml-v17/ folder.
This targets Android 4.2 and all new "properties on the appwidget-provider element will be avaible. Also right click your project in eclipse and change build target to: API level 17/ Android 4.2
I saw your Edit. But i think this makes it more clear that this question have an answer.
UPDATE: I can confirm Tomáš Hubálek answer. the xml-v17 is not needed. Changing Build target is enough. Right click your project in eclipse and change build target to: API level 17/ Android 4.2

Phonegap 2.1 for Android - Hello World App 3 errors at launch

I developed something with Phonegap for iOS, but this is my first trial for Android.
I created my hello world application with CLI sth like this mentioned here:
$ /path/to/cordova-android/bin/create /path/to/my_new_cordova_project com.example.cordova_project_name CordovaProjectName
Even though I created this app in Eclipse Workspace, I needed to import it to Eclipse. I created two AVDs. One for API level 8, one for API level 16.
When I try to build, it gives me these three errors and a warning. What is wrong with my setup?
Description Resource Path Location Type
error: No resource identifier found for attribute 'hardwareAccelerated' in package 'android' AndroidManifest.xml /com.example.test.testprojectname line 20 Android AAPT Problem
error: No resource identifier found for attribute 'xlargeScreens' in package 'android' AndroidManifest.xml /com.example.test.testprojectname line 22 Android AAPT Problem
error: Error: String types not allowed (at 'configChanges' with value 'orientation|keyboardHidden|keyboard|screenSize|locale'). AndroidManifest.xml /com.example.test.testprojectname line 51 Android AAPT Problem
The import android.app.Activity is never used testprojectname.java /com.example.test.testprojectname/src/com/example/test line 22 Java Problem
Go to Project -> Properties -> Android and select a newer SDK (preferably the latest one), after that run Project -> Clean. That worked for me.
Check the minSdkVersion and targetSdkVersion attributes in your AndroidManifest.xml. It sounds like you're building the app for an older SDK version that didn't have the attributes that are producing the errors. Try to set both min and target to 11 and see what happens.
You should always be building for the latest SDK. It looks like your Eclipse setup is using an old version of Android (Android 2.2?). hardwareAccelerated and xlargeScreens is from Android 3.x. I recommend making sure your project uses the latest version fo the SDK in Eclipse. This has nothing to do with your Android Manifest, and is actually an eclipse setting.
By default android version is 2.1; you must right click on root folder of you project, select properties, then in android select new version; try to reload it and it wrok...
You should always be building for the latest SDK. It looks like your Eclipse setup is using an old version of Android (Android 2.2?). hardwareAccelerated and xlargeScreens is from Android 4.x. I recommend making sure your project uses the latest version of the SDK in Eclipse.
(or)
after creating your project Do the following steps
Right click your project -> properties --> change the Android target version as 4.x

Android Import incorrectly includes min SDK JARs instead of target

Hopefully I am not missing something obvious. I have done a good bit of work to isolate this issue. Say I create a new Android project:
Target Platform: Google APIs Android 3.1 (API 12)
Min Platform: Android 2.2 Froyo (API 8)
When the project is created, AndroidManifest.xml shows min=8, target=15 (not sure why 15 and not 12 actually, but that's not the issue). And this looks fine:
included JAR: Google APIs [Android 3.1]
project.properties shows target=Google Inc.:Google APIs:12
So far, so good.
Now, without even editing the fresh project, I remove that project from the workspace, move it somewhere, and import using Import->Android->Existing Android Code into Workspace.
Now:
Included JAR: Android 2.2
project.properties shows target=android-8
And the project now has errors due to things like the Holo style not being present in 2.2.
I tried Project->Clean, nothing. I tried Android->Fix Project Properties. No change.
The only fix is to remove the project, delete the project.properties, update the AndroidManifest.xml to use min-sdk 12, and re-import. Even, then, I don't get the Google JAR:
Included JAR: Android 3.1
project.properties shows target=android-12
It seems like the import process incorrectly uses the min SDK value instead of the target when creating the project. Or is this somehow expected behavior? What am I missing?
(This scenario may seem a bit contrived, but I am an instructor trying to import student assignments. So this is causing me difficulties!)
Right click the imported project and go to
Properties - Android - Project Build Target
Specify the build target as the target sdk version.
Now it should include the correct jar file.
Hope this helps

ActionBarSherlock not working in eclipse

I have been trying to get ActionBarSherlock ( http://www.actionbarsherlock.com ) working with my eclipse projects. I added ABS into a new project with target version 3.2, and this created fine. When I try to add this as a library to my other project (min version 2.1, target 3.2), I get errors such as
G:\EclipseWorkspace\Android\ActionBarSherlock2\res\values-v11\abs__styles.xml:65: error: Error: No resource found that matches the given name: attr 'android:windowActionModeOverlay'
basically, none of the xml attributes found in 3.0 or higher are recognised. As a consequence, R.java does not generate.
Am I doing anything wrong?
You need to compile with Android 3.2 in addition to targeting at least API 11 both in your app and for the library.
In eclipse, right click on the project and go to "Properties". Under the "Android" tab you'll need to select Android 3.2.
Eclipse is giving me strange Errors too, when implementing external libraries. What always helped for me after some tries:
try multiple times:
*rightclick on your project => Source => Clean Up
*delete and readd the library project
*restart eclipse several
you might also try to delete the generated files to force it to regenerate, but do this on your own risk :)
have fun w/ the open source libraries :)
Try upgrading the version of the sdk and target version 2.1:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
This will allow using last sdk features and the app will work on version 2.1.
Maybe, you'll see issues even after fixing this. Then you can clean the project.

Not able to use new resource identifiers in Android with targetSdkVersion defined in manifest

I'm developing an Android application that I'd like to be compatible with 1.5 (SDK version 4). I'm testing the application on 2.2 (SDK version 8). To do this, I'm including in the manifest file the line
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
I thought this would allow me to use the newest manifest elements and APIs, but I'm getting a compile error whenever I try to use them. For example, I try to define the element installLocation to allow the app to be installed on the SD card, but Eclipse gives me the error
No resource identifier found for attribute 'installLocation' in package 'android'
Is there something else I have to do to get this to work? If I can't get this to work, what benefit is defining targetSdkVersion?
Make sure that you are using building against the android 2.2 jars. Right click on your Eclipse project, choose, properties, go down to Android and make sure the correct sdk is selected.
Change the build target by editing the project properties in Eclipse, and choose a target with at least API Level 8: ("I'm testing the application on 2.2 (SDK version 8)").

Categories

Resources