问题描述
我实现APK扩展成功和OBB文件的存储 - > Android-> Obb-> PackageName-> main.1.com.packagename.obb
但是,当我去解我得到的问题是没有一个Zip压缩文件。
子presourceFile ZRF =新的子presourceFile(文件名);
公共子presourceFile(字符串zipFileName)抛出IOException异常{
addPatchFile(zipFileName);
}
无效addPatchFile(字符串zipFileName)抛出IOException异常{
档案文件=新的文件(zipFileName);
RandomAccessFile的F =新RandomAccessFile的(文件,R);
长文件长度= f.length();
如果(文件长度< kEOCDLen){
抛出新的java.io.IOException异常();
}
长readAmount = kMaxEOCDSearch;
如果(readAmount>文件长度)
readAmount =文件长度;
/ *
*确认这是一个ZIP文件。
* /
f.seek(0);
INT标题= read4LE(F);
如果(标题== kEOCDSignature){
Log.i(LOG_TAG,发现Zip文件,但它看起来空);
抛出新IOException异常();
}否则,如果(头!= kLFHSignature){
Log.v(LOG_TAG,不是一个Zip压缩文件);
抛出新IOException异常();
}
我得到了2天后的解决方案
唯一的问题是 -
.obb文件是创建错误的方向
在OBB文件中创建步骤
- 所有资源存储在一个文件夹中。
-Zip这个文件夹
- 仅重命名.obb为.zip文件
快乐与此解决方案
I implemented apk expansion successfully and OBB file downloaded at Storage->Android->Obb->PackageName->main.1.com.packagename.obb
But when i go to extract i am getting issue is "Not a Zip archive".
ZipResourceFile zrf = new ZipResourceFile(fileName);
public ZipResourceFile(String zipFileName) throws IOException {
addPatchFile(zipFileName);
}
void addPatchFile(String zipFileName) throws IOException {
File file = new File(zipFileName);
RandomAccessFile f = new RandomAccessFile(file, "r");
long fileLength = f.length();
if (fileLength < kEOCDLen) {
throw new java.io.IOException();
}
long readAmount = kMaxEOCDSearch;
if (readAmount > fileLength)
readAmount = fileLength;
/*
* Make sure this is a Zip archive.
*/
f.seek(0);
int header = read4LE(f);
if (header == kEOCDSignature) {
Log.i(LOG_TAG, "Found Zip archive, but it looks empty");
throw new IOException();
} else if (header != kLFHSignature) {
Log.v(LOG_TAG, "Not a Zip archive");
throw new IOException();
}
I got the Solution after 2 days
only problem is that -
.obb file are create wrong direction
the obb file create step
-All Resources store in one folder.
-Zip this folder
-Only Rename .obb to .zip file
Happy with this solution
这篇关于OBB文件不提取错误是&QUOT; XAPK文件验证失败&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!