My apk version code is version 3. with it I am using main expansion
file which was loaded with apk version code 1 (file name is similar to
main.1.ex.etc.eg.obb). The expansion file downloads fine on a device.

The expansion file has media file, so I using APEZProvider from the
Google Zip Expansion Library to play it with VideoView.

Calling VideoView.start() causes an Nullpointer exception.

What I have found so far: In APEZProvider.initIfNecessary() returns
Main expansion file version as 3 instead of 1. Thus trying to open
ZipResourceFile (mAPKExtensionFile) returns null.
APEZProvider.openAssetFile() causes null pinter exception as
mAPKExtensionFile is null.

Relevant code from APEZProvider class in Google Zip Expansion Library:


private boolean initIfNecessary() {
    if ( !mInit ) {
        Context ctx = getContext();
        PackageManager pm = ctx.getPackageManager();
        ProviderInfo pi = pm.resolveContentProvider(getAuthority(),
PackageManager.GET_META_DATA);
        PackageInfo packInfo;
        try {
            packInfo = pm.getPackageInfo(ctx.getPackageName(), 0);
        } catch (NameNotFoundException e1) {
            e1.printStackTrace();
            return false;
        }
        int patchFileVersion;
        int mainFileVersion;
        int appVersionCode = packInfo.versionCode;
        if ( null != pi.metaData ) {
            mainFileVersion = pi.metaData.getInt("mainVersion",
appVersionCode);
            patchFileVersion = pi.metaData.getInt("patchVersion",
appVersionCode);
        } else {
            mainFileVersion = patchFileVersion = appVersionCode;
        }
        try {
            mAPKExtensionFile =
APKExpansionSupport.getAPKExpansionZipFile(ctx, mainFileVersion,
patchFileVersion);
            return true;
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return false;
}


@Override
public AssetFileDescriptor openAssetFile(Uri uri, String mode)
        throws FileNotFoundException {
    initIfNecessary();
    String path = uri.getEncodedPath();
    if ( path.startsWith("/") ) {
        path = path.substring(1);
    }
    return mAPKExtensionFile.getAssetFileDescriptor(path);
}


I am not sure about this line of code in the above: ProviderInfo pi =
pm.resolveContentProvider(getAuthority(),
PackageManager.GET_META_DATA); Is this correct?

>From Android reference for PackageManager.resolveContentProvider().

public abstract ProviderInfo resolveContentProvider (String name, int
flags)

Since: API Level 1 Find a single content provider by its base path
name. Parameters

name The name of the provider to find. flags Additional option flags.
Currently should always be 0.

Can someone confirm if i am doing something wrong or is it a bug.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to