-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
插件targetSdkVersion版本过高问题 #582
Comments
由于这个是android系统packageManager自己解析的问题,无法处理,因此只能添加提示
} |
我没法复现这个问题。麻烦fork一下,如果能复现,把修改push上来看看。 按照你说的情况,应该是打包的apk中的 我把所有版本都改到30,也会有 <?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
android:compileSdkVersion="30"
android:compileSdkVersionCodename="11"
package="com.tencent.shadow.sample.manager"
platformBuildVersionCode="30"
platformBuildVersionName="11">
<uses-sdk
android:minSdkVersion="30"
android:targetSdkVersion="30" />
<application
android:extractNativeLibs="false" />
</manifest> 要么至少是空的tag: <?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="local"
android:compileSdkVersion="30"
android:compileSdkVersionCodename="11"
package="com.tencent.shadow.sample.host"
platformBuildVersionCode="30"
platformBuildVersionName="11">
<uses-sdk
android:minSdkVersion="30"
android:targetSdkVersion="30" />
<application />
</manifest> |
@shifujun 我这边使用的是idea2020.1编译android工程,如果自己不在androidManifest里面手动添加application节点的话,编译后的apk不会存在application节点 |
我这边写了一个demo,2个pluginmanager.apk ,唯一的区别就是targetSdkVersion不同,一个是30,一个是28,androidManifest里面都不存在application节点,但是28的可以解析,30的无法解析,demo我发下吧 |
你这个app-debug.zip的源码push上来看看吧。打包apk的行为应该主要还是受AGP的版本影响。AGP可能会参考targetSDK改变逻辑。 |
@shifujun 应该不需要吧,你可以直接用PackageManager解析assets里面的2个pluginmanager.apk、pluginmanager28.apk就可以看到pm无法解析第一个apk文件 |
你有无法解析的apk文件这个我信,不用测。但是这不解决问题呀,得找出来它为什么会产生。 |
@shifujun 我看了下,插件的targestSdkVersion版本如果是android11的话,PMS解析包会调用到 |
我大概清楚了。通过枚举测试不同版本的AGP,我确定这个问题应该是AGP已经修复的Bug。3.6.0以及更早的版本有不生成 因此我觉得这个问题Shadow不用特别兼容。对于适用低于4.0.0的项目,如果遇到此问题,建议主动写一个 |
@shifujun 但是对于targetSdkVersion<30,不存在application节点还是可以解析的,所以理论上我觉得这个问题产生的根本原因还是PackageManager的问题吧 |
估计是AGP的开发和PackageManager的开发在这个细节上早先没有对齐吧。PackageManager和AGP对我们来说都是黑盒的API,从一个API获取到的apk作为输入给另一个API,有问题也只能是这个黑盒自己的bug。所以到底是PackageManager的bug还是AGP的bug,对我们来说不重要。 |
在系统版本低于30的手机上面不存在application节点的apk都可以解析,不受插件apk的targetSdkVersion影响 |
一个targetSdkVersion>=30的app,使用低于4.0.0的AGP构建,恐怕有点不太匹配了吧。 |
避免4.0.0以下版本生成没有<application />的apk,在targetSdkVersion>=30时,在API 30以上的手机上Crash。 Tencent#582
避免4.0.0以下版本生成没有<application />的apk,在targetSdkVersion>=30时,在API 30以上的手机上Crash。 #582
当插件的androidManifest.xml只存在manifest节点的情况,打包成插件apk之后manifest里面只有manifest和use-sdk的情况,目前我就测试了targetSdkVersion为28和30的情况:
当插件的targetSdkVersion为28的时候,packageManager.getPackageArchiveInfo可以获取到PackageInfo;
当插件的targetSdkVersion为30的时候,获取不到PackageInfo信息,在androidManifest文件添加application节点后打包可以获取到PackageInfo
由于shadow的pluginmanager.apk也使用了packageManager.getPackageArchiveInfo,导致无法初始化
测试设备小米11
android11
miui 12.5.9
The text was updated successfully, but these errors were encountered: