How to reduce the APPRTC library size? - android

In my app , I implemented APPRTC. Before implement the APPRTC my app size is 6MB. After implemented APPRTC My app size went 16 MB. i am using one to one Voice chat only. Can we have any other options to reduce the APP size or webrtc library size? Please suggest.. Thanks..
Note : "libjingle_peerconnection_so.so" liberary size is 10 MB.

You can Split APK using Gradle. Like,
// APK splitting
splits {
abi {
// Enable APK splitting wrt architecture
enable true
// Reset the architectures for which you need to build the APKs for
reset()
// Include the architectures for which Gradle is building APKs
include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
// Set this to false if you don't want an APK that has native code for all architectures
universalApk false
}
}
// Assign codes to each architecture
project.ext.versionCodes = ['x86': 0, 'x86_64': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3]
// Add the architecture-specific codes above to base version code, i.e. the version code specified in the defaultConfig{} block
// Example: 2000 is the base version code -> 2000 (x86), 2001 (x86_64), 2002 (armeabi-v7a) & 2003 (arm64-v8a) would be the version codes for the generated APK files
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.versionCodeOverride = project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1 + android.defaultConfig.versionCode
}
}
}

Related

react-native size doesn't shrink

Trying to make a smaller APK, currently the size is 21 MB. Hoping to reduce it to 10MB.
I do this inside android/app/build.gradle, but it doesn't reduce, I just want ARM support for now:
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "arm64-v8a"
}
}
Try this, I hope this will helps you.
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.
more information to https://medium.com/#aswinmohanme/how-i-reduced-the-size-of-my-react-native-app-by-86-27be72bba640

How to do ABI split on Gradle 3+ to change the version code?

As per the issue raised https://issuetracker.google.com/issues/64747519 and google documentation https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration#variant_api Variant API no longer works to change or alter the version code runtime.
So how can we create multiple apks and upload it to google play store?
Here's my code snippet
splits {
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86, armeabi-v7a, and mips.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
// Specifies that we want to also generate a universal APK that includes all ABIs.
universalApk true
}
}
// Map for the version code that gives each ABI a value.
def abiCodes = ['x86': 1, 'x86_64': 2, 'armeabi-v7a': 3, 'arm64-v8a': 4]
// APKs for the same app that all have the same version information.
android.applicationVariants.all { variant ->
// Assigns a different version code for each output APK.
variant.outputs.each {
output ->
def abiName = output.outputFile
output.versionCodeOverride = abiCodes.get(abiName, 0) * 100000 + variant.versionCode
}
}

barteksc/AndroidPdfViewer massive APK Size

We included this AndroidPdfViewer library to support viewing of PDF reports in the app. It lead to massive increase in APK size from 4.7Mb to 20.1Mb .
Is there a way to reduce this size. Let me know where and what to tinker around to help or solve this.
I am familiar with proguard and have it configure for my app with reasonable success.
Why resulting apk is so big?
As stated in the documentation by barteksc/AndroidPdfViewer
Android PdfViewer depends on PdfiumAndroid, which is set of native
libraries (almost 16 MB) for many architectures. Apk must contain all
this libraries to run on every device available on market.
Fortunately, Google Play allows us to upload multiple apks, e.g. one
per every architecture. There is good article on automatically
splitting your application into multiple apks, available here.
Most important section is Improving multiple APKs creation and
versionCode handling with APK Splits, but whole article is worth
reading. You only need to do this in your application, no need for
forking PdfiumAndroid or so.
API: https://github.com/barteksc/AndroidPdfViewer
You have to generate Multiple APKs for different devices, by doing this you can reduce the size of apk up to 10 MB less than previous. Add below code to build.gradle (Module:App)
android{
.....
splits {
abi {
enable true
reset()
include 'x86_64', 'x86', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips'
universalApk false
}
}
.....
}
ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, mips: 4, 'x86': 5, 'x86_64': 6]
import com.android.build.OutputFile
// For each APK output variant, override versionCode with a combination of
// ABI APK value * 1000 + defaultConfig.versionCode
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride =
project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) * 1000 + android.defaultConfig.versionCode
}
}
Whatch video here https://youtu.be/bP05Vpp49hs for detail explanation on how to do it.
If anyone is looking for a lightweight pdf viewer for your app, then try this one
Use this library
It helped me to reduce the app size from 27MB to 10MB because of the barteksc-androidpdfviewer requires more space
I also faced the same problem, but this is very easy as of now to reduce the apk sizes by using android app bundles.
Firstly in build.gradle(Module: app) add these lines inside android { } brackets.
bundle {
abi {
enableSplit = true
}
}
This will handle apk splits on the basis of architecture.
Now, also remember to add this line in proguard-rules.pro
-keep class com.shockwave.**
If you will not add this line in proguard-rules.pro then your app will crash in release version.
Now, after this go to Build and then select, Generate Signed Bundle/apk. From here, generate a signed bundle. Bundles are generated in very same way, as the apk's are generated.
Then, upload your bundle(.aab file) on Google Play Console and you will see that every device gets different apks depending upon their architecture.
This is the most easiest way to reduce the app size.Multiple apk concept is more complicated.
So,I suggest you to use this way.

