【问题标题】:Android 2.2 Webview causes OpenGL ES API with no current context (logged once per thread)Android 2.2 Webview 导致 OpenGL ES API 没有当前上下文(每个线程记录一次)
【发布时间】:2012-09-20 04:41:26
【问题描述】:

首先,感谢您阅读这篇文章并提前帮助我解决这个问题。 我目前正在为 android 创建一个 webshel​​l 来运行 Webapps,它在 Android 2.2 SDK 上运行。

当我调试我的应用程序时出现问题(这是通过 USB 在 Android 4.0 手机上完成的):

09-28 11:32:32.415: D/dalvikvm(25629): Debugger has detached; object registry had 576 entries
09-28 11:32:36.355: W/ActivityThread(25764): Application com.android_api8_webshell is waiting for the debugger on port 8100...
09-28 11:32:36.375: I/System.out(25764): Sending WAIT chunk
09-28 11:32:36.380: I/dalvikvm(25764): Debugger is active
09-28 11:32:36.575: I/System.out(25764): Debugger has connected
09-28 11:32:36.575: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:36.775: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:36.975: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:37.175: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:37.375: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:37.575: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:37.780: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:37.980: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:38.180: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:38.385: I/System.out(25764): waiting for debugger to settle...
09-28 11:32:38.585: I/System.out(25764): debugger has settled (1497)
09-28 11:32:38.710: I/webclipboard(25764): clipservice: android.sec.clipboard.ClipboardExManager@41a184d8
09-28 11:32:38.765: V/StringUrl(25764): String: http://www.cidesign.nl
09-28 11:32:38.785: D/WML_SISO(25764): InitPasteboardJni
09-28 11:32:38.795: V/(25764): NotificationPresenterImpl::setSettingsValue 0 
09-28 11:32:38.795: V/(25764): NotificationPresenterImpl::setSettingsValue 0 
09-28 11:32:38.800: D/webkit(25764): Firewall not null
09-28 11:32:38.800: D/webkit(25764): euler: isUrlBlocked = false
09-28 11:32:38.930: D/CLIPBOARD(25764): Hide Clipboard dialog at Starting input: finished by someone else... !
09-28 11:32:42.440: I/GATE(25764): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
09-28 11:32:42.455: E/libEGL(25764): call to OpenGL ES API with no current context (logged once per thread)
09-28 11:32:42.455: D/ShaderProgram(25764): couldn't load the vertex shader!
09-28 11:32:42.455: E/libEGL(25764): call to OpenGL ES API with no current context (logged once per thread)
09-28 11:32:42.455: D/ShaderProgram(25764): couldn't load the vertex shader!
09-28 11:32:42.455: E/libEGL(25764): call to OpenGL ES API with no current context (logged once per thread)
09-28 11:32:42.455: D/ShaderProgram(25764): couldn't load the vertex shader!
09-28 11:32:42.455: E/libEGL(25764): call to OpenGL ES API with no current context (logged once per thread)
09-28 11:32:42.455: D/ShaderProgram(25764): couldn't load the vertex shader!
09-28 11:32:42.455: E/libEGL(25764): call to OpenGL ES API with no current context (logged once per thread)
09-28 11:32:42.455: D/ShaderProgram(25764): couldn't load the vertex shader!

这是我在主类中的代码:

package com.android_api8_webshell;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebSettings;

public class Main extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        WebView myWebView = (WebView) findViewById(R.id.webView1);

        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        Log.v("StringUrl", "String: " + getResources().getText(R.string.url));

        myWebView.loadUrl(getResources().getText(R.string.url).toString());
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }  
}

最后但并非最不重要的一点是,xml im 正在运行:

<resources>
    <string name="title_activity_main">Main</string>
    <string name="url">http://www.cidesign.nl</string>
    <string name="app_name">Android_API8_WebShell</string>
    <string name="menu_settings">Settings</string>
</resources>

我知道此配置对其他人有帮助:

<application android:hardwareAccelerated="true" ...>

但是对于2.3.3以上的SDK,我运行的SDK不支持这个功能。

我真的希望你能帮我解决这个问题。

提前致谢,

大卫

【问题讨论】:

  • 如果有什么方法可以使用较新的SDK,可以随时尝试setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  • 您可以使用反射更改到软件层,这样它仍然可以在旧设备上运行。我在这里描述了如何:stackoverflow.com/questions/7781655/…
  • 您是否必须使用 SDK 2.2,或者您是否可以使用更新的 SDK(比如 4.2.2)但通过支持 API 支持 2.2 设备?
  • 这不是 2.2 SDK 的问题。 Romain Guy 已经回答了:stackoverflow.com/a/8825054/1761411

标签: java android web-applications opengl-es


【解决方案1】:

要获得android:hardwareAccelerated 属性并仍支持API 8 (2.2),请将targetSdkVersion 设置为11,但保持minSdkVersion 不变:

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11" />
<application android:hardwareAccelerated="true" ...

在 API 11 之前的设备上运行时,hardwareAccelerated 将被忽略。

【讨论】:

  • 我在 2.2 到 4.2 上运行,那么有什么解决方案吗?
  • 就在这里。它不适合你吗?只需将 targetSdkVersion 设置为 17 - 这是 4.2 的设置
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-17
  • 1970-01-01
相关资源
最近更新 更多