Reputation: 301
I made a flutter application about 2 years ago. Although I bring functional updates to the application from time to time, I haven't updated Flutter for about a year because updating Flutter also requires updates such as Gradle, SDK and Kotlin files. Since I bought a new computer, I needed to install the latest Flutter version(null safety) before latest version my old app is not null safety and I also updated the Gradle, SDK and Kotlin files to the latest version. However, when I want to build, the size of my old application is 38mb, while the size of my current application is 80mb. What is the reason for this? Why has there been such a big increase?
I had built my old 38mb file as a flutter build appbundle
bundle file, now I wrote the same code and got the output, but it is 80mb.
To be sure, I reverted 70% of the dependencies I updated to the old version, but there was no difference in size, I flutter build appbundle
built it as 80mb again, so the problem is not in the updated dependencies. It's either caused by Flutter, Gradle, Kotlin or Sdk, but I couldn't find out which one or why.
My old versions;
Flutter 3.7.3
Gradle 7.2.0
Kotlin 1.9.0
environment: sdk: ">=2.7.0 <3.0.0"
Current versions;
Flutter 3.22.1
Gradle 8.4.0
Kotlin 1.9.23
environment: sdk: ">=3.3.4 <4.0.0"
Upvotes: 0
Views: 781
Reputation: 301
If you are using minSdkVersion 23
or higher and if your application size increased after increasing the minSdkVersion
, your issue is completely different, you can look for the solution here compressed native libraries. An easily solved problem with adding code to the build.gradle
file. In my case my problem is not increasing app size when I increase my minSdkVersion
from below 23 to 23 or higher. Because my minSdkVersion
is currently 21 so I had to solve my problem with different way.
First of all, instead of getting normal output from my app with flutter build apk --release
, I took the output with this code to analyze my apk file flutter build apk --analyze-size --target-platform android-arm64
I opened the resulting json file in devtools and looked at which variables were added compared to my old apk file. And in the librive_text.so
file, I saw that a file took up 48 MB in total, with 12 MB for each file type such as x64, x86. When I searched for this file, I realized that this file came with the Rive library. Among my dependencies, the awesome_dialog: ^3.2.1
package started using the Rive package after version 3.0.0, which took up extra space in my application.
When I researched, I saw articles saying that normally the Rive package should not take up so much space, As I continued to research the problem, I learned that the size of the Rive package decreased when the ndkVersion
was set to "25.1.8937393"
. When I used the latest ndkVersion
, the size of the Rive package in the build increased. Since reducing the ndkVersion
is not a healthy solution and I could not find another solution, I had to remove the package. Instead I am using the quickalert: ^1.1.0
package now.
Upvotes: 0