uni-app带有原生插件的APP在某些设备上出现白屏问题

发布于 1周前 作者 gougou168 来自 uni-app

uni-app带有原生插件的APP在某些设备上出现白屏问题
有可能是什么原因导致这些问题,一直找不出原因

报错信息

12-24 15:56:47.230 W/!MCSER! ( 2869): SECURITY## a client is using 'oneway'!
12-24 15:56:47.236 I/ViewRootImpl(28759): CPU Rendering VSync enable = true
12-24 15:56:47.268 I/OpenGLRenderer(28759): Initialized EGL, version 1.4
12-24 15:56:47.287 E/Html5Plus-onCreate(28759): 1735027007287
12-24 15:56:47.287 D/WebAppActivity(28759): onCreate
12-24 15:56:47.295 W/ContextImpl(28759): Failed to ensure directory: /storage/sdcard1/Android/data/com.highzap.sms/cache
12-24 15:56:47.296 D/download_manager(28759): BaseActivity onCreate
12-24 15:56:47.296 D/(28759): onRuntimePreCreate appid=Main_App
12-24 15:56:47.298 W/ResourceType(28759): No package identifier when getting value for resource number 0x00000000
12-24 15:56:47.299 D/Main_Path(28759): use defaultSplash
12-24 15:56:47.312 D/WebAppActivity(28759): checkAutoHide false
12-24 15:56:47.315 E/Html5Plus-onResume(28759): 1735027007315
12-24 15:56:47.316 I/ViewRootImpl(28759): CPU Rendering VSync enable = true
12-24 15:56:47.317 W/!MCSER! ( 2869): SECURITY## a client is using 'oneway'!
12-24 15:56:47.361 E/weex (28759): [WXBridgeManager] invoke execJSService: framework.js uninitialized.
12-24 15:56:47.388 E/weex (28759): [WXBridgeManager] invoke execJSService: framework.js uninitialized.
12-24 15:56:47.389 W/weex (28759): app AvailMemory ---->>>310
12-24 15:56:47.403 E/art (28759): No implementation found for void com.bun.lib.a.a(boolean) (tried Java_com_bun_lib_a_a and Java_com_bun_lib_a_aZ)
12-24 15:56:47.405 E/MdidSdkHelper(28759): InvocationTargetException
12-24 15:56:47.405 E/MdidSdkHelper(28759): java.lang.reflect.InvocationTargetException
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at java.lang.reflect.Constructor.newInstance(Native Method)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at com.bun.miitmdid.core.MdidSdkHelper.InitSdk(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at java.lang.reflect.Method.invoke(Native Method)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at java.lang.reflect.Method.invoke(Method.java:372)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.h.a.d.b.g.a(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.h.a.d.b.g.b(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.h.a.d.b.g.c(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.h.a.d.b.i.b(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.h.c.c.b.b.e.b(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.h.c.c.b.b.e.a(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.h.c.c.b.b.d.b(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.feature.gg.dcloud.ADHandler.pull(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.feature.gg.dcloud.AolFeatureImpl.doForFeature(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.feature.gg.AolFeatureImplMgr.doForFeature(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.a.a(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at io.dcloud.b$a.run(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at android.os.Handler.handleCallback(Handler.java:739)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at android.os.Handler.dispatchMessage(Handler.java:95)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at android.os.Looper.loop(Looper.java:135)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at android.app.ActivityThread.main(ActivityThread.java:5271)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at java.lang.reflect.Method.invoke(Native Method)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at java.lang.reflect.Method.invoke(Method.java:372)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
12-24 15:56:47.405 E/MdidSdkHelper(28759): Caused by: java.lang.UnsatisfiedLinkError: No implementation found for void com.bun.lib.a.a(boolean) (tried Java_com_bun_lib_a_a and Java_com_bun_lib_a_aZ)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at com.bun.lib.a.a(Native Method)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  at com.bun.miitmdid.core.MdidSdk.(Unknown Source)
12-24 15:56:47.405 E/MdidSdkHelper(28759):  ... 25 more
12-24 15:56:47.405 D/MdidSdkHelper(28759): exception exit
12-24 15:56:47.435 W/ContextImpl(28759): Failed to ensure directory: /storage/sdcard1/Android/data/com.highzap.sms/cache
12-24 15:56:47.441 W/ContextImpl(28759): Failed to ensure directory: /storage/sdcard1/Android/data/com.highzap.sms/cache
12-24 15:56:47.450 I/jse_precompilejs(28759): 1
12-24 15:56:47.606 I/ActivityManager(  798): Displayed com.highzap.sms/io.dcloud.PandoraEntryActivity: +363ms (total +410ms)
12-24 15:56:47.608 I/ylyl (28759):  AppMGr START_APP UNICDD0C45
12-24 15:56:47.609 I/ylyl (28759): startOneApp UNICDD0C45
12-24 15:56:47.609 I/System.out(28759): call findFirstX509TrustManager! keyProvider=null
12-24 15:56:47.613 I/Timeline(  798): Timeline: Activity_windows_visible id: ActivityRecord{3789632d u0 com.highzap.sms/io.dcloud.PandoraEntryActivity t14} time:3956422
12-24 15:56:47.614 I/Timeline(  798): Timeline: Activity_windows_visible id: ActivityRecord{33ed0cd6 u0 com.highzap.sms/io.dcloud.PandoraEntry t14 f} time:3956422
12-24 15:56:47.617 E/WXParams(28759): setCrashFilePath: /data/data/com.highzap.sms/app_crash
12-24 15:56:47.618 E/weex (28759): getUseSingleProcess is running false
12-24 15:56:47.618 E/weex (28759): getReleaseMap:true
12-24 15:56:47.619 E/weex (28759): getLibJsbPath is running /data/data/com.highzap.sms/cache/cache/weex/libs/weexjsb/armeabi-v7a/libweexjsb.so
12-24 15:56:47.619 E/weex (28759): getLibLdPath is running /data/app/com.highzap.sms-1/lib/arm:/vendor/lib:/system/lib:/lib:/usr/lib:/home/EPT_Middleware/lib
12-24 15:56:47.632 E/WeexCore(28759): startupPie :1
12-24 15:56:47.656 D/WeexCore(30795): jsengine#weexcore fork child succes!
12-24 15:56:47.649 W/WeexJSBridgeThr(30795): type=1400 audit(0.0:17): avc: denied { setattr } for name="libweexjsb.so" dev="mmcblk0p33" ino=178559 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:apk_data_file:s0 tclass=file permissive=0
12-24 15:56:47.659 W/WeexJSBridgeThr(30795): type=1400 audit(0.0:18): avc: denied { setattr } for name="libweexjsb.so" dev="mmcblk0p33" ino=178559 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:apk_data_file:s0 tclass=file permissive=0

2 回复

也是有的设备白屏


针对uni-app带有原生插件的APP在某些设备上出现白屏问题,这通常与设备兼容性、原生插件的实现方式以及APP的生命周期管理有关。以下是一些可能的解决方案和代码示例,帮助你定位和解决问题。

1. 检查原生插件的兼容性

确保你的原生插件支持目标设备。有时,插件可能只针对特定版本的Android或iOS进行了优化。你可以在插件的官方文档或仓库中查找兼容性信息。

2. 调试原生代码

使用Android Studio或Xcode调试你的APP,查看是否有原生代码导致的崩溃或异常。以下是一个简单的Android原生代码调试示例:

// 在你的原生插件代码中添加日志输出
Log.d("NativePlugin", "Plugin initialized");

// 捕获并处理异常
try {
    // 你的插件逻辑代码
} catch (Exception e) {
    Log.e("NativePlugin", "Error in plugin", e);
    // 可以考虑将错误信息传递给JavaScript层
}

3. 检查uni-app的生命周期管理

确保在APP的生命周期事件中正确管理原生插件。例如,在onLaunchonShow事件中初始化插件,在onHideonUnload事件中释放资源。

// uni-app的生命周期函数
export default {
    onLaunch: function() {
        // 初始化原生插件
        #ifdef APP-PLUS
        plus.myPlugin.init({
            success: function(res) {
                console.log('Plugin initialized successfully');
            },
            fail: function(err) {
                console.error('Plugin initialization failed', err);
            }
        });
        #endif
    },
    onHide: function() {
        // 释放原生插件资源(如果需要)
    },
    // 其他生命周期函数...
};

4. 使用条件编译处理不同设备

针对特定设备或操作系统版本,使用条件编译来包含或排除特定的代码段。

// 针对Android和iOS的不同处理
#ifdef APP-PLUS && __ANDROID__
// Android特定代码
#elif APP-PLUS && __IOS__
// iOS特定代码
#endif

5. 更新uni-app和原生插件

确保你使用的uni-app和所有原生插件都是最新版本,因为新版本可能修复了旧版本中的已知问题。

总结

白屏问题可能涉及多个方面,从原生代码到uni-app的生命周期管理。通过上述方法,你可以逐步定位问题所在,并采取相应的解决措施。如果问题依旧存在,建议查看uni-app和原生插件的官方社区或提交issue寻求更专业的帮助。

回到顶部