I have an app uses clearText
between Android-client and server using Retrofit
, and in Android 9+
it's not allowed to use clearText
.
To ignore that I added android:usesCleartextTraffic="true"
in Manifest
but it warns: tools:ignore="GoogleAppIndexingWarning"
and suggests to add tools:targetApi="m"
.
It's a bit confusing:
Is the tools:targetApi="m"
means that any attributes with tools:
is for Marshmallow and higher?
Is it for using this version of Manifest or something else? Is this making unwanted mistake in my app?
My Manifest:
... <application android:name=".ApplicationClass" android:allowBackup="true" android:fullBackupContent="false" android:hardwareAccelerated="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:supportsRtl="false" android:theme="@style/AppTheme.NoActionBar" android:usesCleartextTraffic="true" tools:ignore="GoogleAppIndexingWarning" tools:targetApi="m"> ...
By adding tools:targetApi="m" to an element you tell the lint that the element won't be used on API level below 23 (M). See the attribute documentation. This tells the tools that you believe this element (and any children) will be used only on the specified API level or higher.
public abstract @interface TargetApi. implements Annotation. android.annotation.TargetApi. Indicates that Lint should treat this type as targeting a given API level, no matter what the project target is.
From the docs you can read:
Indicates that Lint should treat this type as targeting a given API level, no matter what the project target is
This means it will affect only the annotated one.
Other attributes with tools
won't be affected. tools
is a namespace, from which you can get attributes, an attribute won't affect the entire namespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With