解决工程型代码打包的 apk 安装后无法运行的问题。 #264
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在 vscode 或在 app 中创建的工程,在 app 打包后运行直接闪退。但是 app 里创建的单文件打包后就能正常运行。用 logcat 抓闪退 apk 的日志发现闪退原因是缺少对应的 .so 文件。
扒拉了一下源码,发现这里应该是打包时拷贝 .so 文件的逻辑。
AutoJs6/app/src/main/java/org/autojs/autojs/apkbuilder/ApkBuilder.kt
Lines 366 to 377 in c2f0980
然后顺着上面的函数一路找到了 AppConfig 的创建逻辑。
AutoJs6/app/src/main/java/org/autojs/autojs/ui/project/BuildActivity.java
Lines 424 to 471 in c2f0980
这里 425 行有个 if 语句,个人猜测是这里的判断导致工程型的代码和文件型的代码走了不同的 AppConfig 创建逻辑。也就是说因为工程型的代码的创建逻辑缺了参数导致打包时没有复制 .so 文件。解决了这个问题后我本地运行就没有问题了。