Skip to content
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

Enable androidx #2374

Closed
wants to merge 4 commits into from
Closed

Enable androidx #2374

wants to merge 4 commits into from

Conversation

RobertFlatt
Copy link
Contributor

Addresses #2020
AndroidX is a support library that replaces the depreciated Android support library.

This PR adds a build option --enable-androidx which (when used) adds a block to build.tmpl.gradle
When AndroidX is enabled, a specific AndroidX library can be added using the existing gradle_dependencies option.
Some (or all?) of the latest packages in the AndroidX library depend on api=28 or greater.

There is an alternative implementation, setting the same two Gradle flags in a new file named gradle.properties. Because of the file management uncertainties introduced in the context of p4a, this author will not use this approach.

The previous support library is depreciated. There is an argument that AndroidX should be enabled by default. This would impact users who specify an existing support package in gradle_dependencies. And there may be some other unforeseen impact. Alternatively AndroidX could be enabled by api version, but this would not be transparent to users. I think AndroidX should be enabled by default, but not yet; so it is enabled by build command option.

As an example user dependency consider #2200 , it depends on the Android support library but is agnostic to which one. However the user code required does depend on the chosen support library, the change is in a Java class name, and in the name of the gradle_dependencies package.

The need for #2200 is wide spread; for example the plyer camera https://github.com/kivy/plyer/blob/master/plyer/platforms/android/camera.py uses a 'file url' which can no longer be used between Activities, so is not functional with api =29 or greater. To prevent user rework after #2200 is incorporated, I suggest that this PR be incorporated at the same time.

Copy link
Member

@tshirtman tshirtman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@@ -96,6 +96,13 @@ android {
}
}

{% if args.enable_androidx %}
ext {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be preferable to put the if/endif inside the ext block (which would exist, but empty by default, and this way, more options could be added later in that block if needed?

Just a thought, it's certainly not a problem and it can be changed later when we actually have more options to put in there.

@RobertFlatt
Copy link
Contributor Author

@tshirtman ext{} easy to do.

But wait.
A FileProvider works great using androidx (and I developed a content URI api I like), but....
While testing I discovered that pyjnius can't find android.permissions.WHATEVER ,
presumably the library not linked. An issue with this PR, I suspect.
Investigating....

@RobertFlatt
Copy link
Contributor Author

The first issue is the version of the Android Gradle plugin specified by p4a 3.1.4 does not support jetifier, so AndroidX compatibility is not implemented. A minimum of 3.2.1 is required, the current version is 4.0.1

Great release notes here https://developer.android.com/studio/releases/gradle-plugin#3-2-0

Investigating....

@RobertFlatt RobertFlatt deleted the enable_androidx branch December 26, 2020 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants