Accessing a new MediaStore feature on an old device - android

I have an app that accesses audio files through the MediaStore API. I'm using
a minSdkVersion of 16 and a targetSdkVersion of 30. When I query the
MediaStore, my projection array includes MediaStore.Audio.Media.DURATION.
Android Studio attaches a warning message to this, "Field requires API level
29". If I ignore the warning, and run my app anyway on a legacy device with
API level 16 or 19, the app runs fine, and the durations it returns are
correct.
If the DURATION attribute was only added in API 29, how come it doesn't
generate an error on older devices? What is the downside to continuing to
ignore the warning?

Related

checkSelfPermission: How to do it prior to API 22

I am trying to port my app from API 22 to API 26. Several API calls are failing (e.g. WRITE_EXTERNAL_STORAGE, etc.). I believe it is due to the new runtime permission model wherein permissions are not granted EVEN if they are in the manifest.
So I tried to do the right thing, namely using checkSelfPermission() and requesting the permission if denied.
My problem is that checkSelfPermission is not available before API 23 and my minSdkVersion is lower than that so Android Studio flags it as an error.
I'm now stuck between rock & hard place: If I raise my minSdkVersion to 23, I'll break the app for many existing customers. If I lower my targetSdkVersion below API 23 to avoid the problem, Google Play won't accept it.
Help!
You should check permissions only for API >= 23.For API < 21 will use install-time requests
Call ContextCompat.checkSelfPermission() in the v4 support library (see this question). This is a "compatibility layer", so that single function will work on all versions of Android.

Android Apk Submission target

I tried to submit my updated application to playstore. When I tried upload the apk on production, there was notice saying
Play Store will require that new apps and app
updates target a recent Android API level. This will be required for
new apps in August 2018, and for updates to existing apps in November
2018. This is to ensure apps are built on the latest APIs optimized for security and performance.
Currently, my application was set minSDKVersion 19 and targetSDKVersion as 23.
Does that mean I have to update my application to targetSDKVersion 26?
I have tried to change this and upload it. I seems to have error saying about the downgrade (Sorry I should have make a note of the message).
Does that mean I have to update my application to targetSDKVersion 26?
Yes. But for now its just a warning, it will enforced from beginning of August for new apps. Do take note that deadline for app update is November.
have tried to change this and upload it. I seems to have error saying
about the downgrade
Since you don't have complete error message, one probable cause of this issue is, you are trying to upload an app which has VersionCode less than the app available on play store. Re-check your version code and increase it if needed.
August 2018: New apps required to target API level 26 (Android 8.0) or
higher.
November 2018: Updates to existing apps required to target API level 26 or higher.
2019 onwards: Each year the targetSdkVersion
requirement will advance. Within one year following each Android
dessert release, new apps and app updates will need to target the
corresponding API level or higher.
source: https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html

Upload apk to store gets warning message

When I try to upload the apk to store I get these warnings
Partially upgradable APK
WARNING
Some users of this APK may not be able to upgrade to any of the new APKs added in this release.
CAUTION
Users that currently have APK with version code 53, which targets SDK 22 or lower, will be eligible to upgrade to this APK. However, once users upgrade to this APK, they will be unable to upgrade to APKs that target SDK 22 or lower.
Following datas are my current build details
compileSdkVersion 26
buildToolsVersion 26.0.2
minSdkVersion 15
targetSdkVersion 26
This is my previous update details
compileSdkVersion 25
buildToolsVersion "25.0.3"
minSdkVersion 15
targetSdkVersion 22
This warning is because yoy have upgraded your api higher than 22 that means you have to handle some runtime permisions. The warning says that this is a one way switch i.e there is no way of coming back to targeting API 22 or earlier once you make the switch to the runtime permission model.The developer console is just confirming that you have done all the thing need for runtime permissions so no need to worry.
It is normal but in your case - you need to be careful since you target several levels higher.
Warning: Users using previous build would not be able to install the
update simply because of difference in permission models and higher
compile - 26. So if you don't make sure that you handle new permission
models and other functionalities, you may tend to lose part of your
users.
Caution: Users once they update to the new build will not be
able to upgrade back to lesser build of the same App. This means once
you publish your App in higher build successfully, you can't go back
to lesser build targets in your next update. Make sure all your
functionalities work in the new build before deploying.
Thanks
Its simply ok.
Warning indicates that once you increase your target version higher than your previous target version then users get update to newer targeted version app. But then after they cant receive update for lower target version.
But make sure you have handled Runtime Permission Model Properly for all dangerous group permission.
Rather than it does not affect your user base or nor your app functionality.
Happy Coding..

Does a max need to be set in android manifest?

My ionic app is targeted 24, min 16, no max in android manifest.
When I run in firebase on devices set to 24 or 25 I get fatal crashes.
Does my app need a max to avoid crashes? Or does that limit it being supported on newer API devices?
Also in Android studio when you first try to set a project and pick a target it tells you that __% of people in the play store use that target so 24 is less than 1%. So if my target is 24 does that mean only 1% of the store will be able to use my app?
Here is my API 23 app crash on a 25 device:
API 24 app crash on a 24 device:
I see you are a little bit confused, let's first clear what each of them means to Android.
android:targetSdkVersion
With this you are telling Android which SDK you are targeting. What is important about this is that it tells the system that SDK level matchs this attribute, the system doesn't need to enable any behaviour to maintain compatibility.
Your app is still able to run on older versions (down to minSdkVersion).
android:minSdkVersion
As the attribute name suggests this is the minium SDK version required in order to run the app, if the device which is trying to install the app has a lower sdk version the system will block the process.
What is important to note is that if you raise the minSdkVersion in an update, all the user which have already installed the app and no loger match this attribute will be able no longer to use the app
android:maxSdkVersion
Again, the attribute name says it all. This is the maxium Sdk version a device can have in order to run the app.
Notice this from the docs:
An application declaring maxSdkVersion="5" in its manifest is
published on Google Play. A user whose device is running Android 1.6
(API Level 4) downloads and installs the app. After a few weeks, the
user receives an over-the-air system update to Android 2.0 (API Level
5). After the update is installed, the system checks the application's
maxSdkVersion and successfully re-validates it. The application
functions as normal. However, some time later, the device receives
another system update, this time to Android 2.0.1 (API Level 6). After
the update, the system can no longer re-validate the application
because the system's own API Level (6) is now higher than the maximum
supported by the application (5). The system prevents the application
from being visible to the user, in effect removing it from the device.
That's it. Check also the DOCS here
Also in Android studio when you first try to set a project and pick a
target it tells you that __% of people in the play store use that
target so 24 is less than 1%. So if my target is 24 does that mean
only 1% of the store will be able to use my app?
Actually not, you have to consider the minium and max in order to find how many % of market will be able to use your app. That's just saying how many people (in %) have that SDK Version.
About the crashes
I am quite sure that the problem is not related to the SDKVersion, maybe you should post some log in order to give a more detailed answer to that.
Hope it helped you :)

android:maxSDKVersion - couldn't upload apk to alpha

I've faced the problem uploading app to Play Store. The old "19" version was available for API versions 10 and above. New "20" version specified maxSDKVersion=22 (not higher Android 5.1).
An error message, when trying to upload "20", says:
"it is forbidden that a device upgrading from API levels in the range
10-22 to API levels in the range of 23+ should downgrade from version
20 to version 19, which could happen if...".
This situation clearly specified in documentation:
...future versions of Android (beyond Android 2.0.1) will no longer
check or enforce the maxSdkVersion attribute during installation or
re-validation. Google play will continue to use the attribute as a
filter, however, presenting users with applications available for
download.
Our application not working properly on Android 6, so we should somehow to prevent installs on those devices.
So, there is an answer from Google support:
...
The error message is stating that if a user updates the Android
version on their device, the configuration of your APKs would cause
them to become ineligible for the version they currently have.
To resolve this issue, always make sure the APK that supports the
higher API level always has a higher version code. For example, if an
APK with API levels 14 - 17 was version 3 then an APK with API level
18 would have to have version 4.
In other cases, you can simply remove the max SDK declaration from
your app’s manifest.
...
And there is no way to add maxSDKVersion limitation in existing app.

Categories

Resources