我的apk版本代码是版本3.使用它我使用的主扩展文件加载了apk版本代码1(文件名类似于main.1.ex.etc.eg.obb).扩展文件在设备上下载正常.
扩展文件有媒体文件,因此我使用APEZProviderGoogle Zip扩展库来播放它VideoView.
调用VideoView.start()会导致Nullpointer异常.
到目前为止我发现的内容:APEZProvider.initIfNecessary()返回主扩展文件版本为3而不是1.因此,尝试打开ZipResourceFile(mAPKExtensionFile)返回null.APEZProvider.openAssetFile()原因NullPointerException为mAPKExtensionFile是null.
APEZProviderGoogle Zip扩展库中类的相关代码:
private boolean initIfNecessary() {
if ( !mInit ) {
Context ctx = getContext();
PackageManager pm = ctx.getPackageManager();
ProviderInfo pi = pm.resolveContentProvider(getAuthority(), PackageManager.GET_META_DATA);
PackageInfo packInfo;
try {
packInfo = pm.getPackageInfo(ctx.getPackageName(), 0);
} catch (NameNotFoundException e1) {
e1.printStackTrace();
return false;
}
int patchFileVersion;
int mainFileVersion;
int appVersionCode = packInfo.versionCode;
if ( null != pi.metaData ) {
mainFileVersion = pi.metaData.getInt("mainVersion", appVersionCode);
patchFileVersion = pi.metaData.getInt("patchVersion", appVersionCode);
} else {
mainFileVersion = patchFileVersion = appVersionCode;
}
try {
mAPKExtensionFile = APKExpansionSupport.getAPKExpansionZipFile(ctx, mainFileVersion, patchFileVersion);
return true;
} catch (IOException e) {
e.printStackTrace();
}
}
return false;
}
@Override
public AssetFileDescriptor openAssetFile(Uri uri, String mode)
throws FileNotFoundException {
initIfNecessary();
String path = uri.getEncodedPath();
if ( path.startsWith("/") ) {
path = path.substring(1);
}
return mAPKExtensionFile.getAssetFileDescriptor(path);
}
Run Code Online (Sandbox Code Playgroud)
我不确定上面这行代码:ProviderInfo pi = pm.resolveContentProvider(getAuthority(), PackageManager.GET_META_DATA);这是正确的吗?
来自PackageManager.resolveContentProvider()的Android参考.
public abstract ProviderInfo resolveContentProvider(String name,int flags)
从以下版本开始:API级别1按基本路径名查找单个内容提供程序.参数
name:要查找的提供程序的名称.
flags:附加选项标志.目前应始终为0.
有人可以确认我做错了什么或者它是一个错误.
编辑:当我第一次上传我的应用程序时,一切都按预期工作 - 它只有当我更新apk导致出现此问题的不同版本代码时.
dag*_*pin 14
如果APK扩展文件的版本号与APK的版本号不匹配,则Zip文件提供程序类包含可放置在AndroidManifest.zip文件中的元数据.
<provider android:name=".APEZProvider"
android:authorities="my.application.authority"
android:exported="false"
android:multiprocess="true"
>
<meta-data android:name="mainVersion"
android:value="1"></meta-data>
<meta-data android:name="patchVersion"
android:value="2"></meta-data>
</provider>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6471 次 |
| 最近记录: |