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.
Related
Our Xamarin.Android app is targeting Android 4.4 due to hardware constraints. The initial solution was created targeting API 23 and was downgraded. The above error is thrown after downgrading. The code referenced by the error is as follows:
<include layout="#layout/abc_screen_content_include"/>
<android.support.v7.widget.ActionBarContainer
android:id="#+id/action_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
style="?attr/actionBarStyle"
android:touchscreenBlocksFocus="true"
android:gravity="top">
<android.support.v7.widget.Toolbar
android:id="#+id/action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:navigationContentDescription="#string/abc_action_bar_up_description"
style="?attr/toolbarStyle"/>
<android.support.v7.widget.ActionBarContextView
android:id="#+id/action_context_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:theme="?attr/actionBarTheme"
style="?attr/actionModeStyle"/>
</android.support.v7.widget.ActionBarContainer>
This error was replicated after creating a new solution targeting API 19 Android 4.4.
How do I remedy the above error?
Hit this in Xamarin Forms Project. Got this lovely:
"No resource identifier found for attribute 'touchscreenBlocksFocus' in package 'android' App1.Droid C:\dev\xamarin\dev\HWVFromScratch\App1 App1.Droid\obj\Debug\resourcecache\C6193E5D3119528BCA215B6037E272DE\res\layout\abc_screen_toolbar.xml"
To squarely target KitKat
Go into your Droid project properties
Set "Compile using Android Version" to "Use Latest Platform"
Set Minimum Android to Android 4.4( API Level 19 - KitKat )
Set Target Android version to Android 4.4 ( API Level 19 - KitKat )
Compiled like a champ. Screenshot of settings below...
This basically means that the Google tool aapt which is used to compile resources for your app doesn't know how to handle the touchscreenBlocksFocus attribute used somewhere in your resources (or in this case likely in the resources contained in the Android Support Libraries).
First it's worth reviewing my blog post explaining the various places API Levels are used in Xamarin.Android apps: http://redth.codes/such-android-api-levels-much-confuse-wow/
So in this case, your project's Target Android Version is what Xamarin.Android is passing to aapt as the API Level to build resources against.
This means you'll need to set your Target Android Version to a higher API Level (4.4 won't cut it) which understands the resource attributes you are using.
Of course, just because you change your Target Android Version doesn't mean you can't still have a lower Minimum Android Version specified, and your app can then still run on older API Levels.
Finally, it's generally best practice to set your Target Framework Version and Target Android Version to use the Latest SDK version available to avoid these types of issues. Then, set your Minimum Android Version to a lower API level if you wish. Of course you'll have to be aware of the API's you are using and that you take appropriate steps to gracefully avoid using API's that aren't available on a given version of Android at runtime.
It's been a month, but I would like to try and answer your question with the solution I had.
The problem I ran into was that I attempted to use Xamarin.Forms instead of functions/commands/API from the standard Android libraries.
One of the ways to install Xamarin.Forms is to use nuget - which I did. This however caused all kinds of problems, one of which you are experiencing.
So in order to stop these errors I had to remove several dependencies/references within the Xamarin Project by going to Project -> Edit References -> and on the right hand side of the window removing any Xamarin.XXXXX you might see starting with the obvious Xamarin.Forms and working your way through until you can finally compile your project successfully again.
While this was an answer to my similar issue, if you absolutely have to use Xamarin.XXXXX then this won't fix your issue as you are going to have to use the tools supplied by Android.XXXX.
I research material design project for 4.x API, It seem too many problems in style values, always style.... (in v-21) not found. I think v-21 is only build with api 21. But I want to build for 4.x API, do anyone know problem?
Here is some project in Github i found:
https://github.com/wasabeef/awesome-android-ui
https://github.com/rey5137/material
I use eclipse too. Change ANdroid API 21,22,23 but it still not work
The Log say : no resource found that matches the given name "TextAppearance.Appcompat.Body1"
Here is my picture:
OTHER QUESTION:
The Author say this material project can run on API 2.x -> 4.x , but why it need to build with API 21 -> 23? So can lower device can run it?
Set compileSdkVersion 23 or 21 or above in your build.gradle file.
The Log say : no resource found that matches the given name
"TextAppearance.Appcompat.Body1"
This is because you might not have imported AppCompat Library to your Eclipse Project.
The Author say this material project can run on API 2.x -> 4.x , but
why it need to build with API 21 -> 23? So can lower device can run
it?
Yes, Its always a good practice to build your App with the latest API version as this will include all the updated resources which might be not available in previous versions of Android. However, this will not affect your APK size in anyways.
I am trying context.getExternalFilesDirs(null) to get paths for mounted storages. I intend to use this method keeping in view the new restrictions imposed by android in Kitkat. When I write statement to make a call to the method it gets underlined in RED with message as shown in image below:
I have checked all installations required to support API level 19 and everything seems fine.
My application is targeted for API 19 with minimum sdk version set to 16.
I have checked it a lot and looks like no one has faced this issue. I don't know what can possibly go wrong here but if you have any idea that where I am doing wrong please identify. Thank you
This is how I resolved the above issue.Right side click on Project -> Properties -> Android -> set Project Build Target to > Android 4.4.2 -> Apply
Check the documentation ,
getExternalFilesDirs()
has been added with API 19, and your min SDK is 16, you have to check that when you run on devices less than API 19 and there by organize your functionalities.You can Use TargetAPI annotation and then red underline will be removed.
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)
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