-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[+use case: auto-reset of permissions] Overriding compileSDK version has been removed #1373
Comments
I can confirm that removing those lines from the plugin and then readding it made the build successful.
|
tried to hack around this by changing
Causes the error
|
Setting android-targetSdkVersion preference will set both the target and compile sdk version. Using API 31 tooling has known issues and requires some breaking changes. So API 31 is not something cordova currently supports. |
I understand that setting the targetSDKVersion preference will set both target and compile SDKs. However, I don't want to bump up to target SDK 31 prematurely. Google doesn't require it, and it has significant breaking changes for my app. Notably:
I just want to compile against API 31 so I can use the new version of the androidx library, but still target API 30 |
For the record, I also looked into re-implementing the Compat implementations instead of using the androidx library, but they seem non-trivial. In particular:
I'm not sure what that app is in all of the older versions. |
Upgrading to Java 11 fixes the error above. I can now compile and run.
|
This will enable us to call methods in the androidx compat libraries that give users the option to turn off "auto-reset" of permissions for apps that are not used very often. Auto-reset permission background: https://developer.android.com/topic/performance/app-hibernation The most recent version of the androidx libraries requires API 31 e-mission/e-mission-docs#680 (comment) This is a workaround to use API 31 in cordova now apache/cordova-android#1373
cordova android team, as you can see, I have fixed this for my individual plugin by introducing a custom gradle file. But given that @breautek said:
and
I hope that this concrete use case of an androidx package that requires a specific compileSdk helps you revisit your original decision. I'd even be open to making the change myself and submitting a PR if this is consistent with the long-term vision of the maintainers. I am not familiar with the innards of the cordova codebase, but I think I found the PR with a similar change (e.g. #1212) so it doesn't sound too terrible (famous last words?!) |
We are looking to re-introduce the independent setting. The details will be in the PR at #1431 (currently WIP, but pretty stable). It may work slightly different than the setting that was in cordova-android 9.x. Namely we are looking to default the compile SDK to whatever what the target SDK is, unless explicitly configured otherwise. In otherwords:
In all cases where cordova accepts a user-defined value, cordova will accept is as is, including if the configured values produces invalid settings, such as a target sdk > compile sdk. Feedback is welcome on the PR #1431. |
In android 10, the cordova team removed support for `compileSdkVersion` However, in order to support auto-reset of permissions, we needed to use a later SDK than the target. After filing an issue in the cordova-android repo, we added this grade file as a workaround. However, they have now reintroduced it in android 11 apache/cordova-android#1373 (comment) *and* our compile and target SDKs have caught up anyway So we can remove the workaround. More detail at: e-mission/e-mission-phone#1016 (comment)
Bug Report
Problem
Overriding compileSDK version has been removed in cordova-android@10.x
#1310 (comment)
I see that this was an intentional change, but @breautek said that
Here's the use case. I wasn't sure if this was a bug since the change was intentional, but it is arguably a regression, and is inconsistent with the documentation, so I went ahead and chose "bug" instead of "feature request".
What is expected to happen?
I can include
in my plugin
What does actually happen?
When I add that plugin and compile the app, I get the error
Information
Starting in December, android will start resetting permissions of apps that have not been brought into the foreground "for a while". This will happen irrespective of the phone's android version (https://developer.android.com/topic/performance/app-hibernation).
It only applies to apps whose target SDK is Android 11+ (API 30+), but the google play min API requirements are 30+ now for new apps and will be 30+ for app updates in November (https://developer.android.com/distribute/best-practices/develop/target-sdk)
If such a new or updated app reads location in the background, even if it is installed on an Oreo phone, it will stop working "soon after" December.
https://developer.android.com/topic/performance/app-hibernation#effects
If the app use case requires background location access, it can ask users to explicitly authorize such access. The recommended authorization method involves using new functionality in PackageManagerCompat and IntentCompat (https://developer.android.com/topic/performance/app-hibernation#handle-hibernation-android10-lower).
This new functionality is introduced in version 1.7.0 of the androidx core libraries
https://developer.android.com/jetpack/androidx/releases/core#1.7.0
However, it looks like v1.7.0 of the core libraries have a
minCompileSdk
of 31. The default cordovaSDK_VERSION
is 30.cordova-android/framework/cdv-gradle-config-defaults.json
Line 3 in 5db8508
So, when I compile my app after upgrading the androidx dependency in my plugin, I get
Command or Code
cordova build android
I could not find a way to override the compileSDK version. Per the cordova documentation, using
cdvCompileSdkVersion
should work, but it doesn't seem to.I'm going to try and workaround this by mucking around with gradle files, but as the documentation says
"In general, it is discouraged that you edit the contents of this folder because it is easy for those changes to be lost or overwritten."
Environment, Platform, Device
Version information
Output of cordova info
Checklist
The text was updated successfully, but these errors were encountered: