Android源码中如何添加apk文件(源码预安装apk)

来源:互联网 发布:日上防盗门怎么样 知乎 编辑:程序博客网 时间:2024/04/29 04:58

只有一个apk文件,如何添加到Andorid源码中,开机之后这个apk已经安装好。

1.device/amlogic/f20ref/f20ref.mk中copy file到system/app目录下。

[html] view plaincopyprint?
  1. PRODUCT_COPY_FILES += \  
  2.   device/amlogic/f20ref/hello.apk:system/app/hello.apk  
[html] view plain copy
 print?
  1. PRODUCT_COPY_FILES += \  
  2.   device/amlogic/f20ref/hello.apk:system/app/hello.apk  


2. make 源代码。

[java] view plaincopyprint?
  1. *** Prebuilt apk found in PRODUCT_COPY_FILES: device/amlogic/f16ref/hello.apk:/system/app/hello.apk, use BUILD_PREBUILT instead!.  Stop.  
[java] view plain copy
 print?
  1. *** Prebuilt apk found in PRODUCT_COPY_FILES: device/amlogic/f16ref/hello.apk:/system/app/hello.apk, use BUILD_PREBUILT instead!.  Stop.  



原因是build/core/Makefile中对copy file作了检测,如果是apk文件,会出错。

解决办法:注释掉build/core/Makefile文件中检测apk代码

[cpp] view plaincopyprint?
  1. #define check-product-copy-files  
  2. #$(if $(filter %.apk, $(1)),$(error \  
  3.      Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT inst     ead!))  
  4. #endef  
[cpp] view plain copy
 print?
  1. #define check-product-copy-files  
  2. #$(if $(filter %.apk, $(1)),$(error \  
  3.      Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT inst     ead!))  
  4. #endef  


3.在make otapackage时,报错:

[java] view plaincopyprint?
  1. File "/build/tools/releasetools/edify_generator.py", line 213, in SetPermissions  
  2.     self.script.append('set_perm(%d, %d, 0%o, "%s");' % (uid, gid, mode, fn))  
  3. TypeError: %d format: a number is required, not NoneType  
[java] view plain copy
 print?
  1. File "/build/tools/releasetools/edify_generator.py", line 213, in SetPermissions  
  2.     self.script.append('set_perm(%d, %d, 0%o, "%s");' % (uid, gid, mode, fn))  
  3. TypeError: %d format: a number is required, not NoneType  


可能是你的apk名字中包含非法字符,如中文,"-",等.

0 0