Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • APK Expansion File

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 489
    Comment on it

    Google play currently has a restriction that we can not upload an APK greater than 50 Mb. This is the plenty space for most of the application but for some application this space is not sufficient. So Google play gives you a facility to attach additional file that will be downloaded from play store at the time downloading an application. To make this process easier for you and more pleasant for users, Google Play allows you to attach two large expansion files that supplement your APK. Google Play hosts the expansion files for your application and serves them to the device at no cost to you. The expansion files are saved to the device's shared storage location (the SD card or USB-mountable partition; also known as the "external" storage) where your app can access them.

    There are two type of expansion file:

    1. The main expansion file is the primary expansion file for additional resources required by your application.
    2. The patch expansion file is optional and intended for small updates to the main expansion file.

    Expansion file name format:-
    [main|patch]...obb (expansion file you upload can be any format you choose (ZIP, PDF, MP4, etc.))

    -> [main|patch] determines whether the file is main or patch
    -> determines the current version of application
    -> determines the package name of the application
    For example, suppose your APK version is 3 and your package name is com.example.android. If you upload a main expansion file, the file is renamed to: main.3.com.example.android.obb

      Rules and limitations
    1. Each expansion file should not be more than 2GB.
    2. The user must acquire his application from Google Play, if he want to download his expansion from it. Besides, if the application is installed from other sources then Google Play will not render the URL for your expansion files.
    3. The download when performed within the application, the URL provided by Google Play is unique for each and every file and download and everything expires in a short span after its given to the application.
    4. Either you upload various APKs for your application or update the application using a new APK, you can choose the expansion file which you had uploaded for a former APK. The name of expansion file does not change- it hold the version which was received by the APK, to which the file was associated originally.
    5. If expansion files are been used in combination with number of APKs to provide various expansion files for different devices. Further, if you want to declare dissimilar filters and to provide different versionCode value for APK, then you must upload separate APKs for every device.
    6. To update your app it is necessary to upload a new APK, as one cannot update and issue the application by just changing expansion files. In your expansion file if the changes are related to the assets, you can simply update your APK just by changing the versionCode (and may be also the version Name).
    7. One should not save data into your obb/ directory. Save the data into the location specified by getExternalFilesDir(), if you want to unpack any data.
    8. Unless an update has not been performed by your end, one should not delete or rename the .obb expansion file. It might cause Google Play (or your app itself) to download the expansion file recurrently.
    9. When updating an expansion file manually, you must delete the previous expansion file.

    Note: When you download the apk from play store the expansion file are downloaded along with the apk.
    After downloading of apk you can check the expansion file here:- Android/obb//expansion_file

    Once you downloaded the apk you can read the expansion file content and use them in your application.
    A simple method of reading the expansion file:- // The shared path to all app expansion files

    private final static String EXP_PATH = "/Android/obb/";
    
    static String[] getAPKExpansionFiles(Context ctx, int mainVersion,
          int patchVersion) {
        String packageName = ctx.getPackageName();
        Vector ret = new Vector();
        if (Environment.getExternalStorageState()
              .equals(Environment.MEDIA_MOUNTED)) {
            // Build the full path to the app's expansion files
            File root = Environment.getExternalStorageDirectory();
            File expPath = new File(root.toString() + EXP_PATH + packageName);
    
            // Check that expansion file path exists
            if (expPath.exists()) {
                if ( mainVersion > 0 ) {
                    String strMainPath = expPath + File.separator + "main." +
                            mainVersion + "." + packageName + ".obb";
                    File main = new File(strMainPath);
                    if ( main.isFile() ) {
                            ret.add(strMainPath);
                    }
                }
                if ( patchVersion > 0 ) {
                    String strPatchPath = expPath + File.separator + "patch." +
                            mainVersion + "." + packageName + ".obb";
                    File main = new File(strPatchPath);
                    if ( main.isFile() ) {
                            ret.add(strPatchPath);
                    }
                }
            }
        }
        String[] retArray = new String[ret.size()];
        ret.toArray(retArray);
        return retArray;
    }

    References

    http://developer.android.com/google/play/expansion-files.html

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: