can't read zipFile in android

I can run this code to get ZipFile Content below in ios.

unsigned long s;
const char* p = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(“Test.zip”);
unsigned char* zipData = CCFileUtils::sharedFileUtils()->getFileDataFromZip(p, “Test.txt”,&s);
CCLog(“getFileDataFromZip s size:d content:s ",p, s,zipData);
These out info.
getFileDataFromZip /var/mobile/Applications/XXXXX-XXX-XXX-XXX-XXXXXXX/XXXXXX.app/Test.zip size:3 content:123

But I use the same code in android
and put Test.zip into asset(No extra folder),
I can’t get any data.

And I try to use getFileDat to test,It’s fine. I can get correct size.
const char* zipData = CCFileUtils::sharedFileUtils()->getFileData(“Test.zip”,“rb”, &s);
CCLog("getFileData d”,s);

How to fix that getFileDataFromZip issue in android?
Thanks. Regards.

Hey Peter,

Can not put a zip file in Android assets. You can unzip you .apk, there will not contain “Test.zip”.

I unzip my apk, there contain “Test.zip” in assets folder.

Ok. My fault. Because it can not contain .gz file.

.apk is already a zip file. CCFileUtils::sharedFileUtils()->getFileDataFromZip(p, “Test.txt”,&s) will just read “Test.txt” from .apk. It will not read “Test.txt” from Text.zip.

So CCFileUtils::sharedFileUtils()->getFileDataFromZip function can’t read zip in apk
Only can read zip file from writablePath?

You do not want to put zip files in your APK.

Put the files into the assets or resources folder and let Android’s builder create the zip file for you.

Then access them with Cocos2d-x and copy them to writeablePath if you need to modify them.