confusing about android minSDK - android

I have a question about minSDK. I took a project example in here: Contacts Providers.
This project has a minSDK = 5. And in styles.xml some attribute which require higher sdk version like:
android:textAllCaps --> min 14
android:fontFamily --> min 16
But that project so no any error and run fine.
When I copy some style into my styles.xml in my project. It causes an error:
android:textAllCaps requires API level 14 (current min is 11)
...
Can someone help me with the compile error?

You can use those styles in the respective minSDK version by using resource qualifiers. In your resource directory: there is base styles, add folders to res/styles-v14 (for use in ice-cream sandwich and greater, where minSDK is 14) and styles-v16 (so on so forth if you need the styles to be applied when available)
Now when the style needs a higher SDK version, place it in respective style resource directory. textAllCaps goes into styles-v14, android:fontFamily goes into styles-v16.
More can be found here on resource qualifiers ;)
http://developer.android.com/guide/topics/resources/providing-resources.html
Hope this helps buddy, happy coding!

EDIT: previously misunderstood the question/scenario. Sorry!
I think the problem is your Target API level. Make sure that the target api level is at least the level in which the APIs were introduced. In this case, 14.
If you build from command line you would just do
android update project -p -t
(I think what the command does is just update project.properties and sets target=android-14)

Related

Question about version specific resource file

My application support up to the sdk version 21, but I have some styles that work only for SDK 23+.
Should I only add a SDK 21 specific styles.xml, or should I also add a SDK 22 specific styles.xml ? Because they share the same problems.
No, you just need a general styles file, and a 23+ styles. Then anything below 23 will use the general file, and anything 23 or higher will use the v23 one.

no resource identifier found for android:elevation

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.

Android Styles and Values issue

My Android project was working fine when I noticed that I had checked SDK version 4.2 when I meant to target Google 2.33. I set the project back to G2.33 (In the manifest it minsdk = 8 targetsdk=11) and now I have errors on two different styles.xml files in two folders named Values-v11 and values-v14.
the styles.xml in the Values-v14 folder has an error on the following line...
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
the st yles.xml in the Values-v11 folder has an error on ...
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
My other projects, that all target 2.33 don't even have these folders. What is the best way of me getting out of this mess?
Thanks, Gary
You could simply delete these folders if you don't want anything specific for SDK level 11, and the one for 14 won't be used anyway if your targetsdk is 11.
If you want to retain the one for api level 11 for custom behaviour in API level 11, you need to set the project to compile with API level 11 - i.e. if in Eclipse, select the project, go to Properties, select Android and then set the project build target to "Android 3.0" or "Google APIs" for API level 11 if you need the Google APIs.

How to use "values-v11" folder with Xamarin.Android

The android doc here states that I can target Api Level 8+ devices and still specify that I want to use the Holo theme for devices that are API Level 11+. I should be able to do this using two themes.xml files :
One would go in /Resources/values for devices of API Level 8, 9 and 10
One would go in /Resources/values-v11 for devices with API Levels 11+
In a Xamarin.Android project, using Xamarin Studio it doesn't look like it's working, I get a compile time error :
Error retrieving parent for item: No resource found that matches the given name '#android:style/Theme.Holo'.
Am I doing something wrong here ? Is there a workaround ?
Theme.Holo is only available on API 11 and above.
If your project target is set to automatic, the system will build against the minimum level required (I think).
Try explicitly setting it to a higher API version.

No resource ident ifier found for attribute 'widgetCategory' in package 'android'

widgetCategory was added in Android 4.2 SDK level 17. I decompiled an APK with apktool, added the widgetCategory attribute to a xml file, and recompiled.
The error is this:
No resource identifier found for attribute 'widgetCategory' in package 'android'
I have tried using the latest aapt and changing the sdk level in apktool.yml but neither solved the problem.
Is there anything I need to change to add support for Android 4.2 to apktool?
Set build target to API 17. In Eclipse you can achieve this by right clicking on the project and choose Properties. Then, under Android, select Android 4.2 as build target. It's also possible to just open the file project.properties and set target to android-17.
You do not have to change either minSdkVersion or targetSdkVersion in the Android Manifest.
I just ran into this issue myself. You need to update the MinSdkVersion of the App (in the manifest.xml) to 17.
If it uses a MinSdkVersion below 17, it will not recognize the widgetCategory resource.
Cheers!
All the answers are geared towards someone using Eclipse and Java when the OP said he's using apktool. Most likely the problem is apktool is using a framework SDK file below level 17. https://code.google.com/p/android-apktool/wiki/FrameworkFiles

Categories

Resources