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

Add package: gradle #7227

Merged
4 commits merged into from
Aug 5, 2021
Merged

Add package: gradle #7227

4 commits merged into from
Aug 5, 2021

Conversation

suhan-paradkar
Copy link
Contributor

Will be a draft until someone confirms that it works without any problem

packages/gradle/build.sh Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Aug 2, 2021

It doesn't work. When building even simple project, it fails with Unsupported class file major version 61.

@ghost ghost closed this Aug 2, 2021
@suhan-paradkar suhan-paradkar deleted the gradle branch August 2, 2021 11:46
@suhan-paradkar suhan-paradkar restored the gradle branch August 2, 2021 11:46
@suhan-paradkar suhan-paradkar deleted the gradle branch August 2, 2021 11:49
@suhan-paradkar
Copy link
Contributor Author

Well.. looks like gradle doesn't support openJDK 17 yet...
https://docs.gradle.org/current/userguide/compatibility.html#compatibility

@agnostic-apollo
Copy link
Member

Try 7.2-rc-1 as per gradle/gradle#16857 (comment)

@suhan-paradkar suhan-paradkar restored the gradle branch August 3, 2021 00:45
@suhan-paradkar
Copy link
Contributor Author

Lemme try

@suhan-paradkar
Copy link
Contributor Author

@xeffyr should I open a PR here or in unstable-repo for gradle-nightly (v7.2-rc-1 as per @agnostic-apollo ) ??

@thunder-coding
Copy link
Member

unstable-packages would be better until it is tested to be working. (Vote here instead of commenting)
👍 for upvote
👎 for downvote

@agnostic-apollo
Copy link
Member

Well, technically all this stuff with jdk, kotlin, gradle, etc is pretty nightly/unstable at this point considering the issues and only basic testing having being done yet. But we can test without merging with master too.

@suhan-paradkar
Copy link
Contributor Author

@agnostic-apollo so should I open a new PR or continue with this(this PR will be reopened)??

@agnostic-apollo
Copy link
Member

Send the changes here I guess, will see if build even succeeds and gradle actually works or not. Decision to move it to unstable repo can be made after that, no point in doing that now if gradle doesn't even work.

@suhan-paradkar
Copy link
Contributor Author

suhan-paradkar commented Aug 3, 2021

I have already made changes see 2086ffb

@suhan-paradkar
Copy link
Contributor Author

Well.. it builds... Need to check if it works...

@suhan-paradkar
Copy link
Contributor Author

suhan-paradkar commented Aug 3, 2021

@agnostic-apollo
Well.. It works... I can confirm it...

I could test jadx

Screenshot_2021-08-03-17-13-39-18.jpgScreenshot_2021-08-03-17-20-28-37.jpgScreenshot_2021-08-03-17-20-37-58.jpg

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Aug 4, 2021

Welcome and apologies for the following journey! ;)

Some url links below are not active any more and you will need to find the active/latest link yourself, like for https://github.com/Lzhiyong/sdk-tools

So TLDR is that gradle is working with openjdk-17. I have managed to compile termux-app and termux-tasker with them on my LG G5 Android 7.0, aarch64. But was hell to do it.

There is one exception that `gradle` with `--debug` flag does show when running tasks that I noticed but it still worked.
net.rubygrapefruit.platform.NativeIntegrationLinkageException: Native library 'libnative-platform.so' could not be loaded for Linux aarch64.
	at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:61)
	at net.rubygrapefruit.platform.Native.init(Native.java:56)
	at org.gradle.internal.nativeintegration.services.NativeServices.initializeNativeIntegrations(NativeServices.java:170)
	at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:155)
	at org.gradle.internal.nativeintegration.services.NativeServices.initializeOnClient(NativeServices.java:135)
	at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:42)
	at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
	at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:240)
	at org.gradle.launcher.Main.doAction(Main.java:35)
	at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
	at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
	at org.gradle.launcher.GradleMain.main(GradleMain.java:31)
Caused by: java.lang.UnsatisfiedLinkError: /data/data/com.termux/files/home/termux_img/.gradle/native/e1d6ef7f7dcc3fd88c89a11ec53ec762bb8ba0a96d01ffa2cd45eb1d1d8dd5c5/linux-aarch64/libnative-platform.so: dlopen failed: library "libstdc++.so.6" not found
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:384)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:228)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:170)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
	at java.base/java.lang.Runtime.load0(Runtime.java:751)
	at java.base/java.lang.System.load(System.java:1912)
	at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:51)
	... 18 more
  

I am not well versed in the gradle and android sdk/apk build systems, so some issues will need more research. Anyways, firstly, as already mentioned, gradle does work with jdk-17, but android gradle plugin is not officially supported and has issues. It will fail with Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @6a45f906 while compiling termux-* and will likely get triggered for other apps too. Similar issue reported at gradle/gradle#17152 (comment). As per this, even jdk-16 is not supported by android gradle plugin/studio, at least was not in June. The official docs only mention minimum version 11, but not max. However, that issue is solvable by adding --add-opens=java.base/java.io=ALL-UNNAMED to org.gradle.jvmargs in root level gradle.properties. This is due to newer restrictions in jdk-17 of accessing internal APIs with reflection, so that error may get triggered for other classes as well and each will have to be opened separately. Check https://www.infoq.com/news/2021/06/internals-encapsulated-jdk17/ for details.

So lets begin setup.

Install gradle and openjdk-17 packages

Run pkg install openjdk-17 gradle

Set Environmental Variables

First we need to set ANDROID_SDK_ROOT, JAVA_HOME and update PATH. Add following to ~/.bashrc. You will need to source it with source ~/.bashrc or start a new termux session for changes to take effect. You will also need to stop the gradle daemon with gradle --stop, since it will be using old values if its already running.

ANDROID_SDK_ROOT is deprecated and repalced by ANDROID_HOME now.

export ANDROID_SDK_ROOT="$HOME/Android/sdk"
export PATH="$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin"
export JAVA_HOME=/data/data/com.termux/files/usr/opt/openjdk

So ~/Android/sdk directory will be where we store android sdk related files. The ~/.gradle directory is used by gradle for storing its own files like dependencies in caches, etc.

Download cmdline-tools

