-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Update gradle, android gradle plugin and dependencies #3619
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
Conversation
6d8542a to
e490087
Compare
b0dea1c to
5e1a770
Compare
8dbb212 to
98645ce
Compare
|
I plan on getting back to plugin app updates next week so will look into pushing the related local changes for termux app for this too. Some of these changes are not required and some dependency updates will require testing. If I couldn't get to it next week, then will let you know, then you can merge this, I will sort out my conflicts later. |
98645ce to
ea99164
Compare
050cb81 to
21bf4e0
Compare
timscharfenort8
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplikat von #
9759708 to
149ae2f
Compare
149ae2f to
b99ae50
Compare
|
Merging this one now as not being compatible with newer jdk versions is starting to become a problem for people checking out the code. @agnostic-apollo Let me know if you want help with any merge conflicts, or if you spot any issue that needs to be fixed! |
|
@fornwall sorry to bother you, but since you went ahead with this, I wanted to ask, should this repository also have its Gradle version updated? https://github.com/termux/termux-am-library I regularly build the entire termux app from source in a way that is not compatible with fetching prebuilt libraries from Maven, so I import the termux-am-library repository into my project in a custom way that breaks if the termux-app repository requires a different Gradle version from the termux-am-library repository. I assume that if anyone else does something similar, they are probably also affected by this now that this PR in the termux-app repository has been merged. I'm using this patch now which works for me: --- a/termux-am-library/build.gradle
+++ b/termux-am-library/build.gradle
@@ -4,6 +4,7 @@ plugins {
}
android {
+ namespace = "com.termux.am"
compileSdk project.properties.compileSdkVersion.toInteger()
defaultConfig {
@@ -36,7 +37,7 @@ dependencies {
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
- classifier "sources"
+ archiveClassifier = "sources"
}
afterEvaluate {
@@ -44,7 +45,7 @@ afterEvaluate {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
- from components.release
+ from components.findByName('release')
groupId = 'com.termux'
artifactId = 'termux-am'
version = '2.0.0'
--- a/termux-am-library/src/main/AndroidManifest.xml
+++ b/termux-am-library/src/main/AndroidManifest.xml
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.termux.am">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
\ No newline at end of filewould you want to apply these changes to the termux-am-library yourself, or if I make a PR with them, would you approve it? |
|
@robertkirkman Absolutely makes sense to update there as well imho - create a PR! |
|
Opened here: |
|
@fornwall additionally, I've noticed that unfortunately, this PR (#3619) seems to have caused the I've spent some time troubleshooting this, and I've found that this seems to be a manifestation of this problem: Following the directions from the accepted answer there, I was able to create this code, which fixes the error for me for specifically the case of the reverse dependency --- a/termux-shared/build.gradle
+++ b/termux-shared/build.gradle
@@ -63,6 +63,14 @@ android {
path file('src/main/cpp/Android.mk')
}
}
+
+ publishing {
+ multipleVariants {
+ withSourcesJar()
+ withJavadocJar()
+ allVariants()
+ }
+ }
}
dependencies {
@@ -81,7 +89,7 @@ afterEvaluate {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
- from components.findByName('release')
+ from components.default
groupId = 'com.termux'
artifactId = 'termux-shared'
version = '0.118.0'I've also revised my I would guess that the other instances of I'll try doing that and testing the results using the technique based on the |
|
PR to resolve that is here: Additionally, I've noticed that these changes related to desugaring are necessary in all the reverse dependencies of termux-app after this PR, in order for them to actually build: --- a/termux-api/app/build.gradle
+++ b/termux-api/app/build.gradle
@@ -66,7 +66,7 @@ android {
}
dependencies {
- coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
+ coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.2"
implementation "com.google.android.material:material:1.12.0"
implementation "androidx.biometric:biometric:1.2.0-alpha05"
--- a/termux-float/app/build.gradle
+++ b/termux-float/app/build.gradle
@@ -66,7 +66,7 @@ android {
}
dependencies {
- coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
+ coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.2"
testImplementation "junit:junit:4.13.2"
--- a/termux-tasker/app/build.gradle
+++ b/termux-tasker/app/build.gradle
@@ -67,7 +67,7 @@ android {
}
dependencies {
- coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
+ coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.2"
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.2.1"
--- a/termux-widget/app/build.gradle
+++ b/termux-widget/app/build.gradle
@@ -45,6 +45,8 @@ android {
}
compileOptions {
+ coreLibraryDesugaringEnabled true
+
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
@@ -63,6 +65,7 @@ android {
}
dependencies {
+ coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.2"
// required for TermuxWidgetControlsProviderService
implementation "org.reactivestreams:reactive-streams:1.0.3"
implementation "io.reactivex.rxjava2:rxjava:2.2.10"in order to avoid this error: however, since you don't have merge permission for the other repositories, it's probably not important to open PRs for those repositories until after the PR in termux-am-library is merged. |
…to 9.2.1 - After #3619, unfortunately this error began to occur when one attempts to use the [Publication to Maven Local guide](https://github.com/termux/termux-app/wiki/Termux-Libraries#forking-and-local-development) to compile all Termux APKs entirely from source, which previously worked: ``` > Task :app:processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > Android resource linking failed ERROR: /home/tacokoneko/code/termux/termux-generator/termux-apps-main/termux-api/app/src/main/AndroidManifest.xml:72:9-76:20: AAPT: error: resource style/Theme.BaseActivity.DayNight.NoActionBar (aka com.termux.api:style/Theme.BaseActivity.DayNight.NoActionBar) not found. ERROR: /home/tacokoneko/code/termux/termux-generator/termux-apps-main/termux-api/app/src/main/AndroidManifest.xml:88:9-93:20: AAPT: error: resource style/Theme.BaseActivity.DayNight.NoActionBar (aka com.termux.api:style/Theme.BaseActivity.DayNight.NoActionBar) not found. ERROR: /home/tacokoneko/code/termux/termux-generator/termux-apps-main/termux-api/app/build/intermediates/packaged_manifests/debug/processDebugManifestForPackage/AndroidManifest.xml:183: AAPT: error: resource style/Theme.MarkdownViewActivity.DayNight (aka three.termux.api:style/Theme.MarkdownViewActivity.DayNight) not found. ``` - This PR fixes that error by using `components.default` in the `publications` block instead of `components.findByName('release')` and adding a `publishing` block to the `android` section of the `build.gradle` of each affected library, in accordance with https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/PublishingOptions and https://stackoverflow.com/a/71366104. `components.release` no longer works, but testing indicates that `components.default` works.
- After termux/termux-app#3619, this is necessary for building termux-am-library from source in the same Gradle project as termux-app when building all of Termux from source rather than downloading a prebuilt termux-am-library from Maven Updates: - Gradle from `7.2` to `9.2.1` - The [Android Gradle plugin](https://developer.android.com/build/releases/gradle-plugin) from `7.0.3` to `8.13.2` (note that this change requires gradle to be run with java 17) - Ensure to add a `publishing` block to the `android` block and change the `publications` block to use `from components.default` instead of `from components.release` or `from components.findByName('release')` to avoid this kind of error in Maven reverse dependencies: ``` > Task :app:processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > Android resource linking failed ERROR: /home/tacokoneko/code/termux/termux-generator/termux-apps-main/termux-api/app/src/main/AndroidManifest.xml:72:9-76:20: AAPT: error: resource style/Theme.BaseActivity.DayNight.NoActionBar (aka three.termux.api:style/Theme.BaseActivity.DayNight.NoActionBar) not found. ERROR: /home/tacokoneko/code/termux/termux-generator/termux-apps-main/termux-api/app/src/main/AndroidManifest.xml:88:9-93:20: AAPT: error: resource style/Theme.BaseActivity.DayNight.NoActionBar (aka three.termux.api:style/Theme.BaseActivity.DayNight.NoActionBar) not found. ERROR: /home/tacokoneko/code/termux/termux-generator/termux-apps-main/termux-api/app/build/intermediates/packaged_manifests/debug/processDebugManifestForPackage/AndroidManifest.xml:183: AAPT: error: resource style/Theme.MarkdownViewActivity.DayNight (aka three.termux.api:style/Theme.MarkdownViewActivity.DayNight) not found. ```
|
Thank you! I have opened the four other PRs for the four remaining places that I found errors in reverse dependencies after this PR, here: |
|
Bumping
An external dependency and downloading jdk with
|
| testImplementation "junit:junit:4.13.2" | ||
| testImplementation "org.robolectric:robolectric:4.10" | ||
| coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" | ||
| coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desugar_jdk_libs was bumped in master branch here. If bumping it is incorrect, then should this part be reverted?
I've been testing some builds that have this, though, and I haven't noticed anything wrong (that I haven't mentioned already). Do you have any ideas of what I should test in particular?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desugar_jdk_libs 2.0 uses platform impl for java.nio.file for android 8+, and uses desugar impl for lower versions. termux-shared libraries only uses nio APIs for android 8+ in FileUtils class as otherwise app wouldn't have compiled before, so ideally platform impl should still be used and behaviour shouldn't be affected, however those functions should still be tested, as messing around with filesystem code can have catastrophic results for users. Moreover, since nio APIs would now be available for older versions, any additional code added by devs/contributors can use those for older versions as well without the android 8+ checks, where impl is provided by desugar would be used instead, which again would need to be tested, since not everything is ported by it, and it could be unintended consequences as well, especially considering termux filesystems are far more complex than other apps which google may be testing for. It would have to be looked in desugar source code for what exactly was ported, etc. But personally, I don't intend to use the java.io.File or java.nio.file APIs for file operations in future, either platform or desugar, especially for Termux as they are all broken, and I have been implementing my own libraries for all the file operations, but it will take time to complete as I haven't implemented all of the operations yet, possibly some time this year.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining, that makes sense. In this case, it sounds like the best solution is to partially revert this PR by downgrading the uses of desugar_jdk_libs back to the version they were before, 1.1.5. I've opened a PR to do that here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that unfortunately, even after
, the local Maven repository guide is still not working anymore for just specifically Termux:Widget, not any of the other ones just Termux:Widget, because it's still having this error:
1. Dependency 'com.termux:termux-shared:0.118.0' requires core library desugaring to be enabled
for :app.
it seems like Termux:Widget might be different because it never had desugaring enabled to begin with, and the only clear change that resulted in this error in Termux:Widget must have been bumping Gradle in https://github.com/termux/termux-app to 9.2.1 (it definitely didn't have this error previously before this PR,
), so in this case I'm not really sure if there's a clear choice for what should be done, just thought I should let you know this so you're aware that the local Maven repository guide doesn't currently work for just Termux:Widget. I guess you will be able to figure out what to do the next time that you need to recompile Termux:Widget after the next time that you need to bump termux-shared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just do coreLibraryDesugaringEnabled true and coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" as per termux/termux-api@6207214
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've opened the PR to do that here:
- This is necessary because `desugar_jdk_libs` version 2.1.2 adds new `java.nio.file` APIs that are untested, and additionally, `java.nio.file` APIs are known to be broken, so will be removed from Termux in the future rather than being bumped. More information here: #3619 (comment) - This is necessary to prevent errors like this while using the [local Maven repository guide](https://github.com/termux/termux-app/wiki/Termux-Libraries#forking-and-local-development) to build reverse dependencies like Termux:API after #3619 ``` 1. Dependency 'com.termux:termux-shared:0.118.0' requires desugar_jdk_libs version to be 2.1.2 or above for :app, which is currently 1.1.5 ``` - Partially reverts #3619
- Necessary to fix this error while building Termux from source using the [local Maven repository guide](https://github.com/termux/termux-app/wiki/Termux-Libraries#forking-and-local-development): ``` 1. Dependency 'com.termux:termux-shared:0.118.0' requires core library desugaring to be enabled for :app. ``` - After this PR: termux/termux-app#3619
Updates:
7.2to9.2.14.2.2to8.13.2(note that this change requires gradle to be run with java 17)22.1.7171670(r22b) to29.0.14206865(r29)Note that I haven't been able to test on Android versions older than 7, as I don't have a device with that version, and the Android emulator dies directly on startup for these versions (on arm mac, perhaps due to only 32-bit arm being available for old Android versions).