即时通过使用大尺寸的声音文件构建应用程序.所以我的apk文件比100Mb限制大得多的问题,我需要使用APK扩展文件.我试着在互联网上搜索如何处理这个问题,但一无所获.也许你们中的一些人已经面临这个问题,现在如何解决它.
谢谢.
android apk-expansion-files react-native react-native-android
由于我需要减小APK文件的大小,我已经按照Apk扩展指南将APK分成块.
该下载库定义的方式来下载expansion file
,但我需要知道的排除方法resource files
,并aar
从APK文件.
我发现以下,但这些既不删除resource-drawable files
任何arr
文件,也不删除任何文件,并且apk的大小保持不变.
出于测试目的,我添加drawables
了大约4 MB
几个arr
文件3 MB
.我是apk
从Build->Build APK
选项创建的.我不知道以下是否会影响已签名的APK.
sourceSets {
main {
resources {
exclude '**/drawable/*'
}
}
}
android {
packagingOptions {
exclude 'lib/armeabi/a.so'
}
}
Run Code Online (Sandbox Code Playgroud) 所以我复制了Android的扩展包示例,并根据谷歌提供的指南运行.我已成功通过存储本地.obb文件使其工作,但我无法让它与下载.obb文件一起工作.状态已更改为IDownloaderClient.STATE_COMPLETED
但未找到任何文件.
我经历过的步骤:
BASE64_PUBLIC_KEY
,new package name
,version number
)请帮助获取下载的扩展文件.
编辑:在第4步,我现在得到下载失败,因为无法找到资源.
编辑2:所以在调试之后,我看到状态变为无需下载,但无法验证文件,因为它丢失了.因此,出于某种原因,它认为该文件已被下载.
编辑3:所以在DownloaderService.class中我们有一个run()方法,它使得getExpansionURLCount()
返回0.文档说:this will return zero if there has been no LVL fetch in the current session
.经过多次挖掘后,我发现我从Google获得processServerResponse()
的响应中包含响应代码256并且没有密钥FILE_URL
.那么原因是什么?
由于缺乏内部存储器,我的许多用户都无法从Play商店安装我的应用程序.应用程序的大小是:APK 37MB +扩展1,3 GB.
我知道很多用户不希望在系统内存中有如此大的数据,并且实现了许可和下载 - 库的示例,并且将扩展文件直接下载的代码更改为物理SD卡.但用户只能从选项菜单运行我的下载过程中的应用.
.
问题:
谷歌在此声明:
"......如果Google Play无法下载扩展文件,则只下载APK."
但这似乎是错误的.许多用户抱怨安装问题和"挂起/挂起"下载.他们说,当他们从市场上安装App,谷歌播放尝试下载摆在首位的OBB-扩展文件,(是什么使事情变得更糟)到内部存储器.因此用户无法启动应用程序并使用我的下载实现.
由于我想利用谷歌授权机制的安全功能,我有以下想法:
有人可以证实这可行吗?
有没有办法让Google Play直接将大型扩展下载到外部存储器?也许如果我修改了Manifest:
android:installLocation="auto"
Run Code Online (Sandbox Code Playgroud)
任何想法都很感激!
我尝试使用APK Expansion libs zip_file和downloader_library(需要play_licensing).zip_file工作正常,因为它没有依赖项,但是当我尝试Gradle同步时,play_licensing会引发错误.
Android Studio吐出此错误日志:
Information:Gradle tasks [:app:generateGoogleDebugSources, :app:libs:downloader_library:generateDebugSources, :app:libs:play_licensing:generateDebugSources, :app:libs:zip_file:generateDebugSources]
Information:/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicenseResultListener.aidl:21 interface ILicenseResultListener should be declared in a file called com/android/vending/licensing/ILicenseResultListener.aidl.
Information:2 errors
Information:0 warnings
Information:See complete output in console
/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl
Error:(19) couldn't find import for class com.android.vending.licensing.ILicenseResultListener
Error:(19) Execution failed for task ':app:libs:play_licensing:compileReleaseAidl'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/faiz/Projects/Android/android-sdk-macosx/build-tools/19.0.3/aidl -p/Users/faiz/Projects/Android/android-sdk-macosx/platforms/android-19/framework.aidl -o/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/build/source/aidl/release -I/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl -I/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/src/release/aidl -d/var/folders/y6/g0d5m3f94rxdvq5myp53d9k80000gn/T/aidl662748145109587430.d /Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl
Error Code:
1
Output:
/Users/faiz/Projects/Android/TogetherTime/app/libs/play_licensing/aidl/ILicensingService.aidl:19: couldn't find import for class com.android.vending.licensing.ILicenseResultListener
Run Code Online (Sandbox Code Playgroud)
我没有修改任何库,但由于它们不是为Gradle构建的,我从另一个项目复制了build.gradle并相应地修改它们.
downloader_library /的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies …
Run Code Online (Sandbox Code Playgroud) 我遇到了另一个与APK Expansion文件(.obb文件)有关的奇怪问题.我的扩展文件在我的所有测试设备上都正常安装:
我用jobb -utilite 创建了加密的.obb文件:
jobb -o obb-filename -d files -dir -k password -pn applicationId -pv versionCode
在我的应用程序中,我使用以下代码读取.obb文件:
public void initialize(final Context context) {
final StorageManager storageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
final File mainObbFile = getMainObbFile();
final OnObbStateChangeListener listener = new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
if (state == OnObbStateChangeListener.MOUNTED) {
// work with obb file …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用mountExpansion()
此问题中找到的方法安装我使用JOBB工具创建的加密或非加密的obb文件:在Android中安装加密的obb apk扩展文件.有趣的是,当我尝试使用加密文件时,我得到状态21,根据https://developer.android.com/reference/android/os/storage/OnObbStateChangeListener.html表示
系统无法安装OBB.从通过StorageManager进行的调用返回状态消息
当我尝试一个非加密文件时,我得到状态20,这意味着:
尝试安装OBB时遇到内部系统错误.从通过StorageManager进行的调用返回状态消息
这些解释都没有对可能导致各州发生的事情有所帮助.有什么建议吗?
我对类似问题的回答中的评论也可能是相关的:https://stackoverflow.com/a/37957811/1489990作为我能够以jobb开始创建obb文件的唯一方法是强制FAT32用来代替FAT16.
我尝试以这种方式挂载扩展文件:
final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
String obbPath = Environment.getExternalStorageDirectory() + "/Android/obb";
final String obbFilePath = obbPath + "/com.example/main.1.com.example.obb";
storageManager.mountObb(obbFilePath, "SecretKey", new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
if (state == OnObbStateChangeListener.MOUNTED) {
onObbMounted();
} else {
Log.d("##", "Path: " + path + "; state: " + state);
}
}
});
Run Code Online (Sandbox Code Playgroud)
但是在运行时我得到状态21:ERROR_COULD_NOT_MOUNT:
Path: /storage/sdcard0/Android/obb/com.example/main.1.com.example.obb; state: 21
Run Code Online (Sandbox Code Playgroud)
我添加了这个:
File f = new File(obbFilePath);
if (!f.exists()) {
Log.e("OBB", "FILE NOT FOUND!!!");
}
Run Code Online (Sandbox Code Playgroud)
而logcat说该文件存在.我不知道,为什么我能得到这个状态21?
我可以使用主扩展文件作为应用程序中的可选下载选项吗?所以我不需要用 APK 文件下载它,但稍后用户会这样做。
APK 大小已达到105 MB
,我需要创建APK Expansion Files
.
我正在关注用于创建扩展文件的Android 文档。
我已经下载Google Play APK Expansion Library
和Google Play Licencing Library
。
现在我需要将这些库添加到我的应用程序中。
我遵循了文档。它指出以下
现在的问题是,在步骤-5:当我添加路径遵循Library Repository
它运行了一段时间摇篮构建,然后什么也不做,当我重新打开Project structure
有什么的Library Repository field
。
C:\Users\DELL\AppData\Local\Android\Sdk\extras\google\market_licensing\library
我无法理解如何将此项目导入我的应用程序。另一种方法是单独复制每个文件并将其添加到库模块中,但我不想尝试这种方法。
项目结构: