我正在尝试在Raspberry Pi 2(Android Lollipop 5.1)上运行Android OpenGL ES应用程序。目前不支持硬件加速,因此我在软件中进行了所有渲染。
可以使用以下配置在仿真器(AVD)上重新创建R Pi的相同环境:ARMv7,禁用GPU和Android 5.1。
如果我在模拟器中启用GPU,一切正常,但如果我禁用它,我会收到以下错误:
10-23 22:53:36.798 1550-1565/com.example.android.mediaeffects E/AndroidRuntime﹕
FATAL EXCEPTION: GLThread 187
Process: com.example.android.mediaeffects, PID: 1550
java.lang.IllegalArgumentException: No configs match configSpec
at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:858)
at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1023)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1400)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
我看到这个错误对其他人来说也很常见,比如这篇帖子:
" java.lang.IllegalArgumentException: No configs match configSpec " While opening Camera Intent
或在这篇文章中:
OpenGL ES 2.0 Support for Android?
为其他人工作的解决方案是:
1)在仿真器上启用GPU
2)按以下方式设置EGL配置:
setEGLConfigChooser(8 , 8, 8, 8, 16, 0);
我的问题是我需要禁用GPU(因为在R Pi上它已被禁用),所以我仍然继续得到这个错误。
我还通过添加以下内容强制Manifest文件上的软件加速:
<application
.....
android:hardwareAccelerated="false"
.....>
但这似乎没有任何改变。
有没有人知道如何解决这个问题,但仍然禁用GPU并使用软件加速(hardwareAccelerated =“false”)?
答案 0 :(得分:0)
我使用以下setEGLConfigChooser()
方法实现解决了这个问题:
mEffectView = (GLSurfaceView) view.findViewById(R.id.effectsview);
mEffectView.setEGLContextClientVersion(2);
mEffectView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
/* Get the number of minimally matching EGL configurations */
int[] s_configAttribs2 =
{
EGL10.EGL_RED_SIZE, 4,
EGL10.EGL_GREEN_SIZE, 4,
EGL10.EGL_BLUE_SIZE, 4,
EGL10.EGL_RENDERABLE_TYPE, 1,
EGL10.EGL_NONE
};
int[] num_config = new int[1];
egl.eglChooseConfig(display, s_configAttribs2, null, 0, num_config);
int numConfigs = num_config[0];
if (numConfigs <= 0) {
throw new IllegalArgumentException("No configs match configSpec");
}
/* Allocate then read the array of minimally matching EGL configs */
EGLConfig[] configs = new EGLConfig[numConfigs];
egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config);
/* Return the first configuration found */
return configs[0];
}
});
使用此方法可以正确找到有效的EGL配置。