mirror of
https://github.com/izzy2lost/aab2apk.git
synced 2026-06-19 01:20:08 -07:00
Running in Windows Now but still facing problem when creating distributable.
This commit is contained in:
Generated
+1
-1
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="azul-18" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="azul-18" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -26,6 +26,7 @@ kotlin {
|
||||
}
|
||||
}
|
||||
val jvmTest by getting
|
||||
val resourcesDir = "src/common/resources"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
import java.io.File
|
||||
import java.net.URLDecoder
|
||||
|
||||
object Constant {
|
||||
const val SUCCESS = 0
|
||||
const val FAILURE = 1
|
||||
private const val bundleToolFileName = "bundletool-all-1.15.6.jar"
|
||||
|
||||
fun getCommand(): String {
|
||||
if(Utils.isWindowsOS()){
|
||||
val jarFileEncodedUrl = object {}.javaClass.classLoader.getResource(bundleToolFileName)
|
||||
val decodedJarPath = URLDecoder.decode(jarFileEncodedUrl.path, "UTF-8")
|
||||
val bundletool = File(decodedJarPath)
|
||||
return "java -jar \"${bundletool.absolutePath}\" build-apks --mode=universal --bundle=\"INPUT_FILE_PATH\" --output=\"OUTPUT_FILE_NAME.apks\""
|
||||
}
|
||||
return "bundletool build-apks --mode=universal --bundle=INPUT_FILE_PATH --output=OUTPUT_FILE_NAME.apks"
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
@@ -15,20 +14,20 @@ import kotlinx.coroutines.launch
|
||||
import theme.Styles
|
||||
import java.awt.FileDialog
|
||||
import java.awt.Frame
|
||||
import javax.swing.text.Style
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun App() {
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
var logs by remember { mutableStateOf("========== Logs View ==========\n\n") }
|
||||
var isLoading by remember { mutableStateOf(false) }
|
||||
var isOpen by remember { mutableStateOf(false) }
|
||||
if (isOpen) {
|
||||
FileDialog { fileName, directory ->
|
||||
isOpen = false
|
||||
//Get Command to Execute
|
||||
val cmd = Constant.getCommand().replace("INPUT_FILE_PATH", "${directory}$fileName")
|
||||
.replace("OUTPUT_FILE_NAME", "${directory}${fileName.split(".")[0]}")
|
||||
Log.i("Command $cmd")
|
||||
@@ -39,12 +38,20 @@ fun App() {
|
||||
val runtime = Runtime.getRuntime()
|
||||
val startTime = System.currentTimeMillis()
|
||||
try {
|
||||
//Launch Runtime to execute command
|
||||
val process = runtime.exec(cmd)
|
||||
// Read and log error output
|
||||
val errorReader = BufferedReader(InputStreamReader(process.errorStream))
|
||||
Log.i("Process Error Output:")
|
||||
while (errorReader.readLine().also { logs += "\n ERROR -> $it" } != null) {
|
||||
isLoading = false
|
||||
}
|
||||
process.waitFor()
|
||||
val endTime = System.currentTimeMillis()
|
||||
if (process.exitValue() == 0) {
|
||||
Log.i("Command Executed in ${((endTime - startTime) / 1000)}s")
|
||||
logs += "\nCommand Executed in ${((endTime - startTime) / 1000)}s\n"
|
||||
// Do further file operation after new apks is generated
|
||||
FileHelper.performFileOperations(directory, fileName) { status, message ->
|
||||
isLoading = false
|
||||
Log.i("STATUS - $status\nMESSAGE - $message")
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import androidx.compose.ui.text.toLowerCase
|
||||
import java.util.*
|
||||
|
||||
object Utils {
|
||||
|
||||
fun isWindowsOS(): Boolean{
|
||||
return System.getProperty("os.name").lowercase(Locale.getDefault()).contains("windows")
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user