6.6.2 - Alpha - 修复 dx 库在 Android 7.x 无法正常使用的问题 (issue #293)

This commit is contained in:
SuperMonster003
2025-01-12 12:34:27 +08:00
parent 5da132ab0b
commit b713bbcf84
8 changed files with 26 additions and 23 deletions

View File

@@ -3,7 +3,8 @@
"v6.6.2": {
"released_date": "2025/01/03",
"fix": [
"notice 模块缺失 getBuilder 等扩展方法的问题 _[`issue #301`](http://issues.autojs6.com/301)_"
"notice 模块缺失 getBuilder 等扩展方法的问题 _[`issue #301`](http://issues.autojs6.com/301)_",
"dx 库在 Android 7.x 无法正常使用的问题 _[`issue #293`](http://issues.autojs6.com/293)_"
],
"improvement": [
"精简打包应用模板 APK 文件大小",

View File

@@ -149,6 +149,7 @@ dependencies /* Unclassified */ {
// Dex
implementation(files("$rootDir/libs/com.android.dx-1.14.jar"))
implementation(files("$rootDir/libs/com.legacy.android.dx-1.7.0.jar"))
// OpenCV
implementation(project(":libs:org.opencv-4.8.0"))
@@ -820,13 +821,6 @@ class Versions(filePath: String) {
private val javaVersionMinRadical: Int = properties["JAVA_VERSION_MIN_RADICAL"].let { it as String }.toInt()
private val javaVersionRaw = properties["JAVA_VERSION"] as String
private var javaVersionInfoSuffix = ""
private val javaVersionCeilMap = mapOf(
"idea" to mapOf(
"2023.2" to javaVersionMinSuggested, /* Aug 17, 2023. */
"2023.1" to javaVersionMinSuggested, /* Aug 17, 2023. */
"2022.3" to javaVersionMinSuggested, /* Aug 17, 2023. */
),
)
val javaVersion: JavaVersion by lazy {
var niceVersionInt = javaVersionRaw.toInt()

View File

@@ -1,7 +1,6 @@
package org.autojs.autojs
import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
@@ -29,7 +28,6 @@ import org.autojs.autojs.event.GlobalKeyObserver
import org.autojs.autojs.external.receiver.DynamicBroadcastReceivers
import org.autojs.autojs.leakcanary.LeakCanarySetup
import org.autojs.autojs.pluginclient.DevPluginService
import org.autojs.autojs.runtime.api.WrappedShizuku
import org.autojs.autojs.timing.TimedTaskManager
import org.autojs.autojs.timing.TimedTaskScheduler
import org.autojs.autojs.tool.CrashHandler
@@ -94,7 +92,7 @@ class App : MultiDexApplication() {
val crashHandler = CrashHandler(ErrorReportActivity::class.java)
val strategy = CrashReport.UserStrategy(applicationContext)
strategy.setCrashHandleCallback(crashHandler)
strategy.crashHandleCallback = crashHandler
CrashReport.initCrashReport(applicationContext, BUGLY_APP_ID, false, strategy)
@@ -239,7 +237,7 @@ class App : MultiDexApplication() {
get() = instance.get()!!
fun getProcessNameCompat(): String {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) Application.getProcessName() else {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) getProcessName() else {
try {
@SuppressLint("PrivateApi") val activityThread = Class.forName("android.app.ActivityThread")
@SuppressLint("DiscouragedPrivateApi") val method: Method = activityThread.getDeclaredMethod("currentProcessName")

View File

@@ -1,7 +1,9 @@
package org.autojs.autojs.rhino
import android.os.Build
import android.util.Log
import com.android.dx.command.dexer.Main
import com.legacy.android.dx.command.dexer.Main as LegacyMain
import dalvik.system.DexClassLoader
import net.lingala.zip4j.ZipFile
import net.lingala.zip4j.exception.ZipException
@@ -156,11 +158,19 @@ class AndroidClassLoader(private val parent: ClassLoader, private val cacheDir:
@Throws(IOException::class)
private fun dexJar(classFile: File, dexFile: File?): DexClassLoader {
val niceDexFile = dexFile ?: generateTempFile("dex-" + classFile.path, true)
Main.Arguments().apply {
fileNames = arrayOf(classFile.path)
outName = niceDexFile.path
jarOutput = true
Main.run(this)
when (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
true -> Main.Arguments().apply {
fileNames = arrayOf(classFile.path)
outName = niceDexFile.path
jarOutput = true
Main.run(this)
}
else -> LegacyMain.Arguments().apply {
fileNames = arrayOf(classFile.path)
outName = niceDexFile.path
jarOutput = true
LegacyMain.run(this)
}
}
val loader = loadDex(niceDexFile)
if (dexFile == null) /* is temporary file generated */ {

View File

@@ -883,7 +883,7 @@ object RhinoUtils {
override fun toString(): String = "function ${funcName ?: ""}() { ... }"
override fun getDefaultValue(typeHint: Class<*>?) = when (typeHint) {
org.mozilla.javascript.ScriptRuntime.StringClass -> toString()
RhinoScriptRuntime.StringClass -> toString()
else -> this
}

View File

@@ -60,12 +60,12 @@ class FinalSeg private constructor() {
values!![tokens[0][0]] = tokens[1].toDouble()
}
}
} catch (e: IOException) {
} catch (_: IOException) {
Log.error(String.format(Locale.getDefault(), "%s: load model failure!", PROB_EMIT))
} finally {
try {
`is`.close()
} catch (e: IOException) {
} catch (_: IOException) {
Log.error(String.format(Locale.getDefault(), "%s: close failure!", PROB_EMIT))
}
}

Binary file not shown.

View File

@@ -1,5 +1,5 @@
#Sat Jan 11 19:18:51 CST 2025
BUILD_TIME=1736594331756
#Sun Jan 12 12:30:28 CST 2025
BUILD_TIME=1736656228596
COMPILE_SDK_VERSION=34
JAVA_VERSION=23
JAVA_VERSION_MIN_RADICAL=0
@@ -17,6 +17,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
TARGET_SDK_VERSION=34
TARGET_SDK_VERSION_INRT=29
VERSION_BUILD=2960
VERSION_BUILD=2964
VERSION_NAME=6.6.2 Alpha
VSCODE_EXT_REQUIRED_VERSION=1.0.8