The problem about Google Play's target API level requirement - android

From the article https://developer.android.com/distribute/best-practices/develop/target-sdk,
Google Play will require that new apps target at least Android 8.0 (API level 26) from August 1, 2018, and that app updates target Android 8.0 from November 1, 2018.
The following code is from my app.
1: Does it mean that targetSdkVersion must be greater than or equal to 26 ?
2: Does it mean that minSdkVersion can be 21 ?
Code
defaultConfig {
applicationId "info.dodata.mirror"
minSdkVersion 21
targetSdkVersion 26
versionCode 9
versionName "1.09"
archivesBaseName = "My-V" + versionName
}

1: Does it mean that targetSdkVersion must be greater than or equal to
26 ?
Yes.
2: Does it mean that minSdkVersion can be 21 ?
Yes. (or any lower version you need to support)
From the documentation:
android:minSdkVersion
An integer designating the minimum API Level required for the
application to run. The Android system will prevent the user from
installing the application if the system's API Level is lower than the
value specified in this attribute. You should always declare this
attribute.
android:targetSdkVersion
An integer designating the API Level that the application targets. If
not set, the default value equals that given to minSdkVersion. This
attribute informs the system that you have tested against the target
version and the system should not enable any compatibility behaviors
to maintain your app's forward-compatibility with the target version.
The application is still able to run on older versions (down to
minSdkVersion).

Related

How To Determine SDK Level of Android App? [duplicate]

This question already has answers here:
Android: Get TargetSDKVersion in runtime
(5 answers)
Closed 2 years ago.
I am trying to determine the Build SDK level from within my app. I tried
Log.i( "MYAPP", "SDK="+Build.VERSION.SDK_INT );
I previously had been building for level 28, but recently upgraded to level 30.
My module's current build.gradle file included:
android {
compileSdkVersion 30 // was 28
defaultConfig {
applicationId "com.ramrod.MyApp"
minSdkVersion 23
targetSdkVersion 30 // was 28
more ...
Strangely, logcat still shows level 28.
I've re-synced, did a clean and rebuilt the app but no change.
What's going on
?
As you can see in the documentation here, SDK_INT returns the OS version of the device in which the app is running, and not the targetSdkVersion you're looking for.
public static final int SDK_INT
The SDK version of the software
currently running on this hardware device.
This value never changes
while a device is booted, but it may increase when the hardware
manufacturer provides an OTA update.
To get the targetSdkVersion you need to use ApplicationInfo.targetSdkVersion class:
packageManager.getApplicationInfo(youPackage, 0).targetSdkVersion;

How to make my app work in all devices?

i made android app for minSdkVersion 23 and targetSdkVersion 23.while launching i saw that this can only support 5000 devices in 15000 devices.i want to make this app support for all devices.how can i do?
defaultConfig {
applicationId "com.love.ksr_red_app"
minSdkVersion 23
targetSdkVersion 23
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
It depends on minSdkVersion and targetSdkVersion.
Try making minSdkVersion to lowest OS version to which you make your app compatible with.
And make targetSdkVersion to the latest OS version available. This will make sure that your application is targeting towards all the devices available in the market and will compatible with them.
i want to make this app support for all devices.how can i do?
Well..., That looks practically impossible. Though you can try below thing... which will make your app support most of the devices that are present in the market
1) Launch android studio and Create new project
2) Name new project
3) select the minimum support version user friendly
Look it will be supporting 96 % of the devices in the market
Things to keep in mind :
Very old devices are no more there in market like android 1.0 to 4.0
By doing this way it ensures you are going to give support to the maximum number of the devices you can
It will make and alter the things necessary for you in the project
Most importantly... you have to manage exceptions and build versions via code..!!
There are some devices like VIVO in india or other countries which takes android and modifies it to FuntouchOS which will not let you start your program ON_BOOT_COMPLETED... Such phones are based on android and not purely android like others.
Thats why it is not practically possible to support all the devices which shows you in Google console in numbers; while uploading an app
Hope it helps you or someone else
Change your buile.gradle with this configration.
**android {
compileSdkVersion 25
defaultConfig {
applicationId "com.websinfotech.apptophonecallexample"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
}**

Why does Lint warns me about calling new methods on older versions when it's working on the older version?

In my code I have the following
PhoneNumberUtils.normalizeNumber(editUserInfosPhone.getText().toString())
But when I inspect the class, the Lint parts of the inspection tells me the following:
Call requires API level 21 (current min is 15): android.telephony.PhoneNumberUtils#normalizeNumber
I have in my app's build.gradle the following :
defaultConfig {
//package and code version parts skipped
minSdkVersion 15
targetSdkVersion 25
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
But the codes that requires API level 21 works on a device with Jelly Bean API 16.
Why is it working on that device?

How does gradle lint errors depend on the minSdkVersion?

I'm currently developing on an app using:
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
...
defaultConfig {
...
minSdkVersion 19 // to be 16
targetSdkVersion 19 // to be 25
...
}
}
As you can see my min/max APIs are both 19, but my intention is to build for 16 to 25. (The app has already been developed and used in this range.) At API 19, I get ~200 lint warnings/errors, some for various forms of deprecation. So my question is:
Would fixing all lint errors under API 19 cause app incompatibility problems when changing the API to range from 16 to 25?
PS. No I can't test because I simply have no access to devices of earlier/later AOS's. Or did I miss something?

Call requires API level 16 (current min is 14)

I have this line in my code:
linearLayout.setBackground(drawable);
setBackground() shows the following error:
Call requires API level 16 (current min is 14)
What does this mean?
Can I raise my API level?
What does a higher/lower API level mean?
Does it limit the amount of devices my app can be used on if the API level is higher?
What does this mean?
It means that the setBackground(Drawable) method was added in API Level 16, and older devices do not have it. However, your app's minSdkVersion is 14. So, unless you take steps to avoid this line on API Level 14 and 15 devices, your app will crash on those devices.
Can I raise my API level?
You could set your minSdkVersion to 16.
Does it limit the amount of devices my app can be used on if the API level is higher?
Yes. If you say that your minSdkVersion is 16, then devices running a version of Android older than that cannot run your app.
At the time of this writing, about 90% of Android devices accessing the Play Store are on API Level 16 or higher (i.e., are running Android 4.1 or higher).
You can read more about the concept of API levels in the documentation. Note that this documentation is a bit old, in that it focuses on the minSdkVersion being defined in the manifest. In Android Studio projects, minSdkVersion is usually defined in your app module's build.gradle file.
Can I raise my API level?
You can set API to 16 it will limit device below 16 but it will perfectly work on devices API 16 and higher
Or else You can use API check and set
final int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
layout.setBackgroundDrawable( getResources().getDrawable(R.drawable.ready) );
} else {
layout.setBackground( getResources().getDrawable(R.drawable.ready));
}
Use a validation method that will be supported only in API LEVEL >= 16 (note the use of ContextCompat class:
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
linearLayout.setBackground(ContextCompat.getDrawable(this, drawableid));
}
Use:
layout.setBackgroudResource(R.drawable.ready);

Categories

Resources