mirror of
https://github.com/izzy2lost/aab2apk.git
synced 2026-06-19 01:20:08 -07:00
super messy
This commit is contained in:
@@ -17,12 +17,22 @@ jobs:
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Build aarch64 bundletool using GraalVM aarch64 container
|
||||
- name: Build aarch64 bundletool using buildx
|
||||
run: |
|
||||
docker run --rm --platform linux/arm64 \
|
||||
-v "${{ github.workspace }}":/work -w /work \
|
||||
ghcr.io/graalvm/native-image:23.3.2-java21 \
|
||||
sh -c "apt-get update && apt-get install -y unzip zip build-essential clang pkg-config zlib1g-dev && native-image --no-fallback -jar bundletool/bundletool.jar -H:Name=bundletool-arm64"
|
||||
docker buildx create --use || true
|
||||
docker buildx build --load --platform linux/arm64 \
|
||||
-f - . <<'DOCKERFILE'
|
||||
FROM ubuntu:22.04
|
||||
RUN apt-get update && apt-get install -y curl unzip zip build-essential clang pkg-config zlib1g-dev openjdk-21-jdk-headless
|
||||
WORKDIR /work
|
||||
COPY bundletool/bundletool.jar .
|
||||
RUN curl -L -O https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-23.3.2/graalvm-ce-java21-linux-aarch64-23.3.2.tar.gz \
|
||||
&& tar -xzf graalvm-ce-java21-linux-aarch64-23.3.2.tar.gz \
|
||||
&& rm graalvm-ce-java21-linux-aarch64-23.3.2.tar.gz
|
||||
ENV PATH=/work/graalvm-ce-java21-23.3.2/bin:$PATH
|
||||
RUN native-image --no-fallback -jar bundletool.jar -H:Name=bundletool-arm64
|
||||
RUN ls -lh bundletool-arm64
|
||||
DOCKERFILE
|
||||
|
||||
- name: Verify binary (if produced)
|
||||
run: |
|
||||
|
||||
@@ -12,13 +12,12 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up GraalVM (Java 21) with native-image
|
||||
uses: graalvm/setup-graalvm@v2
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
distribution: 'graalvm-ce'
|
||||
graalvm-version: '23.3.2'
|
||||
distribution: 'graalvm-community'
|
||||
version: '23.3.2'
|
||||
java-version: '21'
|
||||
components: 'native-image'
|
||||
github-token: '${{ secrets.GITHUB_TOKEN }}'
|
||||
|
||||
- name: Install build deps
|
||||
run: |
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,6 +3,11 @@ plugins {
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.aab2apk"
|
||||
compileSdk = 36
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<manifest package="com.aab2apk" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application android:label="aab2apk" android:allowBackup="true" android:icon="@mipmap/ic_launcher">
|
||||
<activity android:name=".MainActivity" android:exported="true">
|
||||
<intent-filter>
|
||||
|
||||
Binary file not shown.
@@ -41,32 +41,49 @@ object AabToApkManager {
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure a bundletool asset (if packaged) is installed to filesDir and set executable
|
||||
val bundletoolFile = File(context.filesDir, "bundletool")
|
||||
// Check for bundletool.jar in assets and copy to internal storage
|
||||
val bundletoolJarFile = File(context.filesDir, "bundletool.jar")
|
||||
try {
|
||||
if (!bundletoolFile.exists()) {
|
||||
// Attempt to copy bundled asset (if present) into filesDir
|
||||
context.assets.open("bundletool").use { input ->
|
||||
bundletoolFile.outputStream().use { output -> input.copyTo(output) }
|
||||
if (!bundletoolJarFile.exists()) {
|
||||
// Attempt to copy bundled jar (if present) into filesDir
|
||||
context.assets.open("bundletool.jar").use { input ->
|
||||
bundletoolJarFile.outputStream().use { output -> input.copyTo(output) }
|
||||
}
|
||||
bundletoolFile.setExecutable(true)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// If asset not present or copy failed, we'll proceed to check for an existing executable.
|
||||
// If jar not present or copy failed, we'll proceed to check for an existing jar.
|
||||
}
|
||||
if (bundletoolFile.exists() && bundletoolFile.canExecute()) {
|
||||
|
||||
if (bundletoolJarFile.exists()) {
|
||||
// Build output path
|
||||
val outFile = File(context.filesDir, "output.apks")
|
||||
val cmd = arrayListOf(bundletoolFile.absolutePath, "build-apks", "--bundle=${aabFile.absolutePath}", "--output=${outFile.absolutePath}", "--mode=universal")
|
||||
|
||||
// Use Java runtime to execute bundletool.jar
|
||||
val javaHome = System.getProperty("java.home")
|
||||
val javaExecutable = File(javaHome, "bin/java").absolutePath
|
||||
|
||||
val cmd = arrayListOf(
|
||||
javaExecutable,
|
||||
"-jar",
|
||||
bundletoolJarFile.absolutePath,
|
||||
"build-apks",
|
||||
"--bundle=${aabFile.absolutePath}",
|
||||
"--output=${outFile.absolutePath}",
|
||||
"--mode=universal"
|
||||
)
|
||||
|
||||
Log.i(TAG, "Running: ${cmd.joinToString(" ")}")
|
||||
val procBuilder = ProcessBuilder(cmd)
|
||||
procBuilder.redirectErrorStream(true)
|
||||
procBuilder.environment()["JAVA_HOME"] = javaHome
|
||||
|
||||
val proc = procBuilder.start()
|
||||
val stdout = StringBuilder()
|
||||
proc.inputStream.bufferedReader().useLines { lines ->
|
||||
lines.forEach { stdout.append(it).append("\n") }
|
||||
}
|
||||
val exit = proc.waitFor()
|
||||
|
||||
if (exit == 0) {
|
||||
// If outputDirUri provided, copy the result there
|
||||
if (outputDirUri != null) {
|
||||
@@ -86,9 +103,9 @@ object AabToApkManager {
|
||||
return@withContext Result.failure(Exception("bundletool failed with exit $exit\n${stdout}"))
|
||||
}
|
||||
} else {
|
||||
// No bundletool available — inform user what to do
|
||||
val msg = """bundletool executable not found in app files.
|
||||
To convert an AAB to APK on-device you must provide a bundletool binary built for Android and place it at: ${context.filesDir}/bundletool
|
||||
// No bundletool.jar available — inform user what to do
|
||||
val msg = """bundletool.jar not found in app assets.
|
||||
To convert an AAB to APK on-device you must place bundletool.jar at: app/src/main/assets/bundletool.jar
|
||||
Alternatively, convert the AAB on a desktop using bundletool.jar:
|
||||
java -jar bundletool-all.jar build-apks --bundle=app.aab --output=app.apks --mode=universal
|
||||
Then transfer resulting .apks/.apks.zip to the phone."""
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
package com.aab2apk.original
|
||||
package com.aab2apk.command
|
||||
|
||||
|
||||
import utils.Log
|
||||
import utils.SigningMode
|
||||
import utils.Utils
|
||||
import com.aab2apk.utils.Log
|
||||
import com.aab2apk.utils.SigningMode
|
||||
import com.aab2apk.utils.Utils
|
||||
|
||||
class CommandBuilder {
|
||||
private var bundletoolPath: String = ""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aab2apk.original
|
||||
package com.aab2apk.command
|
||||
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user