Cannot get the ZipResourceFile expansionfile working
<p>I have been on it for a week now, so I am desperate for help here.
I have imported the zip_file package to this sample project in Eclipse, but it doesn't want to work. The obb expansion file is on the test device in the correct folder. What am I doing wrong?</p>

<p>The log:    </p>

<pre><code>01-04 13:48:17.174: W/System.err(32744): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetFileDescriptor com.android.vending.expansion.zipfile.ZipResourceFile.getAssetFileDescriptor(java.lang.String)' on a null object reference
01-04 13:48:17.177: W/System.err(32744):    at com.imre.testzip2.MainActivity$1.onClick(MainActivity.java:97)
01-04 13:48:17.177: W/System.err(32744):    at android.view.View.performClick(View.java:4756)
01-04 13:48:17.178: W/System.err(32744):    at android.view.View$PerformClick.run(View.java:19749)
01-04 13:48:17.178: W/System.err(32744):    at android.os.Handler.handleCallback(Handler.java:739)
01-04 13:48:17.178: W/System.err(32744):    at android.os.Handler.dispatchMessage(Handler.java:95)
01-04 13:48:17.178: W/System.err(32744):    at android.os.Looper.loop(Looper.java:135)
01-04 13:48:17.178: W/System.err(32744):    at android.app.ActivityThread.main(ActivityThread.java:5221)
01-04 13:48:17.178: W/System.err(32744):    at java.lang.reflect.Method.invoke(Native Method)
01-04 13:48:17.178: W/System.err(32744):    at java.lang.reflect.Method.invoke(Method.java:372)
01-04 13:48:17.178: W/System.err(32744):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
01-04 13:48:17.178: W/System.err(32744):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)    
</code></pre>

<p>The java code:</p>

<pre><code>import java.io.IOException;
import com.android.vending.expansion.zipfile.APKExpansionSupport;
import com.android.vending.expansion.zipfile.ZipResourceFile;
import android.app.Activity;
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

public MediaPlayer wholeTextPlayer;
AssetFileDescriptor descriptor;
ZipResourceFile expansionFile;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    try {
        expansionFile = APKExpansionSupport.getAPKExpansionZipFile(getApplicationContext(),1,0);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    // The button clicks are like follows:      
    final Button btn_default_acc_hun_whole = (Button) findViewById(R.id.btn_default_acc_hun_whole);
    btn_default_acc_hun_whole.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            if (playerState == PlayerState_DefAcc) {
                try {

                descriptor = expansionFile.getAssetFileDescriptor("l1g_df_l2.mp3");
                wholeTextPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
                descriptor.close();
                wholeTextPlayer.prepare();
                wholeTextPlayer.start();
                setPlayerState(PlayerState_DefAccHun);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (playerState == PlayerState_DefAcc_Paused) {
                try {

                descriptor = expansionFile.getAssetFileDescriptor("l1g_df_l2.mp3");
                wholeTextPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
                descriptor.close();
                wholeTextPlayer.prepare();
                wholeTextPlayer.start();
                setPlayerState(PlayerState_DefAccHun);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (playerState == PlayerState_UsAcc) {
                try {

                descriptor = expansionFile.getAssetFileDescriptor("l1g_df_l2.mp3");
                wholeTextPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
                descriptor.close();
                wholeTextPlayer.prepare();
                wholeTextPlayer.start();
                setPlayerState(PlayerState_DefAccHun);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (playerState == PlayerState_UsAcc_Paused) {
                try {

                descriptor = expansionFile.getAssetFileDescriptor("l1g_df_l2.mp3");
                wholeTextPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
                descriptor.close();
                wholeTextPlayer.prepare();
                wholeTextPlayer.start();
                setPlayerState(PlayerState_DefAccHun);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (playerState == PlayerState_DefAccHun) {
                wholeTextPlayer.pause();
                setPlayerState(PlayerState_DefAccHun_Paused);
            } else if (playerState == PlayerState_DefAccHun_Paused) {
                wholeTextPlayer.start();
                setPlayerState(PlayerState_DefAccHun);

            } else {
                try {

                descriptor = expansionFile.getAssetFileDescriptor("l1g_df_l2.mp3");
                wholeTextPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
                descriptor.close();
                wholeTextPlayer.prepare();
                wholeTextPlayer.start();
                setPlayerState(PlayerState_DefAccHun);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });
}

    private final int PlayerState_DefAccHun = 1;
    private final int PlayerState_DefAccHun_Paused = 2;

    private final int PlayerState_DefAcc = 3;
    private final int PlayerState_DefAcc_Paused = 4;

    private final int PlayerState_UsAcc = 5;
    private final int PlayerState_UsAcc_Paused = 6;

    private int playerState;

    private void setPlayerState(int state) {
        playerState = state;
    }

    @Override
    public void onBackPressed() {
        if (wholeTextPlayer != null) {
            wholeTextPlayer.release();

        }
        finish();
        super.onBackPressed();
    }

}
</code></pre>

<p>I have only one main expansion file and no patch
Do I have to change anything in the zip_file package java classes?</p>