Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Hello!
I'm trying to update extension-admob to work with the latest version of admob sdk 20+ and get the following error:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. play-services-ads-lite-20.3.0\AndroidManifest.xml:27:5-43:15: AAPT: error: unexpected element <queries> found in <manifest>.
According to this article, the problem is with older version of Gradle plugin: https://android-developers.googleblog.com/2020/07/preparing-your-build-for-package-visibility-in-android-11.html
As I can see, since Lime 7.7.0, we are using Gradle 5.6.3 and Android Gradle Plugin 3.5.1, but I need a newer version. Anyway to fix that? Thank you!
You can set in project.xml file the following params ( or any other version , check here -> https://developer.android.com/studio/releases/gradle-plugin) :
<config:android gradle-version="6.7.1" />
<config:android gradle-plugin="4.2.0" />
Thanks a lot @flashultra! It seems to work fine now, but I had to fix some AndroidX error by adding the following to gradle.properties:
android.useAndroidX=true android.enableJetifier=true
And there are those warnings now:
WARNING:: NDK was located by using ndk.dir property. This method is deprecated and will be removed in a future release. Please use android.ndkVersion or android.ndkPath in build.gradle to specify the NDK to use. https://developer.android.com/r/studio-ui/ndk-dir NDK was located by using ndk.dir property. This method is deprecated and will be removed in a future release. Please use android.ndkVersion or android.ndkPath in build.gradle to specify the NDK to use. https://developer.android.com/r/studio-ui/ndk-dir
So, hope there will be official release with updated Gradle after all. :smile:
Well, I've hit couple more problems when decided to build release version (everything was fine with debug):
The minSdk version should not be declared in the android manifest file.
I could fix that by removing android:minSdkVersion="::ANDROID_MINIMUM_SDK_VERSION::" from Lime's AndroidManifest.xml template.
Execution failed for task ':app:lintVitalRelease'. Lint infrastructure error Caused by: java.lang.reflect.InvocationTargetException
This problem I've fixed by putting the following to Lime's build.gradle:
lintOptions { checkReleaseBuilds false }
But I'm really playing with fire here as all these fixes are temporary...
android.useAndroidX=true android.enableJetifier=true
Yep, these are a good idea nowadays. We'll just want to check ::if (ANDROID_TARGET_SDK_VERSION>=28)::.
NDK was located by using ndk.dir property. This method is deprecated and will be removed in a future release. Please use android.ndkVersion or android.ndkPath in build.gradle to specify the NDK to use.
Hmm. If we omit this property, the Android Gradle plugin will pick an NDK version based on when the AGP was compiled. Meanwhile, HXCPP will try to pick the latest version of the NDK, causing a version mismatch.
So... we should specify ndkVersion if the AGP is new enough, and ndk.dir otherwise. Looks like version 3.6 is the cutoff?
The minSdk version should not be declared in the android manifest file.
We can get rid of that, no problem.
Lint infrastructure error Caused by: java.lang.reflect.InvocationTargetException
But this is a problem. Disabling linting won't work in the long term, so we'll have to hunt down the real source. Any chance you can try again with --stacktrace?
So... we should specify
ndkVersionif the AGP is new enough, andndk.dirotherwise. Looks like version 3.6 is the cutoff? I'm not sure here, does it matter? Can we just move to the newest AGP?
But this is a problem. Disabling linting won't work in the long term, so we'll have to hunt down the real source. Any chance you can try again with
--stacktrace? So, I was trying to get this error again, but can't, project builds fine even without disabling linting. Maybe it cached this somehow.
I'm not sure here, does it matter? Can we just move to the newest AGP?
We can set that as the default, but we can't be certain everyone will use it.
So, I was trying to get this error again, but can't, project builds fine even without disabling linting. Maybe it cached this somehow.
Ah, one of those errors.
Well, hopefully it was just a one-time hiccup. If it happens again, try --stacktrace (and maybe gradle clean), but until then we'll leave it be.
We can set that as the default, but we can't be certain everyone will use it.
Who is everyone and why they don't want to use it? :)
I was able to reproduce "Lint infrastructure error", it happens when I set minSdkVersion in AndroidManifest.xml:
Caused by: com.android.builder.errors.EvalIssueException: Failed to parse XML in ...\bin\android\bin\deps\extension-api\src\main\AndroidManifest.xml
The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
Ok, submitted a bunch of changes. Check them out and see if they work for you.
Everything seems good except "Remove uses-sdk tag."
I've only removed android:minSdkVersion="::ANDROID_MINIMUM_SDK_VERSION::", but left android:targetSdkVersion="::ANDROID_TARGET_SDK_VERSION::" untouched.
Will I still be able to use this in my project.xml?
<config:android minimum-sdk-version="XX" target-sdk-version="YY" />
Thank you!
Oh yeah, definitely keep both in project.xml. Those values still get passed to build.gradle. We're only removing them from the manifest because they're redundant there.
I wonder why minSdk is still 16? I've switched to 19 long time ago, can't remember the reason, but it has fixed something for me. :) SDK 16 is Android Jelly Bean released July 9, 2012, there aren't many devices left with this Android version. https://en.wikipedia.org/wiki/Android_version_history
Didn't see a reason to mess with it, I guess. Other than at really low numbers, I've never run into a case where minSdkVersion made a noticeable difference.
Ok, everything seems good then, thank you!