问题描述
将 Chrome 预装到 system/app 目录下,打开 Chrome 直接闪退了,直觉告诉我应该是少so库导致的
将Chrome直接install上去,再次打开 Chrome 正常进入,将 data/data/ Chrome 目录拷贝出来,
找到其中需要的so库
错误日志
com.android.chrome I/cr_Linker: Using linker: org.chromium.base.library_loader.LegacyLinker com.android.chrome I/cr_LibraryLoader: Loading chrome com.android.chrome I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:0 com.android.chrome E/GoogleCertificates: Failed to get Google certificates from remote tw: No acceptable module found. Local version is 0 and remote version is 0. at zw.a(PG:29) at dw.b(PG:6) at dw.a(PG:6) at ur.a(PG:23) at el.a(PG:6) at sA0.a(PG:3) at Sm.e(PG:3) at Sm.b(PG:1) at org.chromium.components.signin.AccountManagerFacade.d(PG:2) at l42.a(PG:3) at H40.call(PG:4) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at X40.run(PG:1) at e50.g(PG:11) at d50.run(Unknown Source:2) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at P40.run(PG:2) at java.lang.Thread.run(Thread.java:764) com.android.chrome W/GooglePlayServicesUtil: Google Play Store is missing. W/Layer: [Splash Screen com.android.chrome#0] opaque layer with plane alpha:0.86 cannot be handled by hwcomposer W/Layer: [Splash Screen com.android.chrome#0] opaque layer with plane alpha:0.94 cannot be handled by hwcomposer com.android.chrome E/cr_LegacyLinker: Unable to load library: libchrome.so com.android.chrome W/cr_LibraryLoader: Failed to load native library with shared RELRO, retrying without com.android.chrome E/cr_LegacyLinker: Unable to load library: libchrome.so com.android.chrome I/SurfaceFactory: [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@228b644 com.android.chrome E/cr_CompositorSurfaceMgr: Transitioning to surface with format : -1 --------- beginning of crash com.android.chrome E/AndroidRuntime: FATAL EXCEPTION: main Process: com.android.chrome, PID: 2445 c30: errorCode=4 at xT0.b(PG:8) at cU0.a(PG:3) at rT0.a(PG:18) at nT0.run(PG:2) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6523) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
解决办法
根据拷贝出的Chrome文件,so库路径为 lib/arm, 在编译的Android.mk目录下,新建 lib/arm ,
将对应的so拷贝进去,新建 copy.sh
#!/bin/bash echo -e "SO_PATH=${1}" echo -e "OUT_PACKAGE_PATH=${2}" echo -e "start cp ${1} so..." currentPath=$(pwd)/${1} destinationPath=${OUT}/${2}/lib echo -e "currentPath=${currentPath}" echo -e "destinationPath=${destinationPath}" if [ ! -d "${destinationPath}" ]; then echo "mkdie destinationPath" mkdir -p ${destinationPath} fi cp -f -r $currentPath $destinationPath echo -e "\n copy.sh make done...."
在 Android.mk 中调用执行 copy.sh
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # Module name should match apk name to be installed LOCAL_MODULE := Chrome LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(LOCAL_MODULE).apk LOCAL_MODULE_CLASS := APPS LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) LOCAL_CERTIFICATE := PRESIGNED include $(BUILD_PREBUILT) $(info ${LOCAL_PATH}) $(info ${TARGET_OUT}) SO_PATH := $(LOCAL_PATH)/lib/arm OUT_PACKAGE_PATH := system/app/$(LOCAL_MODULE) __PRODUCT_COPY_SO = $(shell ${LOCAL_PATH}/copy.sh ${SO_PATH} ${OUT_PACKAGE_PATH}) $(info ${__PRODUCT_COPY_SO})