步骤来创建APK扩展文件 [英] Steps to create APK expansion file

查看:255
本文介绍了步骤来创建APK扩展文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发的应用程序和工作顺利。

I have developed Application and work successfully.

我已经使用的应用许可功能到我的应用程序。而现在我要上传到谷歌播放的应用程序。

I have used Application Licensing feature into my application. And now I'm going to upload an application on google play.

请让我知道的步骤,如何使用应用程序的许可,以及如何创建APK扩展文件?

Please let me know the steps, How to use Application licensing and how to create APK Expansion file?

推荐答案

扩展文件删除上传超过50MB的apk大小的限制。这个文件,你必须上传APK时附加。

Expansion files removes the restriction of uploading more than 50mb apk size. This files you have to attach when uploading apk.

有命名规则,你必须在创建扩展文件遵循

There are naming convention you have to follow while creating Expansion files

[主|补丁]<扩充版><包名称> .obb

请注意:

  1. - 都没有这个应用程序的文件将不会运行
  2. 补丁 - 是那些额外的文件,如果没有这个应用程序可以运行
  3. 扩展版本 - 你是给你的APK版本,所以不同的版本,扩展文件不会发生冲突
  4. 包名称 - 这是你唯一的包名称
  1. main- are those files without this your application will not going to run
  2. patch- are those files which are additional, without this your application can run
  3. expansion-version- version that you are giving to your apk, so that Expansion files of different version will not conflict
  4. package-name-This is your unique package name

.obb 我们没有追加,它会隐含附加由谷歌在上传

.obb we are not appending, it will implicitly appended by Google while uploading

假设你有你的当前目录中的所有内容,所以只要选择的所有内容,并使其成为一个名为ZIP main.2.com.xyz.abc.zip 和同时上传APK与它附加

suppose you have all the content in your current directory so just select all the content and make it a zip named main.2.com.xyz.abc.zip and attach it with while uploading apk

这所有上传的一部分,现在下载的部分。

This all uploading part, now downloading part

首先,你需要下载的谷歌额外的包的点击SDK管理器的

First of all you need to download Google extra package by clicking on SDK-Manager

现在从现有的源和进口的创建新项目market_​​licensing play_apk_expansion 从路径的 SDK路径/演员/谷歌

Now create new project from existing source and import market_licensing, play_apk_expansion from the path sdk-path/extras/google

记住:免费APP犯规要求需要进行许可证的可扩展的概念,你只需要不是到您的项目它会隐管理给予market_​​licensing参考打扰

Remember: Free app doesnt require Licensing but Expansion concept required, you just need not to bother by giving reference of market_licensing to your project it will implicitly manage.

play_apk_expansion 包含三个项目 downloader_library zip_file downloader_sample

play_apk_expansion contains three projects downloader_library, zip_file, downloader_sample.

downloader_library本身具有Market_​​licensing的参考。

downloader_library itself having the reference of Market_licensing.

现在你只需要集中精力 downloader_sample 第一包名称(测试)更改为包名称(包名称相同上传APK)

Now you just need to concentrate on downloader_sample first change the packagename(for testing) to your packagename(packagename same as uploaded apk)

非常重要 在 SampleDownloaderActivity 导航至...

Very Important In SampleDownloaderActivity navigate to...

private static final XAPKFile[] xAPKS = {
            new XAPKFile(
                    true, // true signifies a main file
                    2, // the version of the APK that the file was uploaded
                       // against
                    xxxxxxxxxxxL // the length of the zipfile in bytes right click on you expansion file and get the size in bytes, size must be same as zip size
            ),

    };

现在该活动将下载的扩展文件,并将其存储在 SD卡/安卓/ OBB / [主要|补丁]&LT;扩充版&GT;&LT;包名称&gt; .obb <。 / code>忽略OBB,随便找个地方解压缩这个文件,你想要的( SD卡/安卓/数据推荐的,因为它消除了,当你的应用程序中获取卸载)。

Now This activity will download the Expansion file and will store it in sdcard/Android/obb/[main|patch].<expansion-version>.<package-name>.obb ignore obb, just unzip this file anywhere you want (sdcard/Android/data recommended because it removes when your application get uninstalled).

有最新的设备,其下载扩展直接播放存储文件,并能保存 SD卡/安卓/ OBB / ,所以你必须非常小心地检查所有例

There are latest device which download Expansion files directly from Play store and it get stored in sdcard/Android/obb/ so you have to be very careful to check all the cases

  1. OBB已经下载
  2. 可用内存
  3. 在下载,但不能解压缩
  4. 内存选择(请参阅内存例)

记忆案例: 如果你采取任何新的设备或前。 Micromax的funbook,那么它有三个内存

Memory Cases: if you take any new device or for ex. micromax funbook, then its having three memory

  • /数据/数据​​/(手机内存)的 getFilesDirectory()
  • 的/ mnt / SD卡/(手机内部的SD卡)的 Environment.getExternalStorageDirectory()
  • 的/ mnt / extsd /(外置SD卡)的的/ mnt / extsd
  • /data/data/ (phone internal memory) getFilesDirectory()
  • /mnt/sdcard/ (phone's internal sdcard) Environment.getExternalStorageDirectory()
  • /mnt/extsd/ (External sdcard) /mnt/extsd

希望这会帮助你,并会满足您的要求。

Hope this will help you and will meet your requirements.

还有一件事用这个下面 ZipHelper 来解压缩的内容。

And one more thing use this below ZipHelper to unzipped the content.

ZipHelper.java

public class ZipHelper
{
    boolean zipError=false;

    public boolean isZipError() {
        return zipError;
    }

    public void setZipError(boolean zipError) {
        this.zipError = zipError;
    }

    public void unzip(String archive, File outputDir)
    {
        try {
            Log.d("control","ZipHelper.unzip() - File: " + archive);
            ZipFile zipfile = new ZipFile(archive);
            for (Enumeration e = zipfile.entries(); e.hasMoreElements(); ) {
                ZipEntry entry = (ZipEntry) e.nextElement();
                unzipEntry(zipfile, entry, outputDir);

            }
        }
        catch (Exception e) {
            Log.d("control","ZipHelper.unzip() - Error extracting file " + archive+": "+ e);
            setZipError(true);
        }
    }

    private void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir) throws IOException
    {
        if (entry.isDirectory()) {
            createDirectory(new File(outputDir, entry.getName()));
            return;
        }

        File outputFile = new File(outputDir, entry.getName());
        if (!outputFile.getParentFile().exists()){
            createDirectory(outputFile.getParentFile());
        }

        Log.d("control","ZipHelper.unzipEntry() - Extracting: " + entry);
        BufferedInputStream inputStream = new BufferedInputStream(zipfile.getInputStream(entry));
        BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));

        try {
            IOUtils.copy(inputStream, outputStream);
        }
        catch (Exception e) {
            Log.d("control","ZipHelper.unzipEntry() - Error: " + e);
            setZipError(true);
        }
        finally {
            outputStream.close();
            inputStream.close();
        }
    }

    private void createDirectory(File dir)
    {
        Log.d("control","ZipHelper.createDir() - Creating directory: "+dir.getName());
        if (!dir.exists()){
            if(!dir.mkdirs()) throw new RuntimeException("Can't create directory "+dir);
        }
        else Log.d("control","ZipHelper.createDir() - Exists directory: "+dir.getName());
    }
}

这篇关于步骤来创建APK扩展文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