How to use android:usesCleartextTraffic below Marshmallow (API-23) - android

I am trying to secure WebView from cleartext traffic. As mentioned in the documentation. I have to set android:usesCleartextTraffic as false to achieve this. But this works on API level 23 and above. My minimum sdk is 22. How can I make sure app doesn't crash or create any problem on device running below API level 23 ? Or how can I programmatically set that attribute value in the application tag in Manifest.xml ?

As suggested in an article # Android Developers Blogspot:
You don’t have to set minSdkVersion or targetSdkVersion of your app to 23 (Android Marshmallow) to use android:usesCleartextTraffic. On older platforms, this attribute is simply ignored and thus has no effect.
Hope this solves your query.

When you use usesCleartextTraffic in manifest, you get the following warning :
Attribute usesCleartextTraffic is only used in API level 23 and higher
(current min is 19).
The default value of usesCleartextTraffic is as the following :
for apps that target API level 27 or lower is "true".
for apps that target API level 28 or higher default to "false".
This attribute was added in API level 23.
This flag is ignored on Android 7.0 (API level 24) and above if an Android Network Security Config is present.
https://developer.android.com/guide/topics/manifest/application-element
https://android-developers.googleblog.com/2016/04/protecting-against-unintentional.html

Related

android studio use cleartext http on api 17

I am using xammp server for php on localhost , i was working before update (i think), but now http connection gives me an exception:
W/System.err: java.io.IOException: Cleartext HTTP traffic to
192.168.0.105 not permitted
i have tried then to add android:usesCleartextTraffic="true" on Application for AndroidManifest , but also a next error:
Attribute usesCleartextTraffic is only used in API level 23 and higher (current min is 17)
I want to keep support to API 17, and when releasing my app I will use https on a public server, what can I do for now?
You don’t have to set minSdkVersion or targetSdkVersion of your app to 23 (Android Marshmallow) to use android:usesCleartextTraffic. On older platforms, this attribute is simply ignored and thus has no effect.
Reference - https://android-developers.googleblog.com/2016/04/protecting-against-unintentional.html?m=1

android:navigationBarDividerColor requires API level 28

Previously, I implemented light and dark navigation bar, however now tags as android:navigationBarDividerColor and android:windowLightNavigationBar require API level 28 when they previously required API level 27.
It seems API level 28 does not even exist as next API level is called P.
Is there any solution to this problem? Thanks in advance.
UPDATE: it seems to work now on API 27 with latest support libraries
When the "next upcoming API" is still under development, its "name" is a letter (P in your case).
Once the final version of the API is available, the "name" is changed form a letter to a number (P to 28).
Final version of Android API 28 (former Android P) is available since early June 2018. Just use the SDK manager and you'll be able to download it ;-)
Note:
Sources for "Android SDK Platform xx" (28 in your case)" is not available right away. (not available ATTOW)It can takes a few weeks before they are available for download from the SDK manager.
Today I've updated compileSdkVersion, targetSdkVersion and buildToolsVersionfrom 27 to 28. Now I'm facing the same issue as #Teďourek described.
While it was working for me on 27, since the upgrade I now get lint errors:
Error: android:navigationBarDividerColor requires API level 28 (current min is 19)
Error: windowLightNavigationBar requires API level 28 (current min is 19)
This is strange because according to the docs for both attributes it says:
"added in API Level 27"
My temporary fix is to move the two style attributes to v28/styles.xml instead of v27/styles.xml
Since I would like to use lightNavBar + color also on Android 8.1.0 as previously, I would be happy if anyone knows a fix!
With compileSdkVersion and targetSdkVersion set to 29 it seems to be correct.
The XML properties tell me it was added in API level 27.
Only the Java Window properties are added in API level 28.

Disable Multi-Window Support in Android

I'm trying to disable multi window support using android:resizeableActivity="false" inside application tag in the manifest file. But it shows this warning -
Attribute resizeableActivity is only used in API level 24 and higher (current min is 15)
Then I used "suppress with tool:TargetApi Attribute". This gave me RuntimeException: Worker exited due to exception:
What should I do now ?
Attribute resizeableActivity is only used in API level 24 and higher (current min is 15)
You can safely ignore that warning because Multi Window Support is only available from Android 7.0(API level 24) and above. On lower versions this line android:resizeableActivity="false" will simply be ignored.

Android pdfrenderer not working properly with 19 or 21 minsdk

Making a program for Android L' using pdfrenderer the issue is
when 'm running the emulator with minsdk = 21
ERROR - "emulator-5554 disconnected! Cancelling 'com.example.andro_pdf_two.MainActivity activity launch'!"
when 'm trying to run the emulator at minsdk = 19
ERROR at logcat- java.lang.NoClassDefFoundError: android.graphics.pdf.PdfRenderer
and Call requires API level 21 (current min is 19): android.graphics.pdf.PdfRenderer#openPage
I have done everything as suggested - resetting adb, resetting preferences...but nothing seems to be working can anyone help???
Call requires API level 21 (current min is 19): android.graphics.pdf.PdfRenderer#openPage
clearly states that you need a min sdk version of 21 and your app has a current api level of 19
set this in your manifest and try
<uses-sdk android:minSdkVersion="21" />
PDFRenderer assumes minimum API level - 21.
You can use android-pdfview for API level less than 21.

What does Advanceable Added in API level 16 mean?

What does Advanceable Added in API level 16 mean? And how to use those two methods in Advanceable Api?I saw this interface in Launcher source code. I am not clear about the specification in android docs.Thanks.
It means that only devices with api level 16 or above knows/can use that method/class. And will fail to run if you put the code under a device with api level 15 or lower.

Categories

Resources