APP Crash
chejdj opened this issue · 1 comments
chejdj commented
What steps will reproduce the problem?
该问题的重现步骤是什么?
- 按照官网配置
What is the expected output? What do you see instead?
你期待的结果是什么?实际看到的又是什么?
正常集成使用,实际上崩溃
What version of the product are you using? On what operating system?
你正在使用产品的哪个版本?在什么操作系统上?
com.tencent.sonic:sdk:3.1.0
Android 虚拟机Nexus_6 API 22
Please provide any additional information below.
如果有的话,请在下面提供更多信息。
Kotlin 版本 1.3.31
compileSdkVersion 28
buildToolsVersion "28.0.3"
minSdkVersion 21
targetSdkVersion 28
crash 日志如下:
data_app_native_crash@1567006798797.txt
实际使用中的代码
window.addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED)
if (!SonicEngine.isGetInstanceAllowed()) {
SonicEngine.createInstance(SonicRuntimeImpl(application), SonicConfig.Builder().build())
}
val config = SonicSessionConfig.Builder().setSupportLocalServer(true).build()
val sonicSessionClient = SonicSessionClientImpl()
sonicSession = SonicEngine.getInstance().createSession(articleUrl, config)
if (null != sonicSession) {
sonicSession.bindClient(sonicSessionClient)
} else {
Toast.makeText(this, "create sonic session fail!", Toast.LENGTH_LONG).show()
}
setContentView(R.layout.activity_webview)
val titleTx: TextView = findViewById(R.id.title)
titleTx.text = articleTitle
val webView: WebView = findViewById(R.id.webView)
webView.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
if (sonicSession != null) {
sonicSession.sessionClient.pageFinish(url)
}
}
@TargetApi(21)
override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? {
return shouldInterceptRequest(view, request.url.toString())
}
override fun shouldInterceptRequest(view: WebView, url: String): WebResourceResponse? {
return if (sonicSession != null) {
sonicSession.sessionClient.requestResource(url) as WebResourceResponse
} else null
}
}
val webSettings = webView.settings
webSettings.javaScriptEnabled = true
webView.removeJavascriptInterface("searchBoxJavaBridge_")
intent.putExtra(SonicJavaScriptInterface.PARAM_LOAD_URL_TIME, System.currentTimeMillis())
webView.addJavascriptInterface(SonicJavaScriptInterface(sonicSessionClient, intent), "sonic")
// init webview settings
webSettings.allowContentAccess = true
webSettings.databaseEnabled = true
webSettings.domStorageEnabled = true
webSettings.setAppCacheEnabled(true)
webSettings.savePassword = false
webSettings.saveFormData = false
webSettings.useWideViewPort = true
webSettings.loadWithOverviewMode = true
if (sonicSessionClient != null) {
sonicSessionClient.bindWebView(webView)
sonicSessionClient.clientReady()
} else {
webView.loadUrl(articleUrl)
}
liangxiwei commented
log不够完整兄弟,而且你这似乎是模拟器运行的