0%

Android 编译报错--空间超出

因为预置了完整的GMS包或者预置了大量的第三方apk,很容易在全编版本的时候出现”Out of space”错误,下面我们来分析一下错误信息以及该如何解决。

下面是一个典型的system空间超出log:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--------- block_list not set !!! ------------   
Using map file out/target/product/b3679/obj/PACKAGING/systemimage_intermediates/system.map
Running: mkuserimg.sh -s out/target/product/b3679/system out/target/product/b3679/obj/PACKAGING/systemimage_intermediates/system.img ext4 system 3645243392 -D out/target/product/b3679/system -B out/target/product/b3679/obj/PACKAGING/systemimage_intermediates/system.map -L system out/target/product/b3679/root/file_contexts
make_ext4fs -s -T -1 -S out/target/product/b3679/root/file_contexts -B out/target/product/b3679/obj/PACKAGING/systemimage_intermediates/system.map -L system -l 3645243392 -a system out/target/product/b3679/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/b3679/system out/target/product/b3679/system
error: ext4_allocate_best_fit_partial: failed to allocate 15607 blocks, out of space?
Creating filesystem with parameters:
Size: 3645243392
Block size: 4096
Blocks per group: 32768
Inodes per group: 7952
Inode size: 256
Journal blocks: 13905
Label: system
Blocks: 889952
Block groups: 28
Reserved block group size: 223
Out of space? the tree size of out/target/product/b3679/system is (MB):
3456 out/target/product/b3679/system
The max is 3504 MB.
make: *** [out/target/product/b3679/obj/PACKAGING/systemimage_intermediates/system.img] Error 1

#### make failed to build some targets (01:26:48 (hh:mm:ss)) ####

error: ext4_allocate_best_fit_partial: failed to allocate 15607 blocks, out of space? 可以知道报错原因是申请15607个块失败,
Block size: 4096 可以知道每个块的大小是4096字节,
那么通过简单的乘法就可以算出空间超出多少: 15607 × 4096 = 63926272 (Byte) = 62428(KB) ≈ 61(MB)

常用的省空间方法

  1. 某些不可卸载应用不提取odex,比如GmsCore、Maps、Velvet等,不过这种方法会影响第一次开机时间;
  2. 直接删除某些apk,比如客户预置的;
  3. 看开关机动画是否占用过大,有的客户开关机动画可能会有1、200M,可以找UI同事帮忙处理一下图片;
  4. 驱动是否兼容了多余的屏、摄像头;

调整空间大小的方法:

修改分区配置表,不同项目分区配置表路径可能有差异,MT6737 6.0项目参考路径如下:
device/mediatek/build/build/tools/ptgen/MT6737M/partition_table_MT6737M.xls
注意:修改分区配置表会影响Fota升级,如果项目已经量产,还请和Fota提供商确认修改分区表是否能正确升级