Skip to content

Conversation

@fornwall
Copy link
Member

@fornwall fornwall commented Oct 2, 2023

Updates:

  • Gradle from 7.2 to 9.2.1
  • The Android Gradle plugin from 4.2.2 to 8.13.2 (note that this change requires gradle to be run with java 17)
  • NDK used to build the native code from 22.1.7171670 (r22b) to 29.0.14206865 (r29)
  • Updates several java library dependencies to their latest versions

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).

@fornwall fornwall force-pushed the update-gradle branch 2 times, most recently from 6d8542a to e490087 Compare October 2, 2023 22:13
@fornwall fornwall force-pushed the update-gradle branch 3 times, most recently from b0dea1c to 5e1a770 Compare October 8, 2023 18:03
@fornwall fornwall force-pushed the update-gradle branch 2 times, most recently from 8dbb212 to 98645ce Compare September 27, 2024 09:56
@agnostic-apollo
Copy link
Member

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.

Copy link

@timscharfenort8 timscharfenort8 left a comment

Choose a reason for hiding this comment

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

Duplikat von #

@fornwall fornwall force-pushed the update-gradle branch 4 times, most recently from 9759708 to 149ae2f Compare December 31, 2025 10:59
@fornwall
Copy link
Member Author

fornwall commented Jan 4, 2026

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 fornwall merged commit 53f75a8 into termux:master Jan 4, 2026
3 checks passed
@fornwall fornwall deleted the update-gradle branch January 4, 2026 02:16
@robertkirkman
Copy link
Member

robertkirkman commented Jan 10, 2026

@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 file

would you want to apply these changes to the termux-am-library yourself, or if I make a PR with them, would you approve it?

@fornwall
Copy link
Member Author

@robertkirkman Absolutely makes sense to update there as well imho - create a PR!

@robertkirkman
Copy link
Member

@robertkirkman
Copy link
Member

robertkirkman commented Jan 11, 2026

@fornwall additionally, I've noticed that unfortunately, this PR (#3619) seems to have caused the publishReleasePublicationToMavenLocal guide to stop working, resulting in this error when, for example, https://github.com/termux/termux-api is compiled using a local Maven repository containing a com.termux.shared that was built from https://github.com/termux/termux-app after the merge of this PR.

> 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.

I've spent some time troubleshooting this, and I've found that this seems to be a manifestation of this problem:

https://stackoverflow.com/questions/71365373/software-components-will-not-be-created-automatically-for-maven-publishing-from

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 com.termux.api:

--- 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 com.termux.am PR to show what seems to be the correct way of updating that section of the module-level build.gradle.

I would guess that the other instances of components.findByName('release') which were added in this PR might also be affected by this problem, and might also need to be revised.

I'll try doing that and testing the results using the technique based on the publishReleasePublicationToMavenLocal guide that I typically use, then making a PR with what seems to work for me to solve this.

@robertkirkman
Copy link
Member

robertkirkman commented Jan 11, 2026

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:

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

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.

fornwall pushed a commit that referenced this pull request Jan 11, 2026
…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.
fornwall pushed a commit to termux/termux-am-library that referenced this pull request Jan 11, 2026
- 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.
```
@robertkirkman
Copy link
Member

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:

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Jan 12, 2026

Bumping desugar_jdk_libs version can have consequences for file operations/libraries behaviour due to added java.nio.file APIs, that's why I haven't bumped it, changes need to investigated and thoroughly tested. Do it at your own risk if you guys are going to do it.

An external dependency and downloading jdk with actions/setup-java is not required, github runners already provide jdk 17 and other common versions.

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"
Copy link
Member

@robertkirkman robertkirkman Jan 12, 2026

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?

Copy link
Member

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.

Copy link
Member

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:

Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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:

fornwall pushed a commit that referenced this pull request Jan 12, 2026
- 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
laraholand pushed a commit to laraholand/termux-generator that referenced this pull request Jan 21, 2026
agnostic-apollo pushed a commit to termux/termux-widget that referenced this pull request Jan 21, 2026
- 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
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.

4 participants