It appears the best way to develop an Android application today is to target android-17 in project.properties along with minSdkVersion "whateversuitsyou" and targetSdkVersion 17 in the manifest.
In this configuration, the standard lint checks will notify about any API calls which are only available in API versions above "whateversuitsyou" and one can use reflection etc to dynamically support the newer features, if any.
However, in this setup, at least without further configuration, it is possible to have style and theme attributes in XML not placed in the appropriate folder, like referring to "Holo" elements in the default resource folder when "whateversuitsyou" is smaller than 11 aka Honeycomb.
It seems apps will not crash if they encounter unknown XML style attributes. LogCat will show an error, like "Style contains key with bad entry".
Not sure whether the whole style is checked upon app startup; if so, it is certainly possible to run the app once on every API version to check for any problems. However, that's not exactly desirable. Besides, styles and themes are not the only version specific resources.
Is there a way to make lint check the resources in general against minSdkVersion and API versio XY for folder *-vXY? Can someone shed some light on this?
Luckily, with the current (updated) configuration, this has become a non-issue, because the development framework handles the situation just the way it should.
Example:
project.properties:
target=android-11
AndroidManifest.xml:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
You can now use API 8 XML style and theme attributes everywhere and API 11 XML style and theme attributes in -v11 subfolders.
Works with Eclipse Juno Service Release 1, Android SDK Tools 21.1 and Android SDK Platform-tools 16.0.1.
Related
As per guidelines here for Android L development, I used android:elevation property in my application, but it shows the following error:
No resource identifier found for attribute elevation in package
android
I am using eclipse and I have downloaded the latest version just 2 days ago.
I have also set my target sdk as API level 21 and minimum as API level 14. I have also installed the latest updates on sdk-build tools shown in sdk manager.
Anyone know the solution? plz help me.
1) Select Project > Right Click > Properties > Check Android L > apply > Ok
2) android:minSdkVersion="L"
Hope this will work for you.
One thing worth noting is that Android Lollipop corresponds to API level 21. There is no such thing (yet) as API level 22.
You should be able to solve your problem by setting android:minSdkVersion and android:targetSdkVersion to "21".
Select Project, then Properties, then Android and tick Android 5.0. Ignore all the answers telling you to set android:minSdkVersion. Android is designed to ignore stuff inside elements it does not understand just so that in this case you can apply elevation when running on lollipop devices and it is ignored on earlier devices.
You can hide the remaining lint warning in the xml file by adding tools:ignore="NewApi" in the element. This needs xmlns:tools="http://schemas.android.com/tools" specified in the root element.
AppCompat v21 allows a fair bit of Material Design to be used on pre-lollipop devices, but I've yet to work out how to add it to a project in Eclipse.
android:elevation or View.setElevation() is introduced since Android API 21. So, if you set android:minSdkVersion="14", it's not OK. android:minSdkVersion="14" is integrant.
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
As recomended here http://developer.android.com/guide/practices/screens_support.html for compatibility reasons my AndroidManifest.xml contains this:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
This generates warning in eclipse:
Attribute minSdkVersion (3) is lower
than the project target API level (4)
Are there any means to suppress this warning or get rid of it any other way? It is really annoying.
In short, there is no built-in way to do this that I know of.
Here's a discussion from last August.
And here is a Xavier Durochet's response.
It looks like you can manually remove it according to Mark Murphy's response in the first thread:
Or, you can modify SetupTask.java, eliminate this test (lines 297-308 in
the code indexed by Google Code Search), and build it into a custom
version of the Android Ant extension
There is a feature request that may deal with this, but who knows when it will be implemented.
The answer from 2011 is no longer accurate. It was fixed in ADT 17 according to this bug.
This warning is an usual one. I am using minSdkVersion to support Android 1.5 and I am building for Android 1.6 to support small screens. You can build your application with the latest Android 2.3 library, but still support a lower version.
i am making a gigantic app for android, and i start doing it some moths ago for android 1.5, but now i know that some of the things i need for my app only can be done if you are programming for 1.6 api.
there is a easy, fast and safe way to migrate my app from 1.5 to 1.6 without having to lose time?
thanks
Since you are going to a newer version, I don't think that any code changes will be needed.
You need to:
1) Update the minSdkVersion in the AndroidManifest.xml. For android 1.6 it should be minSdkVersion = 4. If you don't have that already, it is a good practice to always include it in the manifest. Add this line:
<uses-sdk android:minSdkVersion="4" />
as the last line before the closing tag of the manifest.
2) Change the target (again to 4) in your IDE or ant build scripts. In Eclipse right click your project, select Properties, Android and change the Project Build Target. Your project will recompile, when you click the Apply button.
Then, do a re-compile. I don't expect any errors to occur, but if they do, they will only be a few and you will be able to correct them quickly.
I use the following in my manifest file:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
At the same time I have configured Eclipse to use the Android 2.2 API. This way I ...
support small screens
can use the latest features (as long as I do it with care)
android 1.5 users can still use my app (as long as I make sure it degrades gracefully)
See http://developer.android.com/guide/appendix/market-filters.html
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)").