Androidx min sdk - android

What is androidx min sdk? I just migrated to androidx and i need to support minsdk 14. But my build fails indicating that androidx.browser:browser:1.0.0 has minsdk 15.
I can't find it in release notes or anywhere else

androidx.browser:browser:1.0.0 requires the minSdk = 15 (see) in order to function properly, so generally theres no way to support minSdk = 14 while still using androidx.browser:browser:1.0.0.
So basically you have these options:
a. Set minSdkVersion to 15 in app level build.gradle file(and stop supporting minSdkVersion 14)
However if u 'must' have to support minSdkVersion 14 :
b. You can add this line in AndroidManifest.xml file just before application tag:
<uses-sdk tools:overrideLibrary="androidx.browser"/>
this will ensure the project will run properly in most cases but it might lead to run time crashes in few occasions.If you are not really using some feature of the class that absolutely requires sdkVersion 15 then u might just get lucky.
c. Look for alternative classes that can do similar behaviour with minSdkVersion 14 (this might be extremely unlikely)
d. You can consider reverting back to android support libraries instead of androidx. Since, android support libraries will continue to stay around in the google's maven repo for a while.

As stated here:
Starting with Support Library release 26.0.0 (July 2017), the minimum supported API level across most support libraries has increased to Android 4.0 (API level 14) for most library packages.
AndroidX has started with the support library for API Level 28, so minSdk 14 will be the requirement.
For your artifact, the current stable version requires minSdk 15 and the current latest alpha release (1.2.0-alpha09) requires minSdk 16.
AndroidX browser is afaik a replacement / androidX version of Chrome Custom Tabs which had required minSdk 16, maybe this explains the sdk requirement.
By the way you can find the release notes here.

Related

How does Android Studio know about backwards compatibility issues?

I am trying to understand how Android Studio determines if a code is available in a certain API. When using MediaStore.setRequireOriginal, Android Studio warns me that "this call requires API level 29". Does Android Studio check that this code is available in previous Android version sources?
photoContentUri = MediaStore.setRequireOriginal(photoContentUri)
I am trying to understand how it knows this.
The linter just knows all the APIs in all the versions. You don't need to download all the previous Android version sources (I was wondering how Android Studio's Linter knew about older versions when I only had API level 29 and 30 sources downloaded on my machine).
As you can see, lint now has a database of the full Android API such that it knows precisely which version each API call was introduced in.
Lint API Check page
The Short Answer:
It's set by the developer, And Android Studio just compares your minSdkVersion set in build.gradle file with the required api level.
The Longer Answer:
When you get this warning on a method, just CTRL+click on it to go to the source class, and there you will find it annotated #RequiresApi or/and #TargetApi, for example :
class MediaStore{
#RequiresApi(api = 29)
#TargetApi(29)
void setRequiredOriginal(...){}
}
Your build.gradle file:
defaultConfig {
minSdkVersion 23
...
}
Android Studio compares minSdkVersion to #RequiresApi or/and #TargetApi at the time you call the method MediaStore.setRequiredOriginal(...); and warn you if minSdkVersion is less that the recommended api.
Please note that there are differences between #RequiresApi and #TargetApi, sometimes you find them used along with each other but sometimes just one of them.
For more about difference between the two see: https://stackoverflow.com/a/50578783/10005752
There is something in build.gradle of application module like:
defaultConfig {
minSdkVersion 23
targetSdkVersion 30
}
So you can change the "minSdkVersion" to 29, and the warning message disappear ...
And if not:
With android OS version >= 29: your code works normally
With android OS version <29: might be an exception occurs

Android, Is it possible to use on old release version of Google Admobs dependency release?

When I try to create Google Admob banner on my project, I receive an error like this below. I want to ask that, is there a solution without changing the minSDKVersion from 14 to 17? Maybe using an old release version of google ads dependency implementation on build.gradle file? If yes, is there any drawback doing this?
Thanks..
Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 16 declared in library [com.google.android.gms:play-services-ads:19.1.0] C:\Users\SAMSUNG\.gradle\caches\transforms-2\files-2.1\3f183cf0518755adc969c4fb4eee168a\jetified-play-services-ads-19.1.0\AndroidManifest.xml as the library might be using APIs not available in 14
Suggestion: use a compatible library with a minSdk of at most 14,
or increase this project's minSdk version to at least 16,
or use tools:overrideLibrary="com.google.android.gms.ads.impl" to force usage (may lead to runtime failures)

