Whenever I create a blank activity layout file assigned to be rendered at API level 22, following error message is generated
The solution to this is to change the API level by changing it to API 21 or less.
What is the reason behind this?.
This was very common for me when a new API SDK version was released and yes like you mention we have to change the Android version to use when rendering layout in the IDE.
But this time i have installed all the elements described in the Android SDK Manager for this API 22 and I have no problems with the rendering.
You can just change "AppTheme" to another theme and keep the API level as you desire.
Many users are reporting this problem and it happens only in the Layout files that uses support libraries and not the normal ones.
Related
AS 4.0.1
Use app:drawableEndCompat instead of android:drawableEnd warning on API 21 and above
<TextView
android:id="#+id/tvCheckStock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableEnd="#drawable/ic_pin_drop
android:gravity="center_vertical"/>
The ic_pin_drop is a SVG (Vector Drawable) that was created using Android Studio File | New | Vector Asset | Configure Vector Assert
In my Build.gradle file I have the following configuration:
minSdkVersion 21
targetSdkVersion 29
vectorDrawables.useSupportLibrary true
As the min is API 21 which is Lollipop I was thinking that vector drawables are supported out of the box and we can use the DrawableEnd, DrawableStart etc without the compat versions?
I was thinking that the compat versions were for pre 21 API level. Kitkat and below. And as I am not targeting that minimum I am not sure why I am getting that warning.
This would result in a cash on those devices less than 21 if the compat version is not used.
Many thanks for any suggestions.
The primary motive behind this warning is to make your VectorDrawables look same on all devices by making them backward compatible.
By using "Compat", you would be ensuring that using your vector asset would not crash your app for devices below API 21(Lollipop). In short, using drawableEndCompat would allow anyone to use the same features of drawableEnd on older APIs(<21).
Now you would be thinking that what should I choose:
If you are using drawableEndCompat, it would work as you expect in every device. Devices with API more than 21 would internally unwrap them as normal drawableEnd as far as I know.
If you choose to use drawableEnd, it will be working for API 21 and above only.
If you think that I don't need any Compat Support : You may increase your application's minimum SDK from current value to atleast 21. Then you can use keyword drawableEnd peacefully without any warning.
Also, you may opt to create different layout file for different APIs under which in layout file for below API 21, use drawableEndCompat and for API 21 and above use drawableEnd. In my opinion, you can also check whether you can use both attributes at same place. I feel like that they can work together as well.
If you are not supporting devices below API 21, there is no problem: You should have no issues/warning. Also, one more thing I need to tell you - Android Studio sometimes throw warnings or bugs; even if you are right. In that case, if you feel that you were correct, you should try invalidate/restart option after clicking File option in Menu Bar. I would also suggest to try restarting your system to everyone who are using system for long durations or always keeping it on sleep mode.
So, for a TextView, you should use app:drawableEndCompat (or start, top, bottom) instead of app:drawableEnd
Vector drawables are supported since API 21 but new features are added over time, even to vector drawables. It may be a good idea to use AppCompat and not worry about that.
Tinting compound drawables on TextViews was added in API 23. The suggestion is pushing you towards the compat variant, where the feature is backported.
app:drawable*Compat
app:drawableTint and app:drawableTintMode
If you don't use compound drawable tinting you may be fine with the platform version of the attributes.
android:drawable*
android:drawableTint and android:drawableTintMode (added in API 23)
could anyone please help me with this?
I opened an existing project and I get this error in the screenshot.
The problem is that you are using a style which require API 21. You are referencing a style called Widget.Material.ActionButton. So you need to put this reference in a v21 directory to use the CompatLibrary which I would recommend.
The real cause seems to be that you have a very low target SDK (like you wrote in the comments API 8). You should set it to the most newest one, it cannot break anything. So set the target SDK to API 21 or newer and it should work fine.
I am developing an app for Card View.Implement two features of card view "setRadius()" and "setElevation()" .It is working fine in Android L.
But when I run the app in API 19 (KitKat) , card view setElevation() getting an error
java.lang.NoSuchMethodError: android.view.View.setElevation"
Can any one please help me to make this app compatible to all version.
possible duplicated.
Android AppCompat 21 Elevation
Basically setElevation from ViewCompat won't even work.
Take a look at the docs for setElevation and you can see that it was added in API 21 (which is Lollipop).
You can, however, use the ViewCompat library's version of setElevation, and then it should work on lower API levels.
I want to use circular-progress-button on android 2.2 or above. But there is a error on Property class that say minimum sdk must be 14.
I don't want to check sdk version and then use or not.
Or even is there any alternative library like this?
If you want to remove that error maybe you need to increase android:minSdkVersion to 14, which means you cant support bellow Android 4.0.
But there is another library with android:minSdkVersion=11. You can use that library too. Here is the link:
FABProgressCircle
I am learning how to develop Android apps, using Eclipse. New to all of this, and apparently there is a bug that messes up the "Graphical Layout" pane of Android XML files when you add a box of plain-text. I've read solutions saying to change the input type, but I'm not deep enough into Android for it to really make a difference between using API 16 or 15. I am currently using 16, I downloaded 15 today, and am trying to find a way to make Eclipse use the older API. How do I switch Eclipse over to use API 15 instead of 16? (I'd prefer not to uninstall API 16, but if I must, oh well).
Open the manifest file and change the line
<uses-sdk android:minSdkVersion="number-of-version-you-want" />