简体   繁体   中英

Unity android apk is too large

In the past few months I've been working on a 2D platform game , that i'd soon like to publish on the Google Play Store .

In the past 2 days, after a few changes, the apk file size increased from around 70MB , to over 130MB . I've been thinking about the most recent changes that i did to the app, that might have caused this problem: I imported TextMeshPro in the project and used it on a few UI pages in the game, added a few small assets and created a new scene .

Another thing that looks wrong to me, is that the whole Asset folder's size is slightly less than 60MB . All the assets that I've manually added are there.

Yesterday I've spent a few hours searching and trying to fix this problem ineffectively. For example by looking in the editor log , the files that are really big: for some reason, there were a few 15Mb .png files (when they were only about 300KB ). I decreased their resolution and compressed them, and looking again in the editor log they had indeed decreased their size, while the apk, still, did not change much (maybe around 200KB, because the asset files were 300KB before, and only 100KB after).

In conclusion, I have absolutely no idea about why the apk size is so big, and in any way, I really must bring it back to 60-70MB to upload it on google play store (being under 100MB).

Any information or help is really appreciated, thank you!

Edit: here is a good part of the build report:

Unloading 309 Unused Serialized files (Serialized files now loaded: 0)
System memory in use before: 92.7 MB.
System memory in use after: 90.0 MB.

Unloading 337 unused Assets to reduce memory usage. Loaded Objects now: 2153.
Total: 384.610600 ms (FindLiveObjects: 0.507000 ms CreateObjectMapping: 0.051800 ms MarkObjects: 382.389300 ms  DeleteObjects: 1.661500 ms)

DisplayProgressNotification: Build Successful
Unloading 1 Unused Serialized files (Serialized files now loaded: 0)
Loaded scene 'Temp/__Backupscenes/0.backup'
    Deserialize:            3.940 ms
    Integration:            333.324 ms
    Integration of assets:  0.050 ms
    Thread Wait Time:       14.688 ms
    Total Operation Time:   352.001 ms
System memory in use before: 196.9 MB.
System memory in use after: 197.0 MB.

Build Report
Uncompressed usage by category (Percentages based on user generated assets only):
Textures               952.7 mb  98.1% 
Meshes                 0.0 kb    0.0% 
Animations             0.0 kb    0.0% 
Sounds                 0.0 kb    0.0% 
Shaders                685.8 kb  0.1% 
Other Assets           2.0 mb    0.2% 
Levels                 929.5 kb  0.1% 
Scripts                930.6 kb  0.1% 
Included DLLs          13.3 mb   1.4% 
File headers           339.3 kb  0.0% 
Total User Assets      970.8 mb  100.0% 
Complete build size    2.0 gb
Used Assets and files from the Resources folder, sorted by uncompressed size:
 13.4 mb     0.6% Assets/Graphics/Level 11/ground11.png
 13.4 mb     0.6% Assets/Graphics/Level 3/Lava2.png
 13.0 mb     0.6% Assets/Graphics/Level 12/Trampoline4.png
 12.9 mb     0.6% Assets/Graphics/Level 4/Lava6.png
 12.5 mb     0.6% Assets/Graphics/Level 4/Lava1.png
 12.3 mb     0.6% Assets/Graphics/Level 12/Ground15.png
 11.4 mb     0.5% Assets/Graphics/Backgrounds/Lev19.png
 11.0 mb     0.5% Assets/Graphics/Level 3/Lava5.png
 10.9 mb     0.5% Assets/Graphics/Level 4/Ground13.png
 10.7 mb     0.5% Assets/Graphics/Level 4/Ground12.png
 10.7 mb     0.5% Assets/Graphics/Level 2/Ground1.png
 10.7 mb     0.5% Assets/Graphics/Level 4/Ground6.png
 10.7 mb     0.5% Assets/Graphics/Level 4/Ground8.png

Etc.

Few tips to reduce build size on Unity 3d

  1. Target project to NetStandard 2.0 rather than .Net 4.x only if project does NOT take a dependency on something like NetCore.App.

Unity supports two .NET API compatibility levels.: .NET 4.x and .NET Standard 2.0. The .NET Standard 2.0 restricts you to a smaller subset of the .NET API, which can help keep size down.

  1. Compress Meshes and imported Animation Clips so that they take up less space in your game file.

To enable Mesh compression, select the Mesh, then in the Inspector window set the Mesh Compression to Low, Medium or High.

  1. Compress Textures

To do this without modifying the actual source content, select the Texture in the Project view, and in the Inspector window reduce the Max Size. To see how this looks in-game, zoom in on a GameObject that uses the Texture, then adjust the Max Size until it starts looking worse in the Scene view .

  1. Experimentally build against arm v7 architecture only, not x86 + armv7 as fewer devices are on x86

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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