Gradle dependency for specific architecture with ABI splits

Im facing this problem which seems im not able to solve. Here is scenario:
Im building apk which uses gradle dependency and this dependency is architecture specific so for apk for x86 i need different dependency and for arm different as well.
I solved it with product flavors:
productFlavors {
dev { ... }
develx86 { ... }
production { ... }
productionx86 { ... }
}
So then i defined dependency like this:
develCompile 'dependency_for_arm'
develx86Compile 'dependency_for_x86'
This works good. But recently i had to add to my application an usage of renderscript. I did it in this way:
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
And after this when i uploaded apk on Google Play it says it's apk is suitable with arm, x86. I don't know how this is possible. As you can think it will crash on device with different CPU (if i generated apk for arm and user will execute it on x86 app will crash).
So i decited to use ABI splits:
splits {
abi {
enable true
reset()
include 'armeabi', 'x86'
universalApk false
}
}
//Ensures architecture specific APKs have a higher version code
//(otherwise an x86 build would end up using the arm build, which x86 devices can run)
ext.versionCodes = [armeabi:0, x86:1]
import com.android.build.OutputFile
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
output.versionCodeOverride = android.defaultConfig.versionCode + abiVersionCode
}
But now when i see generated apk files, my dependency which is flavor-specific is not included into apk and apk will crash when i open section which uses API from this dependency.
Do someone know how to solve this issue? Or someone know why Google Play says that apk is for both architectures when i included renderscript? (Without it it works properly but i need renderscript).
Thank you for your time. I will appreciate any help.
If you look inside your APK, under lib folder, you should see that renderscript support mode added libs for other architectures than the one you're supporting.
You can keep your earlier configuration with ABI-specific flavors.
But in order to ensure that no libs for other architectures are included, try adding abiFilters to your flavors:
productFlavors {
dev { ... ndk.abiFilters 'armeabi-v7a' }
develx86 { ... ndk.abiFilters 'x86' }
production { ... ndk.abiFilters 'armeabi-v7a' }
productionx86 { ... ndk.abiFilters 'x86' }
}
Sorry I cannot comment inline yet.
What's in the apk, especially in res/raw/ and lib/?
Also, are you using gradle-plugin 2.1.0? (since you are using renderscriptTargetApi 22), have you tried Build-Tools 23.0.3?

Amazon app store Multiple APK Support like Android market?

Does Amazon app store support multiple APK uploading like Android market?
The Amazon Appstore does support multiple APKs for the one app. This is confirmed in the Amazon documentation. It is possible to upload multiple APKs for different platforms and capabilities including screen size and density, OpenGL compression format, architecture or API version.
Multiple APK support in the Amazon Appstore works the same as the multiple APK support in the Play Store, where the app android:versionCode must be unique for each uploaded APK.
You can use the gradle build script to automate the generation of unique versionCode for the multiple APKs. Here is an example that generates different APKs based on device architecture:
splits {
abi {
enable true
reset()
include 'x86', 'armeabi', 'armeabi-v7a'
universalApk true
}
}
project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.versionCodeOverride =
project.ext.versionCodes.get(output.getFilter(
com.android.build.OutputFile.ABI), 0) * 10000000 + android.defaultConfig.versionCode
}
}
You can visit developer.amazon.com. Create an account there and your are free to upload android apps. They also give you an option to choose when do you want the app to be available for the users. Unlike android market, the app will not be live immediately. It will undergo a review process and only after approval it will become live. You cannot edit the apk details once it is sent for review.
This feature is unsupported by Amazon Market
http://www.amazonappstoredev.com/2011/02/when-to-create-multiple-binaries-for-your-app.html

Categories

Resources