I am making a simple video call app by using Jitsi Android SDK after completion when i build my signed APK its size is too big i.e, 101 MB when i check that apk it shows the type .nox apk.
Another problem is when i tried to install that 101MB apk into Mobile it says App Not Installed
for this i checked mobile settings Unknown Sources after that it stick to the same message (App not installed).
this is my App's build.gradle(app) file
Here is my Proguard Rule also and target SDK
and this is the extention of APk file
here is my analyze apk result
How to build reduced Apk which run easily...Please Help me into this i don't know where i am going wrong ??
The main reason for your app to be that big is because of all the native libraries which you have in your project. I guess they are included by Jitsi Android SDK.
I guess you are not creating App Bundle but building directly an apk via Android Studio, that's why all versions of native libraries are included in the same apk.
By using App Bundle format to build your app you should lower a lot your app's size, because it will create apk files only for the specific configurations, so every architecture will have it's own apk with included native libraries for only that architecture.
Once you have the App Bundle file you can create your apk's in order to install to a device using bundletool. With a command like this:
bundletool build-apks --bundle=/PathToMyABB/app-bundle.aab --output=/PathToMyAPKS/my-apks.apks
You can retrieve apk as bundle and convert your images to webp format you are going to save %50 memory area.
First of All You Need to Tinify the Resource images Tinyfy, I suggest you to use this link to tinify your image assets.
The Second thing after the above Step, Convert all Image Assets to Webp Format, in order to convert to webp you need to right click on image asset and then at the Bottom of option there will be optionj convert to webp.
Remove Unnecessary classes and libraries to Reduce the Size.
Apply Proguard Rules to Reduce Size
In Order to remove delete x86_64 you just need to do is, just add this under Android Tag in app level gradle File
splits {
abi {
enable true
reset()
include 'armeabi-v7a'
universalApk false
}
}
Related
Background info
When uploading an app to the play store that uses a native library its necessary to also upload the native debug symbols to get useful crash/ANR info.
If you upload without symbols you receive the following warning: "This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug."
In the past when uploading apps as .apk files it was necessary to manually upload such debug info. Now using .aab if the native library is built via android studio its possible to set android.defaultConfig.ndk.debugSymbolLevel = 'FULL' at which point when you build a the .aab it will include the debug info automatically, you upload this single file and everything is done/working.
pre-built libraries
However its not always possible/ideal/necessary to build a library inside android studio. Sometimes there are reasons for libraries to be externally pre-built and just used by android studio not built by it; Android studio supports this via a directory structure which is described here https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs
In short you just copy the libraries into the correct src/main/jniLibs/{ABI} path(s) and it is picked up and made part of the bundle.
Problem
Android studio can build a .aab that contains debug info that play store can understand so that you don't need to upload it manually.
Android studio can use pre built native libraries if you place them in the right path structure
I am unable to find any documentation or way to do both of these things together, use native pre-built libraries but include their debug info in the .aab. Even though logically it should be possible to do this.
I have searched everywhere I think but can't find anyone even talking about this really, how/where do you place the corresponding debug information so that that also can be included as part of the .aab? Is there a separate path for this, do they just need a specific file extension, does gradle need to be told what to do with them somehow?
Is it really just not possible?
Things I have tried:
Don't split the debug info just leave them in the .so files - play store does not strip them then so you deliver giant debug versions of your builds to your users
Split the debug info into files with .so.dbg extension and place them alongside the .so files - they aren't included in the .aab
Following the instructions (here https://support.google.com/googleplay/android-developer/answer/9848633 and elsewhere) to manually zip and upload the symbols after uploading the .aab - this appears to work but isn't the same convenience wise as having them in the .aab
I've tried building a sample app with android studio building a lib instead of using a pre-built lib just to verify that it does then include the debug info and what file extension it uses.
After some more digging I found the task responsible for this is "ExtractNativeDebugMetadataTask" with which some effort can likely be tailored/altered to do custom things here.
However this ended up being unnecessary as while digging into this I discovered that it actually already works.
At least as of now in latest gradle versions (not sure about the past).
It was only failing due to some NDK path confusion which doesn't fail the build/creation of the bundle building but just logs an easy to miss informational message.
Ultimately all you need to do to make this work is:
Build your external .so files with -g -g3 or similar
Do not strip them in any way
Place them in jniLibs directory structure un-stripped
Configure your build.gradle appropriately android{ ndk { debugSymbolLevel 'FULL' } ndkPath "$projectDir/path/to/NDK" }
Resulting .aab will contain the stripped .so files and the split-debug .so.dbg files all in the right location.
I make my app using flutter and my app size is more than 100 mb and app has 15 screens.
It's android size is more than 100 mb and iOS app size is 40 mb I have to make it small
and I want proper solution for this
I try to compress my image files but it just decrease 8 mb
I want proper solution for compress flutter app size.
Check this below steps it may help you to reduce app size (only Android), i have reduced my 48mb build to 14mb
Step 1: android/gradle.properties
android.enableR8=true
Step 2: android/app/build.gradle
inside -> buildTypes -> release
minifyEnabled true
shrinkResources true
useProguard true
Step 3:
Run
flutter build apk --target-platform=android-arm
or
flutter build apk --split-per-abi
Some other optimizing tips,
1. Image assets
Upload the images in permanent storage path like AWS or in your website server and use the link to that image in your code.
2. Icons
Its recommended to use from Material Icons or Cupertino Icons class. You can add --tree-shake-icons option to flutter build command, to remove all of the not used icons from the bundle. This will potentially save the size of your app. (use svg format icons)
3. Fonts
If we are using more fonts from local assets similar like images these fonts will also increase app size. The best solution is to use google_fonts plugin. This pluign will dynamically download font when it is used.
4. Dynamic App Delivery
We could build an app bundle if we are uploading to playstore or we could split the apk per abi which splits the apk to x64 and x86 bit code. By using appbundle Google Play’s new app serving model, called Dynamic Delivery, uses your app bundle to generate and serve optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app.
Refer below links for more understanding,
https://developer.android.com/studio/build/shrink-code
https://developer.android.com/guide/app-bundle
https://www.youtube.com/watch?v=9D63S4ZRBls
How many third-party packages are you using?
Did you use drag and drop to create the app or code everything manually?
Did you properly use const in objects that are repeated but are essentially the same? Like const EdgeInsets.all(8.0).
Do you have a lot of gradient images that you can convert to Container gradients?
Use webp images instead of PNG or JPEG
Add pro-guard files
Minify Enabled - true
Shrink- Resource -true
try running:
flutter clean
and then:
flutter build apk --split-per-abi
you could even further reduce the size of your code by doing:
flutter build apk --split-debug-info=/<project-name>/<directory>
and if you're willing to take the risk, you can obfuscate your code:
flutter build apk --obfuscate --split-debug-info=/<project-name>/<directory>
where
/<'project-name'>/<'directory'>
is the directory where Flutter can output your app debug files.
I'm building an APK (not app bundle) using Gradle via Android Studio.
Without adding any Mozilla dependencies in my app's build.gradle file the APK size is under 5MB but after adding these dependencies the APK size increases to over 100MB.
Most of the APK size is in the (new) lib directory, particularly the lib/libxul.so file, but also the assets/omni.ja file is around 9MB.
I am aware of how to reduce the APK size by using ABI filters and APK splitting to generate separate APKs for different architectures, but this can only do so much to reduce the download size for the user. Is there any way I can significantly reduce the size of my APK? Are there any command line options I can add or additional Gradle options to achieve this?
For reference, I am importing the following dependencies: https://github.com/mozilla-mobile/android-components
from here: https://maven.mozilla.org/maven2
The official recommendation is here: https://developer.android.com/studio/build/shrink-code.
And you can also use Play feature delivery to serve some features only when needed by users: https://developer.android.com/guide/app-bundle/play-feature-delivery
I am working on react native project , but whenever i am building an Apk file , it give me Apk of 47MB.
I tried every documentation which i found useful on google but nothing works for me, Is there any way to reduce my App size below 10MB as the app only contain three or four pages. Any help would be appreciated
You can try following steps
Open up android/app/build.gradle
Set def enableProguardInReleaseBuilds = true this would enable Progaurd to compress the Java Bytecode. This reduces the app size by a tad bit
Set def enableSeparateBuildPerCPUArchitecture = true . Android devices support two major device artitectures armebi and x86. By default RN builds the native librariers for both these artitectures into the same apk.
Setting the last function creates two distinct apk in the build folder. You have to upload both of this apk to Play Store and Google would take care of distributing the app to the correct architectures.
Using this split generates version numbers for both apks in the order of 104856 and such. This is auto-generated by the build to avoid version conflicts, so don’t freak out (I did).
This split reduced the apk size from around 7MB to 3.5MB for arm and 5MB for x86 respectively.
You can find more information in this article https://medium.com/#aswinmohanme/how-i-reduced-the-size-of-my-react-native-app-by-86-27be72bba640
Seem like android app bundle can help you. But i will also answer the question how to reduce Android APK size in react-native
there are many ways to optimize app install size of a mobile app build with react-native.
a react-native app size depend on:
total Js code imported in your app (included in node_modules)
total Native code use in your app.
Total assets (images/ videos/ media ...)
variant of devices your app supported
To reduce / optimize your app size, you have to optimize 4 things above
First, js code
We write JS code, react components then update, replace by new others. By times, js code base growth. and become mess & smelling, useless but hard to remove from code base. It make your app size growth by still imported in your code base but never to be use.
-> Check, refactors your JS code after 1 / 2 phase of features development to make your code beauty & lean.
Second, Native code
Native side seem like a mystery cave with JS react-native developers and beginners. In native libraries have a ton of Java / Objective-C codes which hard to reach by developer. Some of their un-controlled or not necessary.
Abuse native libraries can soaring your app size and make some weird crashes
-> Don't use native libraries if you don't need it or you can do it by js code.
-> use Proguard to thin your app size by shrink code and remove unused codes. My apps reduced 15% - 20% app size after configured proguard.
Learn more about proguard here
Third, Assets
Assets like images, sounds or video are usually have high weight. To optimize assets you can use some tips below:
use webp format images
do not abuse png, gif format if jpg is enough
Optimize image files size using some tools like tinypng.com It's pretty good and fast
use vector icons. Like react-native-vector-icons
Do not included high weight assets in bundle, you can processing download and setup they when first times users open app.
Last, config variant of devices your app supported
If your app target some specify devices, os versions. You can limit it, remove unsupported architectures. It's can reduced 2% -> 10% base on what you removed.
Use Android app bundle, it's recommended by Google. if your app sold in Play Store. It will separate your bundle file into many installable apk files base on device types. So your app only included assets / code necessary for only this device type. Amazing, right?
Learn more about Android App Bundle here
one of my apps if build for type APK is 40MB.
When build type AAB is 40 MB. But install file from Goole play store only 13 -> 17 MB depend on device types.
Switch on these options
def enableProguardInReleaseBuilds = true
def enableSeparateBuildPerCPUArchitecture = true
Find alternatives for large-sized modules
Use cost-of-modules (npm package that will list the size of packages in your peoject) ... and try to find an alternative for costy-packages
Build .apk to .aab file and then deploy .aab file to google play console.
please read about app bundle concept in devloper site.
https://developer.android.com/guide/app-bundle
You can build .abb (Android App Bundle) file instead of .apk. This reduce your app size almost 3x time smaller.
You cannot do much about it . by using def enableProguardInReleaseBuilds = true can compress the app a bit . Use .aab bundle instead of apk format and uplaod it to Play store google play will compress the app further .If you are using play store and bundling your app in .aab format you need to do separate apk by enablingdef enableSeparateBuildPerCPUArchitecture = true
For more Info https://developer.android.com/studio/build/configure-apk-splits
Open up android/app/build.gradle and edit the following code as shown.
***lATEST method ***
def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: true).toBoolean()
Remove unwanted Codes and unused Packages.
inside the app/build.gradle
Set values into true
def enableProguardInReleaseBuilds = true
def enableSeparateBuildPerCPUArchitecture = true
And
buildTypes {
release {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
use this command to build
gradlew bundleRelease
I Build an APK using Android studio and its bigger than I expected. I attached a APK analyze report and it shows lib download file size is 56.6 MB. can anyone suggest a way how can i reduce that lib size.
PS: And can someone explain me what is this lib means? becouse i did't use any libs other than dependency. and as i know those dependency included in classes.dex
Thanks.
Screen shot of the APK analyze :
Since you have the dependency of vlc-android-sdk library which contains large native library (libvlc.so) and is included in the app, your apk size is large.
You can use splits or product flavors for different CPU architectures to include only necessary so files. Or you should use a different library.