We need the tools provided by cmdline-tools. You can also download it directly from https://developer.android.com/studio#command-tools. Note that we added its extraction path to PATH in .bashrc, which is required so that it can be executed from anywhere, without referring to its path. These tools are scripts and architecture is not an issue. We need sdkmanager from it to install other sdk packages, like the ones you see in Android Studio SDK manager.

curl -L https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip -o commandlinetools-linux-7583922_latest.zip
mkdir -p ~/Android/sdk/cmdline-tools
unzip commandlinetools-linux-7583922_latest.zip -d ~/Android/sdk/cmdline-tools
mv ~/Android/sdk/cmdline-tools/cmdline-tools ~/Android/sdk/cmdline-tools/latest

Accept Android SDK Licenses

You will get errors like Failed to install the following Android SDK packages as some licences have not been accepted. if you try to install packages with sdkmanager. So run yes | sdkmanager --licenses so that google owns your soul (if it doesn't already).

Install Android Platforms

Since we are only compiling termux-app and termux-tasker, we would mainly only need Android sdk 28, 29 and 30 now and near future.

yes | sdkmanager "platforms;android-28"
yes | sdkmanager "platforms;android-29"
yes | sdkmanager "platforms;android-30"

Install Android Build And Platform Tools

Now, if at this point if you try to run a gradle task for termux-tasker, hoping it will download the build-tools automatically for you, then you are right, it will, well, it will try to, but it will fail with Failed to install the following SDK components: build-tools;29.0.2. Note that termux-tasker does not set buildToolsVersion in app/build.gradle and the android gradle plugin will automatically choose the minimum required version since 3.0.0. Since termux-tasker uses com.android.tools.build:gradle:4.1.1, build-tools;29.0.2 would be chosen. The termux-app uses com.android.tools.build:gradle:4.2.1, so build-tools;30.0.2 would be chosen.

So the solution would have been to use sdkmanager to manually install it with yes | sdkmanager "build-tools;29.0.2" but that fails too without any specific error, just like above. The log is for after I already installed 29.0.2 with the below way so using 29.0.1.

Log
$ yes | sdkmanager --verbose "build-tools;29.0.1"
Info: Parsing /data/data/com.termux/files/home/termux_img/Android/sdk/build-tools/29.0.2/package.xml
Info: Parsing /data/data/com.termux/files/home/termux_img/Android/sdk/build-tools/30.0.2/package.xml
Info: Parsing legacy package: /data/data/com.termux/files/home/termux_img/Android/sdk/cmdline-tools/latest
Info: Parsing legacy package: /data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670
Info: Parsing /data/data/com.termux/files/home/termux_img/Android/sdk/platform-tools/package.xml
Info: Parsing /data/data/com.termux/files/home/termux_img/Android/sdk/platforms/android-28/package.xml
Info: Parsing /data/data/com.termux/files/home/termux_img/Android/sdk/platforms/android-29/package.xml
Info: Parsing /data/data/com.termux/files/home/termux_img/Android/sdk/platforms/android-30/package.xml
Warning: Dependant package with key emulator not found!
Warning: Unable to compute a complete list of dependencies.
$ echo $?
1
  

The current hack is the following. Firstly, build-tools has binaries like aapt2 and platform-tools has binaries like adb, so architecture would matter, so we need the ones for aarch64 that are compatible with android/termux. So what we do is use the ones provided by https://github.com/Lzhiyong/sdk-tools for build-tools i.e aapt, aapt2, aidl, dexdump, split-select and zipalign and extract them to ~/Android/sdk/build-tools/latest and the platform-tools ones to ~/Android/sdk/platform-tools-latest. Termux apt also provides some of the binaries.

Download and extract Lzhiyong/sdk-tools
curl -L https://github.com/Lzhiyong/sdk-tools/releases/download/sdk-tools_v210205/sdk-tools_v210205.tar.xz -o sdk-tools_v210205.tar.xz
tar -xf sdk-tools_v210205.tar.xz

rm -rf ~/Android/sdk/build-tools/latest
mkdir -p ~/Android/sdk/build-tools/latest
mv sdk-tools_v210205/build-tools/* ~/Android/sdk/build-tools/latest/

rm -rf ~/Android/sdk/platform-tools-latest
mkdir -p ~/Android/sdk/platform-tools-latest
mv sdk-tools_v210205/platform-tools/* ~/Android/sdk/platform-tools-latest/
Install build-tools package

Now of course, android sdk expects the binaries in their respective build-tools, like build-tools/29.0.2, with other required files, otherwise package would be considered corrupt. So we download the respective tools from google repo and extract them to ~/Android/sdk/build-tools/29.0.2. Then we replace the binaries in it with compatible ones, by creating symlinks in ~/Android/sdk/build-tools/latest/29.0.2 to the binaries in ~/Android/sdk/build-tools/latest. The binaries that come from google repo will fail to execute, like build-tools/30.0.2/aapt2 with syntax error: '(' unexpected.

If a build-tools version required is not found, check the dl.google.com/ directory under different tags at https://android.googlesource.com/platform/tools/google_prebuilts/studio/sdk/remote/ to find the available versions on https://dl.google.com/android/repository/build-tools_*.

For 29.0.2:

curl -L https://dl.google.com/android/repository/build-tools_r29.0.2-linux.zip -o build-tools_r29.0.2-linux.zip
rm -rf ~/Android/sdk/build-tools/android-10 ~/Android/sdk/build-tools/29.0.2
unzip build-tools_r29.0.2-linux.zip -d ~/Android/sdk/build-tools
mv ~/Android/sdk/build-tools/android-10 ~/Android/sdk/build-tools/29.0.2
ln -sf ~/Android/sdk/build-tools/latest/* ~/Android/sdk/build-tools/29.0.2/

For 30.0.2:

curl -L https://dl.google.com/android/repository/build-tools_r30.0.2-linux.zip -o build-tools_r30.0.2-linux.zip
rm -rf ~/Android/sdk/build-tools/android-11 ~/Android/sdk/build-tools/30.0.2
unzip build-tools_r30.0.2-linux.zip -d ~/Android/sdk/build-tools
mv ~/Android/sdk/build-tools/android-11 ~/Android/sdk/build-tools/30.0.2
ln -sf ~/Android/sdk/build-tools/latest/* ~/Android/sdk/build-tools/30.0.2/

Now note that 29.0.2 is for Android 10 and 30.0.2 for Android 11. We are linking both to Lzhiyong/sdk-tools which is based on Android 11 with possibly different versions even for 30.0.2. This can cause problems and shouldn't be normally done since build workflow may be expecting something else and we are giving it something else and there can be compatibility issues. It would be best to at least use com.android.tools.build:gradle:4.2.1 or higher so that 30.0.2 is at least used instead of 29.0.2 when building apps, even though it works for termux-tasker.

Install platform-tools package

Moreover, android sdk expects the binaries in the platform-tools directory, with other required files. If we just use the sdk-tools_v210205/platform-tools directory, package would be considered corrupt, since it doesn't have other required files, and latest tools will automatically be downloaded to platform-tools-2 and you will get log warnings like Warning: Observed package id 'platform-tools' in inconsistent location '/data/data/com.termux/files/home/Android/sdk/platform-tools-2' (Expected '/data/data/com.termux/files/home/Android/sdk/platform-tools'). So we download the respective tools from google repo and extract them to ~/Android/sdk/platform-tools. Then we replace the binaries in it with compatible ones, by creating symlinks in ~/Android/sdk/platform-tools to the binaries in ~/Android/sdk/platform-tools-latest. Although, note that technically platform binaries are not needed for building and you don't have to do create the symlinks, and adb is also provided by termux android-tools package.

For 30.0.3:

curl -L https://dl.google.com/android/repository/platform-tools_r30.0.3-linux.zip -o platform-tools_r30.0.3-linux.zip
rm -rf ~/Android/sdk/platform-tools
unzip platform-tools_r30.0.3-linux.zip -d ~/Android/sdk/
ln -sf ~/Android/sdk/platform-tools-latest/* ~/Android/sdk/platform-tools/

Install Android NDK

Now, if at this point if you try to run a gradle task for termux-app, it will fail with org.gradle.api.InvalidUserDataException: NDK not configured. Download it with SDK manager. Preferred NDK version is '21.4.7075529'. This is of course expected, since android gradle plugin would expect the ndk to be installed in ANDROID_SDK_ROOT which we haven't done yet. We can use the one provided by https://github.com/Lzhiyong/termux-ndk. The ndk-r22b is based on 22.1.7171670, which is currently also used by termux-app.

curl -L https://github.com/Lzhiyong/termux-ndk/releases/download/android-ndk/android-ndk-r22b.tar.xz -o android-ndk-r22b.tar.xz
tar -xf android-ndk-r22b.tar.xz
mkdir ~/Android/sdk/ndk
rm -rf ~/Android/sdk/ndk/22.1.7171670
mv android-ndk-r22b ~/Android/sdk/ndk/22.1.7171670

Now this NDK also have issues which probably can be fixed in upstream by @lzhiyong. When you run gradle :app:assembleDebug for termux-app, it will fail with the errors like the following and similar if not patched fully.

Execution failed for task ':terminal-emulator:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/data/data/com.termux/files/home/repos/termux-app/terminal-emulator/src/main/jni/Android.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-24 NDK_OUT=/data/data/com.termux/files/home/repos/termux-app/terminal-emulator/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/data/data/com.termux/files/home/repos/termux-app/terminal-emulator/build/intermediates/ndkBuild/debug/lib APP_CFLAGS+=-std=c11 APP_CFLAGS+=-Wall APP_CFLAGS+=-Wextra APP_CFLAGS+=-Werror APP_CFLAGS+=-Os APP_CFLAGS+=-fno-stack-protector APP_CFLAGS+=-Wl,--gc-sections termux}
  [armeabi-v7a] Compile thumb  : termux <= termux.c

  WARNING: linker: /data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-aarch64/bin/clang++.real: unsupported flags DT_FLAGS_1=0x8000001
  CANNOT LINK EXECUTABLE "/data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++.real": cannot locate symbol "posix_spawn_file_actions_init" referenced by "/data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-aarch64/bin/clang++.real"...
  WARNING: linker: /data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-aarch64/bin/clang.real: unsupported flags DT_FLAGS_1=0x8000001
  CANNOT LINK EXECUTABLE "/data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/clang.real": cannot locate symbol "posix_spawn_file_actions_init" referenced by "/data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-aarch64/bin/clang.real"...
  make: *** [/data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/build/core/build-binary.mk:476: /data/data/com.termux/files/home/repos/termux-app/terminal-emulator/build/intermediates/ndkBuild/debug/obj/local/armeabi-v7a/objs-debug/termux/termux.o] Aborted
Fix cannot locate symbol "posix_spawn_file_actions_init"

CANNOT LINK EXECUTABLE "/data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++.real": cannot locate symbol "posix_spawn_file_actions_init" referenced by "/data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-aarch64/bin/clang++.real"...

We need to find what provides the posix_spawn_file_actions_init symbol. The NDK sysroot does provide it, but was only provided for sdk 28 and higher. The termux libandroid-spawn package at $PREFIX/lib/libandroid-spawn.so as shared lib and libandroid-spawn-static package at $PREFIX/lib/libandroid-spawn.a as static lib also provides it.

Helper one liners to find which library provides the symbols:

# locate symbols exported by static libraries
symbol="posix_spawn_file_actions_init"; path="$PREFIX"; { while IFS= read -r -d '' lib; do echo "$lib"; nm "$lib" 2>/dev/null | grep "$symbol" | grep -v " U "; done < <(find "$path" -name "*.a" -print0); } | grep -B 1 "$symbol"

# locate symbols exported by shared libraries
symbol="posix_spawn_file_actions_init"; path="$PREFIX"; { while IFS= read -r -d '' lib; do echo "$lib"; nm -D "$lib" 2>/dev/null | grep "$symbol" | grep -v " U "; done < <(find "$path" -name "*.so" -print0); } | grep -B 1 "$symbol"

To actually fix the issue, we patch the 4 binary's DT_NEEDED to also look for libandroid-spawn.so as a dependency with patchelf.

pkg install patchelf libandroid-spawn
cd /data/data/com.termux/files/home/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-aarch64/bin
patchelf --add-needed libandroid-spawn.so clang++.real
patchelf --add-needed libandroid-spawn.so clang.real
patchelf --add-needed libandroid-spawn.so aarch64-linux-android-ld
patchelf --add-needed libandroid-spawn.so lld

# Confirm if patched properly
readelf -d clang++.real | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libandroid-spawn.so]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc++_shared.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
Fix unsupported flags DT_FLAGS_1=0x8000001

WARNING: linker: /data/data/com.termux/files/home/termux_img/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-aarch64/bin/clang++.real: unsupported flags DT_FLAGS_1=0x8000001

These are just warnings and you may optionally ignore them but will pollute console when running commands. More info at https://wiki.termux.com/wiki/FAQ#Why_does_a_compiled_program_show_warnings

To fix the issue we use termux-elf-cleaner.

pkg install termux-elf-cleaner
cd /data/data/com.termux/files/home/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-aarch64/bin
termux-elf-cleaner clang++.real
termux-elf-cleaner clang.real
termux-elf-cleaner lld
termux-elf-cleaner llvm-strip
Additional config

Note that I had already previously installed build-essential ndk-multilib ndk-sysroot packages. You also need to run export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib when building the app with NDK, otherwise it will fail with library "libandroid-spawn.so" not found. Run gradle --stop if you change the value before building.

Final Directory Structure

The following should be the final directory structure for `~/Android`. It is truncated and does not list all directories.
$ find Android/ -maxdepth 4 -type d
Android/
Android/sdk
Android/sdk/licenses
Android/sdk/cmdline-tools
Android/sdk/cmdline-tools/latest
Android/sdk/cmdline-tools/latest/lib
Android/sdk/cmdline-tools/latest/bin
Android/sdk/platform-tools-latest
Android/sdk/platforms
Android/sdk/platforms/android-30
Android/sdk/platforms/android-30/templates
Android/sdk/platforms/android-30/data
Android/sdk/platforms/android-29
Android/sdk/platforms/android-29/templates
Android/sdk/platforms/android-29/data
Android/sdk/platforms/android-28
Android/sdk/platforms/android-28/templates
Android/sdk/platforms/android-28/data
Android/sdk/platform-tools
Android/sdk/platform-tools/lib64
Android/sdk/platform-tools/systrace
Android/sdk/build-tools
Android/sdk/build-tools/latest
Android/sdk/build-tools/29.0.2
Android/sdk/build-tools/29.0.2/renderscript
Android/sdk/build-tools/29.0.2/lib64
Android/sdk/build-tools/29.0.2/lib
Android/sdk/build-tools/30.0.2
Android/sdk/build-tools/30.0.2/renderscript
Android/sdk/build-tools/30.0.2/lib64
Android/sdk/build-tools/30.0.2/lib
Android/sdk/ndk
Android/sdk/ndk/22.1.7171670
Android/sdk/ndk/22.1.7171670/python-packages
Android/sdk/ndk/22.1.7171670/build
Android/sdk/ndk/22.1.7171670/toolchains
Android/sdk/ndk/22.1.7171670/sources
Android/sdk/ndk/22.1.7171670/prebuilt

aapt2 syntax error: '(' unexpected

This is the final issue that occurs when running gradle :app:assembleDebug task. It seems that android gradle downloads/gets aapt2 dynamically as a dependency as well while building and does not only use the sdk/build-tools/30.0.2 one. The error is the same as when running build-tools/30.0.2/aapt2 and also mentioned in Lzhiyong/termux-ndk/build-app, although its solution replaces the .jar file instead of aapt2 binary.

Error
> Task :termux-shared:generateDebugRFile UP-TO-DATE
AAPT2 aapt2-4.2.2-7147631-linux Daemon #0: Unexpected error output: /data/data/com.termux/files/home/termux_img/.gradle/caches/transforms-3/3c0280d63d25eeb181d70b9cff36b39e/transformed/aapt2-4.2.2-7147631-linux/aapt2[1]: syntax error: '(' unexpected
AAPT2 aapt2-4.2.2-7147631-linux Daemon #1: Unexpected error output: /data/data/com.termux/files/home/termux_img/.gradle/caches/transforms-3/3c0280d63d25eeb181d70b9cff36b39e/transformed/aapt2-4.2.2-7147631-linux/aapt2[1]: syntax error: '(' unexpected
> Task :app:processDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform appcompat-1.3.0.aar (androidx.appcompat:appcompat:1.3.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}.
      > Execution failed for AarResourcesCompilerTransform: /data/data/com.termux/files/home/termux_img/.gradle/caches/transforms-3/6a00b2e60878b5caf06f17cfe50137cb/transformed/appcompat-1.3.0.
         > AAPT2 aapt2-4.2.2-7147631-linux Daemon #1: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
  

The fix is to add android.aapt2FromMavenOverride=/data/data/com.termux/files/home/Android/sdk/build-tools/latest/aapt2 in root level gradle.properties.

Old fix

The hack is to replace the /data/data/com.termux/files/home/termux_img/.gradle/caches/transforms-3/3c0280d63d25eeb181d70b9cff36b39e/transformed/aapt2-4.2.2-7147631-linux/aapt2 with ~/Android/sdk/build-tools/latest/aapt2. That does work, but the only issue is that, it seems that whenever gradle plugin is started again, the aapt2 is updated again and we must let gradle :app:assembleDebug task to run and fail once. Then we replace it, and run gradle :app:assembleDebug again. Possibly, replacing the jar does not require this.

For 29.0.2:

ln -sf ~/Android/sdk/build-tools/latest/aapt2 ~/.gradle/caches/transforms-3/10ed78c3bcd82595e27b6d2f34ea17c9/transformed/aapt2-4.1.1-6503028-linux/aapt2

For 30.0.2:

ln -sf ~/Android/sdk/build-tools/latest/aapt2 ~/.gradle/caches/transforms-3/3c0280d63d25eeb181d70b9cff36b39e/transformed/aapt2-4.2.2-7147631-linux/aapt2

The paths above were for mine, check your error for yours, should change depending on version, etc.

  

Build termux-tasker and termux-app

Add --add-opens=java.base/java.io=ALL-UNNAMED to org.gradle.jvmargs and android.aapt2FromMavenOverride=/data/data/com.termux/files/home/Android/sdk/build-tools/latest/aapt2 in root level gradle.properties, then run gradle :app:assembleDebug.

termux-tasker-build.log
Ⲧ git diff
diff --git a/gradle.properties b/gradle.properties
index 9e6fce1..1aca680 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -11,7 +11,8 @@
 # The setting is particularly useful for tweaking memory settings.
 android.enableJetifier=true
 android.useAndroidX=true
-org.gradle.jvmargs=-Xmx1536m
+org.gradle.jvmargs=-Xmx1536m --add-opens=java.base/java.io=ALL-UNNAMED
+android.aapt2FromMavenOverride=/data/data/com.termux/files/home/Android/sdk/build-tools/latest/aapt2
 
 # When configured, Gradle will run in incubating parallel mode.
 # This option should only be used with decoupled projects. More details, visit


Ⲧ gradle clean
> Task :clean UP-TO-DATE
> Task :app:clean

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2-rc-1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 3s
2 actionable tasks: 1 executed, 1 up-to-date


Ⲧ gradle :app:assembleDebug
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig
> Task :app:javaPreCompileDebug
> Task :app:checkDebugAarMetadata
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:extractDeepLinksDebug
> Task :app:processDebugMainManifest
> Task :app:mergeDebugResources
> Task :app:processDebugManifest
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets
> Task :app:compressDebugAssets
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:desugarDebugFileDependencies
> Task :app:mergeDebugJniLibFolders
> Task :app:checkDebugDuplicateClasses
> Task :app:processDebugManifestForPackage
> Task :app:mergeDebugNativeLibs
> Task :app:mergeDebugJavaResource
> Task :app:processDebugResources
> Task :app:mergeExtDexDebug

> Task :app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :app:compileDebugSources
> Task :app:mergeLibDexDebug
> Task :app:dexBuilderDebug
> Task :app:stripDebugDebugSymbols NO-SOURCE
> Task :app:validateSigningDebug
> Task :app:mergeProjectDexDebug
> Task :app:packageDebug
> Task :app:assembleDebug

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2-rc-1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 46s
26 actionable tasks: 26 executed


Ⲧ ls app/build/outputs/apk/debug
app-debug.apk  output-metadata.json
  
termux-app-build.log
Ⲧ git diff
diff --git a/gradle.properties b/gradle.properties
index c8f9ae0..2ad66ce 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -12,7 +12,8 @@
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
 # org.gradle.parallel=true
-org.gradle.jvmargs=-Xmx2048M
+org.gradle.jvmargs=-Xmx2048M --add-opens=java.base/java.io=ALL-UNNAMED
+android.aapt2FromMavenOverride=/data/data/com.termux/files/home/Android/sdk/build-tools/latest/aapt2
 android.useAndroidX=true
 
 minSdkVersion=24


Ⲧ gradle clean
> Task :clean UP-TO-DATE
> Task :app:externalNativeBuildCleanDebug
Clean termux-bootstrap armeabi-v7a
Clean termux-bootstrap arm64-v8a
Clean termux-bootstrap x86
Clean termux-bootstrap x86_64
> Task :app:externalNativeBuildCleanRelease
> Task :app:clean

> Task :terminal-emulator:externalNativeBuildCleanDebug
Clean termux armeabi-v7a
Clean termux arm64-v8a
Clean termux x86
Clean termux x86_64

> Task :terminal-emulator:externalNativeBuildCleanRelease
> Task :terminal-emulator:clean
> Task :terminal-view:clean
> Task :termux-shared:clean

BUILD SUCCESSFUL in 14s
9 actionable tasks: 8 executed, 1 up-to-date


Ⲧ gradle :app:assembleDebug
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :terminal-emulator:preBuild UP-TO-DATE
> Task :terminal-emulator:preDebugBuild UP-TO-DATE
> Task :terminal-emulator:compileDebugAidl NO-SOURCE
> Task :terminal-view:preBuild UP-TO-DATE
> Task :terminal-view:preDebugBuild UP-TO-DATE
> Task :terminal-view:compileDebugAidl NO-SOURCE
> Task :termux-shared:preBuild UP-TO-DATE
> Task :termux-shared:preDebugBuild UP-TO-DATE
> Task :termux-shared:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :terminal-emulator:packageDebugRenderscript NO-SOURCE
> Task :terminal-view:packageDebugRenderscript NO-SOURCE
> Task :termux-shared:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE

> Task :app:downloadBootstraps
Downloading https://github.com/termux/termux-packages/releases/download/bootstrap-2021.06.30-r1/bootstrap-aarch64.zip ...
Downloading https://github.com/termux/termux-packages/releases/download/bootstrap-2021.06.30-r1/bootstrap-arm.zip ...
Downloading https://github.com/termux/termux-packages/releases/download/bootstrap-2021.06.30-r1/bootstrap-i686.zip ...
Downloading https://github.com/termux/termux-packages/releases/download/bootstrap-2021.06.30-r1/bootstrap-x86_64.zip ...

> Task :app:generateDebugBuildConfig
> Task :app:javaPreCompileDebug
> Task :terminal-emulator:writeDebugAarMetadata
> Task :terminal-view:writeDebugAarMetadata
> Task :termux-shared:writeDebugAarMetadata
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :terminal-emulator:compileDebugRenderscript NO-SOURCE
> Task :terminal-emulator:generateDebugResValues
> Task :terminal-emulator:generateDebugResources
> Task :terminal-emulator:packageDebugResources
> Task :terminal-view:compileDebugRenderscript NO-SOURCE
> Task :terminal-view:generateDebugResValues
> Task :terminal-view:generateDebugResources
> Task :terminal-view:packageDebugResources
> Task :termux-shared:compileDebugRenderscript NO-SOURCE
> Task :termux-shared:generateDebugResValues
> Task :termux-shared:generateDebugResources
> Task :termux-shared:packageDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:extractDeepLinksDebug
> Task :terminal-emulator:extractDeepLinksDebug
> Task :terminal-emulator:processDebugManifest
> Task :terminal-view:extractDeepLinksDebug
> Task :terminal-view:processDebugManifest
> Task :termux-shared:extractDeepLinksDebug
> Task :app:checkDebugAarMetadata
> Task :termux-shared:processDebugManifest
> Task :app:mergeDebugResources
> Task :app:processDebugMainManifest
> Task :app:processDebugManifest
> Task :terminal-emulator:compileDebugLibraryResources
> Task :app:processDebugManifestForPackage
> Task :terminal-emulator:parseDebugLocalResources
> Task :terminal-view:compileDebugLibraryResources
> Task :terminal-view:parseDebugLocalResources
> Task :terminal-emulator:generateDebugRFile
> Task :termux-shared:compileDebugLibraryResources
> Task :termux-shared:parseDebugLocalResources
> Task :terminal-emulator:generateDebugBuildConfig
> Task :terminal-view:generateDebugRFile
> Task :terminal-emulator:javaPreCompileDebug
> Task :terminal-view:generateDebugBuildConfig

> Task :terminal-emulator:compileDebugJavaWithJavac
Note: /data/data/com.termux/files/home/repos/termux-app/terminal-emulator/src/main/java/com/termux/terminal/TerminalSession.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :terminal-view:javaPreCompileDebug
> Task :terminal-emulator:bundleLibCompileToJarDebug
> Task :termux-shared:generateDebugBuildConfig
> Task :termux-shared:javaPreCompileDebug
> Task :app:generateJsonModelDebug
> Task :termux-shared:generateDebugRFile

> Task :terminal-view:compileDebugJavaWithJavac
Note: /data/data/com.termux/files/home/repos/termux-app/terminal-view/src/main/java/com/termux/view/TerminalView.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :terminal-view:bundleLibCompileToJarDebug
> Task :terminal-emulator:generateJsonModelDebug

> Task :terminal-emulator:externalNativeBuildDebug
Build termux_armeabi-v7a
Build termux_arm64-v8a
Build termux_x86
Build termux_x86_64

> Task :terminal-emulator:mergeDebugJniLibFolders

> Task :termux-shared:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :termux-shared:bundleLibCompileToJarDebug
> Task :terminal-emulator:mergeDebugNativeLibs
> Task :terminal-emulator:stripDebugDebugSymbols
> Task :terminal-emulator:copyDebugJniLibsProjectOnly
> Task :terminal-view:mergeDebugJniLibFolders
> Task :terminal-view:mergeDebugNativeLibs NO-SOURCE
> Task :terminal-view:stripDebugDebugSymbols NO-SOURCE
> Task :terminal-view:copyDebugJniLibsProjectOnly
> Task :termux-shared:mergeDebugJniLibFolders
> Task :termux-shared:mergeDebugNativeLibs NO-SOURCE
> Task :termux-shared:stripDebugDebugSymbols NO-SOURCE
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :termux-shared:copyDebugJniLibsProjectOnly
> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :terminal-emulator:mergeDebugShaders

> Task :app:externalNativeBuildDebug
Build termux-bootstrap_armeabi-v7a

> Task :app:processDebugResources

> Task :app:externalNativeBuildDebug
Build termux-bootstrap_arm64-v8a
Build termux-bootstrap_x86
Build termux-bootstrap_x86_64

> Task :app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :app:compileDebugSources
> Task :terminal-emulator:compileDebugShaders NO-SOURCE
> Task :terminal-emulator:generateDebugAssets UP-TO-DATE
> Task :terminal-emulator:packageDebugAssets
> Task :terminal-view:mergeDebugShaders
> Task :terminal-view:compileDebugShaders NO-SOURCE
> Task :terminal-view:generateDebugAssets UP-TO-DATE
> Task :terminal-view:packageDebugAssets
> Task :termux-shared:mergeDebugShaders
> Task :termux-shared:compileDebugShaders NO-SOURCE
> Task :termux-shared:generateDebugAssets UP-TO-DATE
> Task :termux-shared:packageDebugAssets
> Task :app:mergeDebugAssets
> Task :app:compressDebugAssets
> Task :app:processDebugJavaRes NO-SOURCE
> Task :terminal-emulator:processDebugJavaRes NO-SOURCE
> Task :terminal-emulator:bundleLibResDebug NO-SOURCE
> Task :terminal-view:processDebugJavaRes NO-SOURCE
> Task :terminal-view:bundleLibResDebug NO-SOURCE
> Task :termux-shared:processDebugJavaRes NO-SOURCE
> Task :termux-shared:bundleLibResDebug NO-SOURCE
> Task :app:desugarDebugFileDependencies
> Task :terminal-view:bundleLibRuntimeToDirDebug
> Task :app:checkDebugDuplicateClasses
> Task :termux-shared:bundleLibRuntimeToDirDebug
> Task :app:mergeDebugJavaResource
> Task :terminal-emulator:bundleLibRuntimeToDirDebug
> Task :app:mergeExtDexDebug
> Task :app:dexBuilderDebug
> Task :app:mergeDebugJniLibFolders
> Task :app:mergeLibDexDebug
> Task :app:mergeProjectDexDebug
> Task :app:validateSigningDebug
> Task :app:writeDebugAppMetadata
> Task :app:writeDebugSigningConfigVersions
> Task :app:mergeDebugNativeLibs
> Task :app:stripDebugDebugSymbols
> Task :app:packageDebug
> Task :app:assembleDebug

BUILD SUCCESSFUL in 5m 12s
87 actionable tasks: 87 executed


Ⲧ ls app/build/outputs/apk/debug
output-metadata.json              termux-app-universal-debug.apk
termux-app-arm64-v8a-debug.apk    termux-app-x86-debug.apk
termux-app-armeabi-v7a-debug.apk  termux-app-x86_64-debug.apk
  

Storage Requirements

All of this would require at least take ~10GB space and more depending on what you build. The ~/Android directory takes ~5GB, the ~/.gradle directory takes ~600MB. The required packages take over a GB. The termux-app final build + ABI APKs also take around ~600MB.

`~/Android`
$ du -h --max-depth=2 Android/
28K     Android/sdk/licenses
106M    Android/sdk/cmdline-tools
25M     Android/sdk/platform-tools-latest
455M    Android/sdk/platforms
18M     Android/sdk/platform-tools
267M    Android/sdk/build-tools
4.0K    Android/sdk/.temp
4.0G    Android/sdk/ndk
4.9G    Android/sdk
4.9G    Android/
  
`~/.gradle`
$ du -h --max-depth=1 .gradle/
587M    .gradle/caches
212K    .gradle/native
32K     .gradle/7.2-rc-1
8.0K    .gradle/checksums
8.0K    .gradle/notifications
4.0K    .gradle/vcs-1
4.0K    .gradle/jdks
4.0K    .gradle/.tmp
28M     .gradle/daemon
614M    .gradle/
  
`openjdk-17` `kotlin` `gradle`
$ apt show openjdk-17 kotlin gradle
Package: openjdk-17
Version: 17.0-8
Maintainer: @termux
Installed-Size: 299 MB
Depends: freetype, libandroid-shmem, libandroid-spawn, libiconv, zlib
Suggests: cups, fontconfig, libx11, libxrender
Homepage: https://github.com/PojavLauncherTeam/mobile
Download-Size: 156 MB
APT-Sources: https://grimler.se/termux-packages-24 stable/main aarch64 Packages
Description: Java development kit and runtime

Package: kotlin
Version: 1.5.21
Maintainer: @termux
Installed-Size: 69.3 MB
Depends: openjdk-17
Homepage: https://kotlinlang.org/
Download-Size: 61.6 MB
APT-Manual-Installed: yes
APT-Sources: https://grimler.se/termux-packages-24 stable/main aarch64 Packages
Description: The Kotlin Programming Language

Package: gradle
Version: 7.2-rc-1-0
Status: install ok installed
Maintainer: @termux
Installed-Size: 308 MB
Depends: openjdk-17
Homepage: https://gradle.org/
Download-Size: unknown
APT-Manual-Installed: yes
APT-Sources: /data/data/com.termux/files/usr/var/lib/dpkg/status
Description: Powerful build system for the JVM
  

On my device, the packages are of course stored on the internal sd card, but I created an ext4 image in an external portable sd card to store ~/Android and ~/.gradle directories. It was mounted as a loop device and then bindfs mounted again with termux uid ownership, both of which of course requires root. Run id -u in a non-root shell to find termux uid and replace 10500 in below commands with it. I used mount binary provided by busybox app, the android toybox /system/bin/mount/losetup binary has issues with loop devices on my device and fails with mount: losetup failed 1 and $PREFIX/bin/mount is just a wrapper for it. You can get bindfs from here and sudo from here.

# Start interactive root shell
sudo su

# Create 10GB img
dd if=/dev/zero of=/storage/XXXX-XXXX/termux.img bs=1M count=0 seek=10000

# Format as ext4
pkg install e2fsprogs
mkfs.ext4 "/storage/XXXX-XXXX/termux.img"

# Create mount directories
mkdir -p "/data/termux_img" "/data/data/com.termux/files/home/termux_img"

# mount loop img
mount -o loop "/storage/XXXX-XXXX/termux.img" "/data/termux_img"

# bindfs remount the mount point with termux ownership.
# 10500 must be replaced with termux uid found with "id -u" in a non-root shell
bindfs --map=0/10500:@0/@10500 "/data/termux_img" "/data/data/com.termux/files/home/termux_img"

# Create symlinks. The gradle daemon must be stopped or incorrect
# symlinks will be created since gradle daemon will automatically
# create missing directory when it detects it has been deleted.
# You may move the directories to termux_img/ instead of deleting.
gradle --stop
rm -rf ~/Android ~/.gradle ~/.m2
ln -s /data/data/com.termux/files/home/termux_img/Android ~/Android
ln -s /data/data/com.termux/files/home/termux_img/.gradle ~/.gradle
ln -s /data/data/com.termux/files/home/termux_img/.m2 ~/.m2

Future

  • Considering gradle is working, at least on aarch64, we can merge with master, unless changes are requested.
  • Termux should officially provide NDK version packages as per Android sdk requirements, likely in a github repository.
  • Termux should officially provide build-tools and platform-tools as per Android sdk requirements, likely in a github repository and possibly all major recent versions, like 29.0.2, 29.0.3, etc (check output for sdkmanager --list). The termux apt repos/mirrors removes old versions and likely not the right place for it since sizes are too large. We can probably use a github repo where build-tools are repacked with the binaries of the right versions and provide as a tar file. Users can download and extract it in Android/sdk/build-tools manually or we can provide a script for it, maybe sdkmanager can be patched.
  • The aapt2-4.2.2-7147631-linux/aapt2[1]: syntax error: '(' unexpected should be looked into to see if it can be fixed. FIXED

Let me know if there are any mistakes/typos.

Edit 1:

Updated build-tools, platform-tools and NDK instructions.

Edit 2:

Updated aapt2 syntax error fix.

@suhan-paradkar suhan-paradkar marked this pull request as ready for review August 5, 2021 02:30
@ghost
Copy link

ghost commented Aug 5, 2021

Screenshot_2021-08-05-09-56-12-502_com android chrome
These have been one of my dreams for years!!
When did you do all these? I've been trying the same for the last 3 months, using https://github.com/Lzhiyong/'s OpenJDK and Android SDK + NDK in Termux's shell!! Hope it gets available in near future!! ☺️

Although the packages are big, which seems not get accepted as bigger than 150 even 200 MBs, but those are most demanded.. Thanks for this pull request!! ❤️

@Hax4us
Copy link
Member

Hax4us commented Aug 5, 2021

According to https://github.com/jrodbx/agp-sources/blob/2b16dd9e08744d6e4f011fa5d0c550530c6a2c0e/4.2.0-alpha12/com.android.tools.build/gradle/com/android/build/gradle/internal/res/Aapt2FromMaven.kt#L83 , we can specify custom local aapt2 like this (gradle.properties)

android.aapt2FromMavenOverride=/path/to/aapt2

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Aug 5, 2021

According to https://github.com/jrodbx/agp-sources/blob/2b16dd9e08744d6e4f011fa5d0c550530c6a2c0e/4.2.0-alpha12/com.android.tools.build/gradle/com/android/build/gradle/internal/res/Aapt2FromMaven.kt#L83 , we can specify custom local aapt2 like this (gradle.properties)

android.aapt2FromMavenOverride=/path/to/aapt2

Thanks, it is working: WARNING:: The option setting 'android.aapt2FromMavenOverride=/data/data/com.termux/files/home/Android/sdk/build-tools/latest/aapt2' is experimental..

Moreover, as per this, we can export a custom repo url for sdkmanager with SDK_TEST_BASE_URL, although seems to have caching issues. At least should make things easier if we host a custom repo for build-tools and platform-tools.

@agnostic-apollo
Copy link
Member

@masterjavaofficial

These have been one of my dreams for years!!
When did you do all these?

The ones in the picture are for the future, they are not done yet. The building of termux-app with openjdk-17 and gradle (this pull request artifact) package was done in last 2 days.

I've been trying the same for the last 3 months, using https://github.com/Lzhiyong/'s OpenJDK and Android SDK + NDK in >Termux's shell!! Hope it gets available in near future!! relaxed

Didn't instructions at https://github.com/Lzhiyong/termux-ndk/tree/master/build-app work?

Note that Lzhiyong/* releases are only for aarch64 so don't expect building for other architectures currently.

@agnostic-apollo
Copy link
Member

I don't see any issues with the pull request currently, @xeffyr any changes before its merged?

@suhan-paradkar
Copy link
Contributor Author

Since Lzhiyong/* packages have their patches out open I guess it would be easier to port them tho.. won't it @agnostic-apollo ?

@agnostic-apollo
Copy link
Member

Since Lzhiyong/* packages have their patches out open I guess it would be easier to port them tho.. won't it @agnostic-apollo ?

For NDK can't really say without actually trying to port. Considering OP says it builds in proot, so should be build-able in docker as well. Some build instructions are commented out as well as pseudo code, but a script to automatically build it should be possible. Not sure exactly what issues may arise, NDK is huge. Also patches are version dependent and there are different components that need building.

https://github.com/Lzhiyong/termux-ndk#issues

each NDK version has a lot of changes, direct compilation will fail, the build script are not generic, so please solve the error yourself.

build-tools would probably be easier.

@suhan-paradkar
Copy link
Contributor Author

Also.. I don't think it would compile easily on 32-bit platforms tho....

@Yisus7u7
Copy link
Contributor

Yisus7u7 commented Aug 5, 2021

Además ... aunque no creo que se compile fácilmente en plataformas de 32 bits ...

Just that I was going to ask, I'm unfortunately a 32-bit user

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Aug 5, 2021

Also.. I don't think it would compile easily on 32-bit platforms tho....

NDK is not officially supported on arm32, arm64 or linux x86. Its working on arm64 with hacks, they may or may not be possible for arm32 in current versions. No specific need for on device builds of NDK itself.

https://groups.google.com/g/android-ndk/c/tcxcRWsBINQ
https://developer.android.com/ndk/guides/other_build_systems
https://github.com/Lzhiyong/termux-ndk/blob/master/patches/ndk-build.patch

Apps that don't require native/NDK building will still be build-able on 32-bit archs once build-tools are ported, when openjdk-17 and any possible gradle issues are fixed of course.

@ghost ghost merged commit 9e0233c into termux:master Aug 5, 2021
@Yisus7u7
Copy link
Contributor

Yisus7u7 commented Aug 5, 2021

Ok, I'll look forward to java in 32-bit

@suhan-paradkar suhan-paradkar deleted the gradle branch August 6, 2021 07:32
agnostic-apollo added a commit to termux/termux-app that referenced this pull request Jan 7, 2022
… add commit hash and `github` to APK file names

The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html

APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35 and 94e01d6, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.

For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.

For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.

Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.

The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.

- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check #1904.

So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.

```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```

The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`

The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at termux/termux-packages#7227 (comment).

```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```

The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`

Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.

Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
agnostic-apollo added a commit to termux/termux-app that referenced this pull request Jan 22, 2022
… add commit hash and `github` to APK file names

The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html

APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35 and 94e01d6, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.

For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.

For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.

Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.

The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.

- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check #1904.

So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.

```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```

The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`

The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at termux/termux-packages#7227 (comment).

```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```

The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`

Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.

Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
Peter-Feng-32 pushed a commit to Peter-Feng-32/ToozKit that referenced this pull request Mar 9, 2022
… add commit hash and `github` to APK file names

The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html

APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35 and 94e01d6, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.

For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.

For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.

Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.

The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.

- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check termux#1904.

So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.

```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```

The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`

The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at termux/termux-packages#7227 (comment).

```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```

The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`

Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.

Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
AdamMickiewich pushed a commit to VolyaTeam/dzida-app that referenced this pull request Aug 8, 2022
… add commit hash and `github` to APK file names

The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html

APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35 and 94e01d6, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.

For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.

For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.

Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.

The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.

- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check termux#1904.

So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.

```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```

The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`

The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at termux/termux-packages#7227 (comment).

```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```

The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`

Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.

Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
shrihankp pushed a commit to reisxd/termux-app that referenced this pull request Oct 20, 2022
… add commit hash and `github` to APK file names

The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html

APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35 and 94e01d6, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.

For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.

For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.

Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.

The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.

- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check termux#1904.

So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.

```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```

The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`

The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at termux/termux-packages#7227 (comment).

```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```

The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`

Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.

Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
@termux termux deleted a comment from movies-downloader-bot Mar 23, 2023
@termux termux deleted a comment from movies-downloader-bot Mar 23, 2023
Copy link

@Faory212 Faory212 left a comment

Choose a reason for hiding this comment

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

Co

@Git2020104
Copy link

But I get this error message when extracting Lzhiyong/sdk-tools

tar: This does not look like a tar archive xz: (stdin): File format not recognized tar: Child returned status 1 tar: Error is not recoverable: exiting now

Why?? Yet i have followed all steps well upto this point.

@thunder-coding
Copy link
Member

But I get this error message when extracting Lzhiyong/sdk-tools

tar: This does not look like a tar archive xz: (stdin): File format not recognized tar: Child returned status 1 tar: Error is not recoverable: exiting now

Why?? Yet i have followed all steps well upto this point.

Please report a new issue instead of commenting on PRs

@ansarierfan99
Copy link

How to do it in mobile device?

@thunder-coding
Copy link
Member

If you have any questions on how to use this package you can always create a new GitHub discussion instead of digging on old PRs: https://github.com/termux/termux-packages/discussions

Locking the PR since this is just attracting spam now

@termux termux locked as spam and limited conversation to collaborators Apr 11, 2024
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants