Android 13 DreamCamera2在Android studio中运行

1.将服务器中DreamCamera2代码复制到本地电脑

s_unisoc_22a\vendor\sprd\platform\packages\apps\DreamCamera2

2.下载build.gradle对应版本Android Studio 4.1.1

下载地址:https://developer.android.google.cn/studio/archive

3.用Android Studio 4.1.1打开DreamCamera2项目,如出现gradle无法下载的情况,请自备梯子

File > Open... > DreamCamera2 > New Window > OK > New Window

4.连接平板电脑,点击Run "DreamCamera2"

5.出现Duplicate resources报错,报错文件为资源key同名冲突,注释一个即可

资源文件一:res\values\dream_camera_arrays_photo_part.xml

资源文件二:res\values\dream_camera_arrays_video_part.xml

同名key为:pref_camera_filter_display_key_array

对比发现同名key对应内容也一致,因些注释上述两个资源文件中的一个pref_camera_filter_display_key_array即可

这里我们注释dream_camera_arrays_video_part.xml中的pref_camera_filter_display_key_array

6.再次点击Run "DreamCamera2"

7.出现依赖缺失报错如下:

Transform's input file does not exist: ...\DreamCamera2\studio_libs\android-ex-camera2-utils.jar

8.去android12源码out目录使用find out -name "android-ex-camera2-utils.jar"可快速查找到该文件所在位置

out/soong/.intermediates/frameworks/ex/camera2/utils/android-ex-camera2-utils/android_common/javac/android-ex-camera2-utils.jar

out/soong/.intermediates/frameworks/ex/camera2/utils/android-ex-camera2-utils/android_common/javac/android-ex-camera2-utils.jar.rsp

out/soong/.intermediates/frameworks/ex/camera2/utils/android-ex-camera2-utils/android_common/turbine/android-ex-camera2-utils.jar

out/soong/.intermediates/frameworks/ex/camera2/utils/android-ex-camera2-utils/android_common/turbine/android-ex-camera2-utils.jar.rsp

out/soong/.intermediates/frameworks/ex/camera2/utils/android-ex-camera2-utils/android_common/turbine-combined/android-ex-camera2-utils.jar

这里我们使用javac/android-ex-camera2-utils.jar文件,并将其放入编译报错所在路径studio_libs中

9.再次点击Run "DreamCamera2"

10.出现类缺失报错如下:

错误: 找不到符号

符号: 类 SystemProperties;

位置: 程序包 android.os

此类为framework.jar中的类,这里我们他用find out -name "framework-minus-apex.jar"

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/aligned/framework-minus-apex.jar

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/combined/framework-minus-apex.jar

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/dex/framework-minus-apex.jar

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/hiddenapi/framework-minus-apex.jar

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/hiddenapi/unaligned/framework-minus-apex.jar

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/jarjar/framework-minus-apex.jar

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/turbine/framework-minus-apex.jar

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/turbine/framework-minus-apex.jar.rsp

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/turbine-combined/framework-minus-apex.jar

out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/turbine-jarjar/framework-minus-apex.jar

这里的们选一个文件最大的combined/framework-minus-apex.jar,并将其放入build.gradle文件中描述的目录,并重命名为framework.jar

options.compilerArgs.add("-Xbootclasspath/p:${ANDROID_TOP}/unisoc_framework/framework.jar")

11.再次点击Run "DreamCamera2"

12.出现已有软件版本号更新报错:The device already has a newer version of this application.

通过下面命令可以监控打开app的包名

C:\Users\WJS>adb shell am monitor

Monitoring activity manager... available commands:

(q)uit: finish monitoring

** Activity starting: com.android.camera2

通过包名获取apk安装位置

C:\Users\WJS>adb shell pm path com.android.camera2

package:/system_ext/app/DreamCamera2/DreamCamera2.apk

将apk下载到电脑上

C:\Users\WJS>adb pull /system_ext/app/DreamCamera2/DreamCamera2.apk .

/system_ext/app/DreamCamera2/DreamCamera2.apk: 1 file pulled, 0 skipped. 32.6 MB/s (7698606 bytes in 0.225s)

将apk拖入Android Studio中进行反编译可获取到其:

android:versionCode="20002000"

android:versionName="2.0.002"

将上述参数写入build.gradle中,同时点击Sync Now

11.再次点击Run "DreamCamera2"

12.签名不一致报错:The device already has an application with the same package but a different signature.

jks签名文件生成方法:

openssl pkcs8 -inform DER -nocrypt -in "platform.pk8" -out "key"

openssl pkcs12 -export -in "platform.x509.pem" -inkey "key" -out "p12" -password pass:123456 -name platform

openssl x509 -noout -fingerprint -in "platform.x509.pem"

keytool -importkeystore -deststorepass 123456 -destkeystore "platform.jks" -srckeystore "p12" -srcstoretype PKCS12 -srcstorepass 123456

platform.pk8和platform.x509.pem可以在build\target\product\security(debug签名)或者vendor\sprd\release\apk_key(release签名)找到

将生成的jks签名文件放入DreamCamera2/key目录中

在build.gradle中android节点下添加如下内容:

android {

signingConfigs {

bnd {

storeFile file('key/bnd/platform.jks')

storePassword '123456'

keyPassword '123456'

keyAlias 'platform'

}

}

...

buildTypes {

...

debug {

...

signingConfig signingConfigs.bnd

}

}

}

完成后点击Sync Now

13.再次点击Run "DreamCamera2", 成功使用Android Studio安装DreamCamera2到平板电脑上,并支持实时调试

相关推荐
大白要努力!18 分钟前
Android opencv使用Core.hconcat 进行图像拼接
android·opencv
小林想被监督学习42 分钟前
idea怎么打开两个窗口,运行两个项目
java·ide·intellij-idea
HoneyMoose44 分钟前
IDEA 2024.3 版本更新主要功能介绍
java·ide·intellij-idea
天空中的野鸟1 小时前
Android音频采集
android·音视频
小白也想学C2 小时前
Android 功耗分析(底层篇)
android·功耗
曙曙学编程2 小时前
初级数据结构——树
android·java·数据结构
PigeonGuan3 小时前
【jupyter】linux服务器怎么使用jupyter
linux·ide·jupyter
小狮子安度因4 小时前
PyQt的安装和再PyCharm中的配置
ide·pycharm·pyqt
闲暇部落5 小时前
‌Kotlin中的?.和!!主要区别
android·开发语言·kotlin
VernonJsn6 小时前
visual studio 2005的MFC各种线程函数之间的调用关系
ide·mfc·visual studio