由上一篇文章在AS导入源码阅读成功,查看如framework层,HAL层源码都没有什么问题,但是当我们来开发系统相机时,发现还是有一大串的bug,发现是R文件引用问题导致,今天就来解决这个问题。
一、AS关联Camera2
-
上一篇一个小问题:导入的依赖配置保存失败,由于AS没有Android.iml和Android.ipr权限
修改权限(否则一直报错,无法保存,Modul的依赖设置): sudo chmod 777 Android.iml sudo chmod 777 Android.ipr
-
修改Android.iml
-
核心源码:
<sourceFolder url="file://$MODULE_DIR$/frameworks" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/hardware" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/kernel_imx" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/packages" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
-
关联系统相机R件配置文(classes)
<!-- 关联系统相机 R --> <sourceFolder url="file://$MODULE_DIR$/out/target/common/obj/APPS/Camera2Tests_intermediates" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/out/target/common/obj/APPS/Camera2_intermediates" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/out/target/common/obj/JAVA_LIBRARIES" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/./out/target/common/obj/APPS/ExtServices_intermediates/src" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/out/target/product/sabresd_6dq" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/out/target/common/gen" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/out/target/common/R" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/out/target/common/docs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/out/target/common/System" isTestSource="false" />
-
-
关联Camera2使用的第三方库,比如glide ,google common,这里有2种办法:
-
首先是一个个找到,如下: (在最初生成的Android.iml,如我的:IMX6Q Android 7.1.2 IDEGen生产Android.iml)
<!-- 关联系统引用的jar包,比如glide ,google common--> <sourceFolder url="file://$MODULE_DIR$/./external/glide/library/src/main/java" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/glide/testutil/src/main/java" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/glide/third_party/disklrucache/src/main/java" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/glide/third_party/gif_decoder/src/main/java" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/glide/third_party/gif_encoder/src/main/java" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/google-tv-pairing-protocol/java/src" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/base/super" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/cache/super" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/collect/super" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/escape/super" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/io/super" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/math/super" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/primitives/super" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/java/util/super" isTestSource="false"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/base/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/cache/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/collect/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/collect/testing/google/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/collect/testing/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/io/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/math/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/net/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/primitives/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/testing/super" isTestSource="true"/> <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/util/concurrent/super" isTestSource="true"/>
-
也可以直接关联external,工程量较大,影响相应速度
<!-- 关联external --> <sourceFolder url="file://$MODULE_DIR$/external" isTestSource="false" />
-
二、debug调式
- 在上述关联完成后就可以进行debug调式了,如下,在adb连上开发板设备后,选择AS进程调式按钮,如下图,勾选Show all processes ,选择我们需要调式得进程,如:
com.android.camera2:
- 启动软件后,在代码中打上断点,即可进行debug调式
三、总结
接下来就是正常开放咯,如果不需要进行framework改动的,可以直接生产moudle项目,将out/target/product/xx_/system/framework.jar导入即可。
是不是很简单,喜欢点个关注呗。