Search code examples
javaandroidfilezipandroid-2.3-gingerbread

Android 2.3 ZIP problems with general purpose flags


I made an application on Android and this application logs the activity into files. I have an option to export the files so I save the files in a .zip. If there is more than 1 file to add to the .zip, I get the following error.

(general purpose flags - local: 808 hex central: 8 hex). Local and central GPFlags values don't match.

This only happens with Android 2.3 and using winzip or 7zip. I can bypass this problem using windows explorer or winrar but I would like to solve the problem and not avoid it.

It does not happen using the same application on an Android 2.2 device.

I searched around around and found some comments about encrypting but I am not encrypting anything. I also found some comments on updating certain libraries and such but I'm using Android sdk 11 and java jdk 1.6.0_25.

I tried 2 different codes with the same result

int count = log_.getLogFileList(files_);
if (count > 0)
{                       
String inFileName;
File inFile;
String phoneNumLast =OsmoService.getAccountString(OsmoService.context).substring(6);
long date = files_.get(count - 1).lastModified();
SimpleDateFormat formatter = new SimpleDateFormat("MMddHHmmss");                     
String outdt = new String(formatter.format(new Date(date)));
String outFileName = new String("Dir Name" + "//" + "PREFIX" + "_" + outdt + ZIP_SUFFIX);

File outFile = new File(outFileName);                   
ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( outFile ) );
BufferedOutputStream outBS = new BufferedOutputStream(zos, 8192 );

for (int idx = (count - 1); (idx >= 0) && !isCancelled(); idx--)
{
inFile = files_.get(idx);  
BufferedReader inBR = new BufferedReader(new FileReader(inFile), 8192);                     
inFileName = inFile.getName();
Log.v(LOG_TAG, "MailLogFiles - Zipping " + inFileName);

zos.putNextEntry( new ZipEntry(inFileName));
int zix;
while ( (zix = inBR.read()) != -1 )
outBS.write(zix);
outBS.flush();       
zos.closeEntry();    
inBR.close();
}
outBS.close();

and this

public static void compressFileList( String[] inFiles, String outFile )
throws IOException
{
ZipOutputStream zos = new ZipOutputStream(
new BufferedOutputStream( new FileOutputStream( outFile ) ));
byte data[] = new byte[2048];

  for (int i = 0; i < inFiles.length; i++)
  {
     BufferedInputStream in = new BufferedInputStream( new FileInputStream( inFiles[i] ) );
     zos.putNextEntry( new ZipEntry(inFiles[i]) );
     int count;
     while( ( count = in.read( data, 0, data.length ) ) != -1 )
        zos.write(data, 0, count);
     zos.closeEntry();
     in.close();
  }
  zos.close();
}

Solution

  • I think this is caused by a reported bug that will be fixed in Ice Cream Sandwich: http://code.google.com/p/android/issues/detail?id=20214