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到平板电脑上,并支持实时调试

相关推荐
_Shirley1 小时前
鸿蒙设置app更新跳转华为市场
android·华为·kotlin·harmonyos·鸿蒙
hedalei3 小时前
RK3576 Android14编译OTA包提示java.lang.UnsupportedClassVersionError问题
android·android14·rk3576
锋风Fengfeng3 小时前
安卓多渠道apk配置不同签名
android
枫_feng3 小时前
AOSP开发环境配置
android·安卓
叶羽西4 小时前
Android Studio打开一个外部的Android app程序
android·ide·android studio
qq_171538855 小时前
利用Spring Cloud Gateway Predicate优化微服务路由策略
android·javascript·微服务
Vincent(朱志强)6 小时前
设计模式详解(十二):单例模式——Singleton
android·单例模式·设计模式
mmsx7 小时前
android 登录界面编写
android·登录界面
姜毛毛-JYM7 小时前
【JetPack】Navigation知识点总结
android
花生糖@8 小时前
Android XR 应用程序开发 | 从 Unity 6 开发准备到应用程序构建的步骤
android·unity·xr·android xr