what is the new version of styleabletoast

Manifest merger failed :
uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.muddzdev:styleabletoast:2.1.2] C:\Users\java\.gradle\caches\transforms-1\files-1.1\styleabletoast-2.1.2.aar\9c4fc146927a85bf2fdc6fca1c3fb32a\AndroidManifest.xml as the library might be using APIs not available in 15
Suggestion: use a compatible library with a minSdk of at most 15,
or increase this project's minSdk version to at least 16,
or use tools:overrideLibrary="com.muddzdev.styleabletoastlibrary" to force usage (may lead to runtime failures)
Suggestion: use a compatible library with a minSdk of at most 15
It's pretty clear what you should do.
Library supports minsdk >= 16 only so, change your minsdk to upper than 16 or equal.
Also, if you're looking for new version of a library, search the library name and version like this: com.muddzdev:styleabletoast:2.1.2 then you'll see results which includes library's github page and maybe more. So, they should be providing the latest versions on their github page but if you still couldn't see it, look for where the author of library uploaded. for e.x: maven, jcenter or whatever then you'll be able to see the latest version on the library's page.
You can find all available versions here:
https://mvnrepository.com/artifact/com.muddzdev/styleabletoast

How to upgrade project targetSdk from 19 to 23

Currently I am using target 19 (Android 4.4) and i have attached support library v4 in jar. I want to upgrade targetSdk to API 23 to handle Runtime Permissions, hovewer there is no clear explonation in web how to do it, and changing targetSdk in Manifest and gradle isn't enough because classes responsible for runtime permission from API 23 are not found.. could you tell me step by step what should i do ?
And second one : should i use android-support v4 or v7 or other version ? what you would advice ?
support library v4 in jar
Why jar and not compile ... in build.gradle?
hovewer there is no clear explonation in web how to do it
There tons of posts and plenty of libs that can help. Just google for it.
changing targetSdk in Manifest and gradle isn't enough because classes responsible for runtime permission from API 23 are not found
You need to change build SDK to API 23 to compile that code.
should i use android-support v4 or v7 or other version
Runtime Permissions are not related to support library. Leave it as is.

Can I use Widgets from support library of Android L Preview in current Android Version?

I am trying to use RecyclerView & CardView in existing Android version. They said it is in support library. So, I should be able to use those with put "compileSdkVersion" to "Android-L". Right ?
I am trying to use those widgets without Android L Preview device or emulator.I have checked other questions on this matter. But, seems they all are trying Android-L with Android-L version.
Here is my dependencies.
compile 'com.android.support:support-v4:13.0.+'
compile 'com.android.support:recyclerview-v7:+'
Here is my target config
minSdkVersion 15
targetSdkVersion 20
Thanks in advance for any idea.
I just found the solution.
The reason why I can't build the App with RecyclerView & CardView while the targetSdkVersion and minSdkVersion is not "Android-L" is because internally Google designed to treat the preview version of OS differently comparing with original releases.
When I compile the App which contains the components from Android-L, the build tools locked minSdkVersion and targetSdkVersion to same level. The new supports libraries (RecyclerView, CardView, Palette, etc) are also locked into the L API level.
This behaviour is only happening on this Android-L preview release.
The fix for it is to put the following in AndroidManifest.xml.I didn't need to change anything on my gradle script.
<uses-sdk
tools:node="replace" />
Since version 0.11 of Android Gradle Plugin, it turned on a new Manifest Merger by default. It allows us to do some niffy stuffs. This specific configuration tells the manifest processor to replace any attributes from uses-sdk nodes in lower-priority manifest (such as library manifest in this case) with this attributes.
Since Gradle also inserts minSdkVersion and targetSdkVersion from your build.gradle into this uses-sdk node, that's all we really need to add.
Check here for more information related to this issue.
Check here for the info related to Manifest Merger.
The best solution is RecyclerViewLib. The support library has been pulled into a repo and published on maven central. It'll be safe even after L is released as all L dependent code has been removed. The author explains it here in his blog post.
To use it in your project just add the following line in your build.gradle dependencies:
compile 'com.twotoasters.RecyclerViewLib:library:1.0.+#aar'
Good luck!
No you must set targetSdkVersion above 7. You can use android support library v7 with project that support android above 7 api level.
And one more. Android L has api level 'android-L', not 20. Under the hood it has api level 21 (20 is 4.4W, KitKat for wearables).

Categories

Resources