Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android闪退 #5

Closed
hongjie104 opened this issue Jun 22, 2019 · 15 comments
Closed

android闪退 #5

hongjie104 opened this issue Jun 22, 2019 · 15 comments

Comments

@hongjie104
Copy link

在执行这个方法的时候 X5Sdk.openWebActivity(url, title: title); 闪退了~
报错如下

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xingfei.ui/com.cjx.x5_webview.X5WebViewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
E/AndroidRuntime(25733):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2856)
E/AndroidRuntime(25733):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2931)
E/AndroidRuntime(25733):        at android.app.ActivityThread.-wrap11(Unknown Source:0)
E/AndroidRuntime(25733):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1620)
E/AndroidRuntime(25733):        at android.os.Handler.dispatchMessage(Handler.java:105)
E/AndroidRuntime(25733):        at android.os.Looper.loop(Looper.java:173)
E/AndroidRuntime(25733):        at android.app.ActivityThread.main(ActivityThread.java:6698)
E/AndroidRuntime(25733):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(25733):        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/AndroidRuntime(25733):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
E/AndroidRuntime(25733): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
E/AndroidRuntime(25733):        at com.cjx.x5_webview.X5WebViewActivity.initView(X5WebViewActivity.kt:24)
E/AndroidRuntime(25733):        at com.cjx.x5_webview.X5WebViewActivity.onCreate(X5WebViewActivity.kt:20)
E/AndroidRuntime(25733):        at android.app.Activity.performCreate(Activity.java:7040)
E/AndroidRuntime(25733):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
E/AndroidRuntime(25733):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809)

求指导

@VenusCao
Copy link
Owner

检查你android values下的 style 是否为noactionbar

@VenusCao
Copy link
Owner

还有不要使用AppCompat下的主题

@hongjie104
Copy link
Author

noactionbar

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
</resources>

style用的都是默认的,并没有做过任何修改

@VenusCao
Copy link
Owner

示例app会出现么

@hongjie104
Copy link
Author

示例app会出现么

示例APP我手机装了,X5Sdk.openWebActivity 访问百度,算是正常吧,只是偶尔会出现错误提示,应该是因为百度页面里有下载百度app的链接导致。但是不会崩溃

@VenusCao
Copy link
Owner

那可能就是sdk版本的问题,你可以对照demo的bulid.gradle调整

@hongjie104
Copy link
Author

额,我看了一下,demo和我的工程里的gradle都是3.2.1

@VenusCao
Copy link
Owner

android sdk,不是gradle

@hongjie104
Copy link
Author

compileSdkVersion 和 targetSdkVersion 都设置成和demo一样的28了,错误依旧~

@VenusCao
Copy link
Owner

那你等下,我看看怎么调整一下

@VenusCao
Copy link
Owner

反正就是找不到actionbar,你把style改成有actionbar的主题试试,下个版本我处理一下

@VenusCao
Copy link
Owner

Theme.Black.NoTitleBar 改成 Theme.Black

@hongjie104
Copy link
Author

好,多谢

@VenusCao
Copy link
Owner

试试新版本0.1.3

@hongjie104
Copy link
Author

试试新版本0.1.3

新版本不会闪退了,非常感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants