I've an android application and i use admob.
Do i need to include the entire languange pack located to google-play-services_lib/res/values-COUNTRYCODE.xml?
I tried to remove them and apk file resulted much smaller.
My app is currently served only in my country.
Use resConfig "en" build configuration inside your app's build.gradle file.
This will instruct gradle to remove all other languages other than english. This immensely helps in reducing the size of the apk by upto 20-40% in some cases.
Related
I faced the task of reducing the size of .apk file of my android app. My apk size is more then 100MB now and tentatively it will grow. So I consider android app bundle as a temporary solution. .so libraries take the most space in apk and I'd like to take them off to expansion files if it is possible. Does anybody have such experience, and what can you advice to learn to solve this problem?
Reduce the size of your app by moving '.so' files to over-the-air. Follow this link
But this violates the Google Policy
You should:
Remove unused resources(image, layout, lib/dependency)
Turn on shirk resource on build.gradle
Moving something to OTA
Build the App bundle instead of APK
I'm facing a little "problem" affecting my APK files built in Android Studio (but the same problem affects my APKs even if I build them from command prompt).
The problem is this: if I rename .apk to .zip to see the files inside, or even if I analyze the .apk with the analyzer tool included in AS, I see in the "res" directory a lot of png files that I didn't include and I don't even use in my application.
I guess that they're standard icons used in Android, but I would like to exclude them from my built apk file.
Those file names are like "abc_ic_restofthefilenamehere.png"
(example: "abc_ic_star_half_black_16dp.png")
I would like to know if there's a way to exclude those file because I don't use them in my activities (my application is very simple, it doesn't even need icons for notifications or other kinds of similar things).
Is it possible to exclude them? Is there a way to do it if I build from the command prompt too (using gradle)?
Thank you very much!
-
Check out the documentation about how to Shrink your resources. This should remove any unused resources in your app.
Note however that some images will seem unused but are actually dependencies (possibly indirect) of a theme you may be depending on, so that's why those would remain.
I have seen that there are decompilers that works pretty well to show on fly code and resources of compiled APK.
I'm wondering if there is a way to edit and rebuild APK classes without export all sources and resources recreating a new project manually adding all libraries resources code etc. Since the APK already contains all the needed dependencies and resources configured to work together should be possible.
Often there are apps that have small bugs that would be easy to fix if only was possible edit and rebuild APK on fly
You can use Virtuous Ten Studio that allows you to import an APK edit smali code and resources and rebuild the edited version of the APK.
(You can also configure it to show Java code but since uses a "smali to Java" approach the generated code is imperfect.)
https://ibotpeaches.github.io/Apktool/
You can use Apktools to extract and compress APK-files
It is possible to manage/edit Smali files. They are similar to Java-files.
All the drawable and raw files have 900kbs all together in my application, but the entire size of the application is comming ouut to be 5.5 Mbs. I am working in eclipse and google play services library along with appcompact_v7 library are attached.
How can i shrink the size of my exported apk file. Because my application is way too simple to have 5.5 Mbs.
Thankyou in advance.
Use Android ProGuard tool. The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer.
First, consider switching to Android Studio and using a subset of Google Play Services, for whatever part you are using. The documentation has a "Selectively compiling APIs into your executable" section that covers this.
Second, if you are examining the size of your debug build, bear in mind that release builds use ProGuard to get rid of extraneous Java code, and so your releae APK will be a bit smaller.
Beyond that, Cyril Mottier has a great blog post on "Putting Your APKs on a Diet". However, some of the more powerful techniques, such as eliminating resources from Play Services via resConfigs, require Android Studio.
There are some techniques you could achieve this:
Proguard - to remove unused classes from your final apk
"lint --check UnusedResources " - detect resources that your app has and are not being used
Use helper jar: https://code.google.com/p/android-unused-resources/
You can read this Android official doc for more info : http://tools.android.com/tech-docs/new-build-system/resource-shrinking .
I am trying to publish an app that is currently only configured for English. When I upload my app to the Play store, it says localization for 'Default + 49 languages'? How do I disable all but English?
I've just noticed the same issue and after some investigation found the explanation. Thought I share this in addition to the already existing answer about the consequences:
As soon as your app includes a library that does support additional languages (e.g. the Google Play Services), your created apk is marked to support all those localizations as well!
You can check the properties of an apk by the way even without uploading it to the Google Play Store. Just run the following from the latest build-tools folder inside your Android Apk. For me this is at the moment cd ~ANDROID_HOME/build-tools/19.0.1
./aapt d badging <apk>
As it was suggested before, it is mostly important in which languages your app description is provided cause this is what the users actually see. In addition one can include the list of real supported languages in this description.
If you really would want to get rid of the additional languages you would need to delete the language specific res-folders from all libraries. In case of local copies of the libraries this is easy. I guess using gradle and maven it should be possible as well, but I don't consider it worth doing at the moment.
When you publish your app, if you wrote it only in English it will be published only in English.
If you want to limit your app to specific countries you can do this: On the developer console you have a tab of "PRICING AND DISTRIBUTION". You can choose the countries there. Here how it looks:
As others have pointed out, the issue is that if you include a library that supports other languages, all of those translations get pulled into your app and then the store assumes that you support those languages.
To stop the build tools from pulling in the unsupported languages, you can set filters on the 'aapt' packaging tool so that it will ignore particular files/directories.
The formatting for the filter can be found in the main ant 'build.xml' file in the sdk. (search for aapt.ignore.assets)
The default exclude list is:
!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~
I'd recommend that you keep this list and append any extra filter to the end of it.
e.g. If you wanted to exclude es-US (which is stored in directories with the extension -es-rUS) you would change the exclude list to:
!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:<dir>*-es-rUS
This will exclude all directories ending in -es-rUS (note that the filters are case-insensitive, so <dir>*-eS-RuS would work just as well)
To do this for the command line:
aapt.exe <All of your normal commands for packaging> --ignore-assets <exclude-list>
For Ant/Eclipse builds add the following to your project's ant.properties file:
aapt.ignore.assets=<exclude-list>