I have a 20MB database stored in the apk's assets, which on first run is extracted for use. To do this I use
PackageManager pm = context.getPackageManager();
String apkFile = pm.getApplicationInfo(context.getPackageName(), 0).sourceDir;
ZipFile zipFile = new ZipFile(apkFile);
ZipEntry entry = zipFile.getEntry("assets/FILENAME");
myInput = zipFile.getInputStream(entry);
myOutput = new FileOutputStream(file);
byte[] buffer = new byte[1024*4];
int length;
int total = 0;
int counter = 1;
while ((length = myInput.read(buffer)) > 0) {
total += length;
counter++;
if (counter % 32 == 0) {
publishProgress(total);
}
myOutput.write(buffer, 0, length);
}
All works fine when I export from eclipse (android 2.2 target) without using proguard. When I export with proguard, the unzip starts to work for a few seconds (and a few progress updates, to 8%), but then crashes with java.io.IOException at java.util.zip.InflaterInputStream.read(.. )
It works on the emulator, but crashes on devices (many devices, but I think always works in Android 4, crashes in Android 2.2). My proguard.cfg is basically the default one. Nothing I have tried changing seems to help, any ideas?