简体   繁体   English

如何安装资产文件夹大小> 1GB而apk最大大小= 50 MB的Android应用程序?

[英]How to install android application whose assets folder size >1GB while apk max size=50 MB?

My assets Folder contain a sub-folder whose size >1 GB 我的资产文件夹包含一个子文件夹,其大小> 1 GB

I cannot install my application on ZTE device whose sd Card size =8 GB 我无法在SD卡大小为8 GB的中兴设备上安装我的应用程序

I add write/read permission to my manifest file and also preferExternal installation 我向清单文件添加了write/read permission ,并且还preferExternal installation

After some search in related question I see that maximum apk size is 50 MB 在相关问题中进行一些搜索后,我看到最大apk大小为50 MB

So I should reduce my application ressource file 所以我应该减少我的应用程序资源文件

and I read that I can install my application without ressource and then donwnolad them in the 我读到我可以在没有资源的情况下安装我的应用程序,然后在

first use 初次使用

Any one can explain more this idea or suggest another idea 任何人都可以解释这个想法或提出另一个想法

I don't know if it is possible that I use big text files in android application 我不知道我是否有可能在android应用程序中使用大文本文件

Correct, APKs have a maximum file-size of 50MB. 正确,APK的最大文件大小为50MB。 To extend your app beyond the 50MB limit you can use one or two expansion files, each file being max 2GB. 要将您的应用扩展到50MB以上的限制,您可以使用一个或两个扩展文件,每个文件最大2GB。 Refer to the official documentation for details regarding this. 有关此细节, 请参考官方文档

I would also ask myself if all of these assets are needed to use the application. 我也要问自己,使用应用程序是否需要所有这些资产。 The app would have to be pretty damn good/provide a lot of value before I'd download 1GB of data. 在下载1GB数据之前,该应用必须非常好/必须提供很多价值。 Perhaps you could server up chunks of data from a server and download to external storage? 也许您可以从服务器中存储大量数据,然后下载到外部存储中?

If you need the data for developing purposes; 如果您需要数据用于开发目的; you can load the data on the external sd card of your test android device(ie the device you'r testing the app on). 您可以将数据加载到测试android设备(即要在其上测试应用的设备)的外部SD卡上。 You can acess these files through code: 您可以通过以下代码访问这些文件:

File root = android.os.Environment.getExternalStorageDirectory();
File dir = new File (root.getAbsolutePath() + "/assets"+...);

root will now hold the root directory of the sd card; root现在将保存sd卡的根目录; dir will get you the Directory to whatever files you'd want to access. dir会将您带到您要访问的任何文件的目录。 You can read/write these files using standard java File and FileReader Objects. 您可以使用标准java File和FileReader对象读取/写入这些文件。 This should work for development purposes. 这应该用于开发目的。 And yeah; 是的 dont forget to add the required permission in your manifest file: 不要忘记在清单文件中添加所需的权限:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

However; 然而; frankly it won't be a good idea to ask the user of an app to download one gigabyte worth of data for your app to run. 坦白说,要求应用程序的用户下载一千兆字节的数据以供您的应用程序运行不是一个好主意。 Instead it will be better to host these files on an external server and access them indirectly from android through the internet; 相反,最好将这些文件托管在外部服务器上,然后通过互联网从android间接访问它们; every time the app runs. 每次应用运行时。 There are a few ways to do this. 有几种方法可以做到这一点。 If its simple text stored in databases, you can use php to send it as JSON encoded strings; 如果其简单文本存储在数据库中,则可以使用php将其作为JSON编码的字符串发送; but since its >1GB of data i'm assuming it's probably images/videos and not plain text. 但由于其> 1GB的数据,我假设它可能是图像/视频而不是纯文本。 Here is a simple tutorial that helps you to download an image from a URL: http://www.androidhive.info/2012/07/android-loading-image-from-url-http/ You can try looking into this further 这是一个简单的教程,可以帮助您从URL下载图像: http : //www.androidhive.info/2012/07/android-loading-image-from-url-http/您可以尝试进一步研究

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM