Issue
I try to call this code:
webView = findViewById(R.id.webView);
WebSettings settings = webView.getSettings();
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
But I get Call requires API level 21 (current min is 16)
So I opened build.gradle
and changed minSdkVersion 16
to minSdkVersion 21
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "my_id"
minSdkVersion 21
targetSdkVersion 28
I also added:
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="27"
/>
to the AndroidManifest.xml.
But it still shows the message Call requires API level 21 (current min is 16)
Solution
For such issues you can do two things:
Android Studio gets better and better but gradle integration still causes some problems so just invalidate cache and reload AS (Invalidate Caches / Restart).
You can trace how
AndroidManifest.xml
is build - it's merged from manifests in every module. First checkapp/build/intermediates/merged_manifests/{buildType}/AndroidManifest.xml
- it's final manifest file that will be put in APK. If you find not expected values there, as next step find how it was merged - inspect:app/build/outputs/logs/
reports. For example if you discover that some library require bigger minSdk, you can override it in your app manifest:<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2" tools:overrideLibrary="com.example.lib1, com.example.lib2"/>
and just make sure that older devices don't execute lib code that requires newer sdks.
Answered By - 3mpty
Answer Checked By - Gilberto Lyons (JavaFixing Admin)