English 中文(简体)
法特例外:java.lang.RuntimeException: 使用 不止一个进程与同一数据目录一起发出的网上意见,没有得到支持。
原标题:Fatal Exception: java.lang.RuntimeException:Using WebView from more than one process at once with the same data directory is not supported

1. 导言 当I in Fragment onCreateView methods inflater.inflate (webview_layout, protocol, false) on 9 可能与点击记录发生碰撞:


    Fatal Exception: java.lang.RuntimeException:Using WebView from more than one process at once with the same data directory is not supported. https://crbug.com/558377
    at jO.b(PG:102)
    at jQ.run(PG:3)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:226)
    at android.app.ActivityThread.main(ActivityThread.java:7210)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:961)

2. 结 论 我尝试在Create 方法应用中添加打击代码。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
    String processName = getProcessName();
    if (!MAIN_PROCESS.equals(processName)) {
        WebView.setDataDirectorySuffix(getProcessName() + ".webview");
    }
}

但是,一些安乐器电话中也有同样的理由,而且我没有使用多功能的网格,然后试图在CreateView上添加这一代码,然后再添加到flater.inflate(网站view_layout,集装箱,假)上。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
    String processName = getProcessName();
    try {
        WebView.setDataDirectorySuffix(processName);
    } catch (Throwable e) {
        // ignore
    }
}

但是,我也看到了在PCAM10PCEM00PCAT10中的一些坠毁报告,我可以在当地重新看到这一坠毁事件。

是否还有其他原因?

问题回答

在Admob启动前,在申请类别中采用该守则解决了我的问题:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        val process = getProcessName()
        if (packageName != process) WebView.setDataDirectorySuffix(process)
    }

MobileAds.initialize(this)

There is a new effective API to get process name for API 28 onwards. [https://developer.android.com/reference/android/app/Application.html#getProcessName()][1]

正如Agogle文件提到的那样,从A/60/828来看,在多过程运行的网上意见显然不能分享同样的数据目录。

This means that different processes in the same application cannot directly share WebView-related data, since the data directories must be distinct.

Another thing, please check if you are initializing any process in the Application class or not. Reference link : Android Pie (9.0) WebView in multi-process

If you have two or more different processes for your app and services then you could just disable WebView usage in the process which doesnt intend to use WebView WebView.disableWebView()

public void onCreate() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        WebView.disableWebView();
    }
    ...
}

在该案中,如果建立网上通话或在roid中采用任何其他方法,则将排除例外情况。 网上工具包按程序使用。 但“java.lang.RuntimeException: 使用 不止一个过程的网上意见......

[Android]Below code help to solve this issue. I add process id in suffix directory name

  private fun setupWebView() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
      getAppProcessName()?.let {
        WebView.setDataDirectorySuffix(it)
      }
    }
  }

  private fun getAppProcessName(): String? {
    val pid = Process.myPid()
    val manager = getSystemService(Context.ACTIVITY_SERVICE) as? ActivityManager
    return manager?.runningAppProcesses?.filterNotNull()?.firstOrNull { it.pid == pid }?.processName + pid
  }




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签