如何使用Android Studio来让Android扩充档案? [英] How to make Android Expansion File using Android Studio?

查看:847
本文介绍了如何使用Android Studio来让Android扩充档案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要上传 .apk文件,但我的 .apk文件 50MB超过上限。

I need to upload an .apk but my .apk exceeds 50mb limit.

我读到这对文档和一些问题,但我有困难,使这个工作的。

I read about this on documentation and some questions but I'm having difficult to make this works.

有没有人有一些教程,解释如何做到这一点(使用Android工作室),如果有某种方式使用gradle这个做到这一点。

Does anyone have some tutorial that explain how to do this (using Android Studio) and if there is some way to use gradle to do this.

推荐答案

我这样做的几个项目,但我从来没有想出了一个简单的方法。在

I've done this on a few projects, but I never figured out a simple way. The instructions at

<一个href=\"http://developer.android.com/google/play/expansion-files.html\">http://developer.android.com/google/play/expansion-files.html

帮我把我周围的基础头,但我发现这个过程的一部分(如Android的更新项目)没有与摇篮正常工作。

helped me get my head around the basics, but I found parts of the process (like "android update project") didn't work properly with Gradle.

下面的说明将帮助您设置项目,所需的库。之后,你可以回去了官方的文档,并找出与你刚刚包含的东西做的。

The instructions below will help you set up your project with the required libraries. After that you can go back to the official docs and figure out what to do with all the stuff you just included.

这些权限添加到AndroidManifest.xml中

Add these permissions to AndroidManifest.xml

<uses-permission android:name="com.android.vending.CHECK_LICENSE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

添加播放服务依赖性的build.gradle

Add Play Services dependency to build.gradle

dependencies {

    compile 'com.google.android.gms:play-services:4.0.30'
}

开放式的SDK管理器并安装的谷歌播放APK扩展库谷歌Play许可库

复制Java源文件文件夹:

Copy java source files from these folders into your project's source/main/java folder:

YOUR-ANDROID-SDK-FOLDER\extras\google\play_apk_expansion\zip_file\src

YOUR-ANDROID-SDK-FOLDER\extras\google\play_apk_expansion\downloader_library\src

YOUR-ANDROID-SDK-FOLDER\extras\google\play_licensing\library\src

打开

YOUR-ANDROID-SDK-FOLDER\extras\google\play_apk_expansion\downloader_library\res

复制绘制,华电国际 绘制-MDPI 布局到项目的源/主/ RES 文件夹

有关在值的所有文件文件夹,合并文件内容到项目的配套文件。

For all files in the values folders, merge content from the file into the matching file in your project.

创建延伸类的 android.content.BroadcastReceiver

添加像这样到你的清单:

Add something like this to your manifest:

<receiver android:name="mypackage.MyReceiver"/>

创建延伸类的 com.google.android.vending.expansion.downloader.impl.DownloaderService

添加像这样到你的清单:

Add something like this to your manifest:

<service android:name="mypackage.MyDownloaderService"/>

编译该项目并寻找有关错误

Compile the project and look for errors relating to

import com.android.vending.expansion.downloader.R;

导入自己的项目资源,而不是在这里。

Import your own project resources here instead.

这篇关于如何使用Android Studio来让Android扩充档案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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