在 AOSP 中添加预构建的 Apk 崩溃

Adding Pre-built Apk in AOSP crashes

我正在尝试在 AOSP 中添加 OpenVPN 应用程序,但它崩溃了。我已经通过在设备中安装来检查它,当我从 playstore/f-droid 安装它或通过 adb install 下载 apk 时它工作正常。当我在 aosp 源代码中添加此 apk 时,它会添加到构建 AOSP (OS) 中,但是当我在设备中闪烁 AOSP 后启动应用程序时,它会在库上崩溃,然后我在 AOSP 中添加了它所需的库,但现在它抛出了其他错误。 AOSP (OS) 在两种情况下都是相同的。我也尝试过其他 VPN 应用程序,但所有应用程序都存在同样的问题。 我在 AOSP 中添加了其他应用程序,这些应用程序运行良好,但这些 VPN 应用程序无法运行。

这是应用程序崩溃的 adb 日志

2020-10-16 10:12:49.736 0-0/? E/q6asm_callback: payload size of 8 is less than expected.
    
    --------- beginning of main
2020-10-16 10:12:51.759 1291-5412/? E/ACDB-LOADER: Error: ACDB AudProc vol returned = -19
2020-10-16 10:12:51.780 0-0/? E/q6asm_callback: payload size of 8 is less than expected.
2020-10-16 10:12:51.785 1568-1743/? E/system_server: Invalid ID 0x00000000.
2020-10-16 10:12:51.788 6354-6354/? E/q6asm_callback: payload size of 8 is less than expected.
2020-10-16 10:12:51.795 0-0/? E/q6asm_callback: payload size of 8 is less than expected.
2020-10-16 10:12:51.885 6354-6354/? E/SoLoader: couldn't find DSO to load: libc++_shared.so caused by: dlopen failed: couldn't map "/data/user/0/net.openvpn.openvpn/lib-main/libc++_shared.so" segment 1: Permission denied
2020-10-16 10:12:51.885 6354-6354/? E/SoLoader: couldn't find DSO to load: libfb.so caused by: couldn't find DSO to load: libc++_shared.so caused by: dlopen failed: couldn't map "/data/user/0/net.openvpn.openvpn/lib-main/libc++_shared.so" segment 1: Permission denied
2020-10-16 10:12:51.885 6354-6354/? E/SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: couldn't find DSO to load: libfb.so caused by: couldn't find DSO to load: libc++_shared.so caused by: dlopen failed: couldn't map "/data/user/0/net.openvpn.openvpn/lib-main/libc++_shared.so" segment 1: Permission denied
2020-10-16 10:12:51.888 6354-6380/? E/SoLoader: couldn't find DSO to load: libhermes.so
    
    --------- beginning of crash
2020-10-16 10:12:51.888 6354-6380/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: net.openvpn.openvpn, PID: 6354
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
        at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27)
        at com.facebook.react.ReactInstanceManager.run(ReactInstanceManager.java:952)
        at java.lang.Thread.run(Thread.java:922)
2020-10-16 10:12:54.986 0-0/? E/q6asm_callback: payload size of 8 is less than expected.
2020-10-16 10:12:55.351 1568-4304/? E/TaskPersister: File error accessing recents directory (directory doesn't exist?).
2020-10-16 10:13:52.588 4309-4309/? E/libnfc_nci: [ERROR:NativeNfcTag.cpp(866)] nativeNfcTag_doDisconnect: tag already deactivated
2020-10-16 10:13:52.571 0-0/? E/i2c-msm-v2 c1b6000.i2c: NACK: slave not responding, ensure its powered: msgs(n:1 cur:0 tx) bc(rx:0 tx:7) mode:FIFO slv_addr:0x28 MSTR_STS:0x0d1300c8 OPER:0x00000090 

@RickSanchez 建议解决了我的问题,但我不得不在 AOSP 中添加两个库]

创建一个名为 OpenVPN 的文件夹,将名为 OpenVPN.apk 的 APK 放入其中,下面 Android.mk:

LOCAL_PATH := $(call my-dir)

my_archs := arm x86 arm64
my_src_arch := $(call get-prebuilt-src-arch, $(my_archs))

include $(CLEAR_VARS)
LOCAL_MODULE := OpenVPN
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_SRC_FILES := OpenVPN.apk

LOCAL_PREBUILT_JNI_LIBS := \
  @lib/arm64-v8a/libc++_shared.so \
  @lib/arm64-v8a/libconceal.so \
  @lib/arm64-v8a/libfb.so \
  @lib/arm64-v8a/libfolly_futures.so \
  @lib/arm64-v8a/libfolly_json.so \
  @lib/arm64-v8a/libglog.so \
  @lib/arm64-v8a/libglog_init.so \
  @lib/arm64-v8a/libhermes-executor-debug.so \
  @lib/arm64-v8a/libhermes-executor-release.so \
  @lib/arm64-v8a/libhermes-inspector.so \
  @lib/arm64-v8a/libhttpcli.so \
  @lib/arm64-v8a/libimagepipeline.so \
  @lib/arm64-v8a/libjsc.so \
  @lib/arm64-v8a/libjscexecutor.so \
  @lib/arm64-v8a/libjsijniprofiler.so \
  @lib/arm64-v8a/libjsinspector.so \
  @lib/arm64-v8a/libnative-filters.so \
  @lib/arm64-v8a/libnative-imagetranscoder.so \
  @lib/arm64-v8a/libovpncli.so \
  @lib/arm64-v8a/libreactnativeblob.so \
  @lib/arm64-v8a/libreactnativejni.so \
  @lib/arm64-v8a/libyoga.so

LOCAL_MODULE_TARGET_ARCH := $(my_src_arch)

include $(BUILD_PREBUILT)

提示:我使用此工具自动生成 Android.mk:https://github.com/northbright/genandroidmk

如果由于某种原因这不起作用,则将库从 APK 解压缩到本地文件夹,并使用相对路径引用库(在 LOCAL_PREBUILT_JNI_LIBS 中没有“@”符号,但是只有 lib/arm64-v8a/libc++_shared.so )