“ java.lang.IllegalArgumentException: No configs match configSpec “在打开相机意图时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6594636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
" java.lang.IllegalArgumentException: No configs match configSpec " While opening Camera Intent
提问by Vaibhav Jani
This is my simple Camera Intent Demo in which i have only one Activity .....
这是我的简单相机意图演示,其中我只有一个活动 .....
package x.y;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.ImageView;
public class PhotoShoot extends Activity {
final static int CAMERA_RESULT = 0;
ImageView imv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, CAMERA_RESULT);
}
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK)
{
Bundle extras = intent.getExtras();
Bitmap bmp = (Bitmap) extras.get("data");
imv = (ImageView) findViewById(R.id.ReturnedImageView);
imv.setImageBitmap(bmp);
}
}
}
And Layout main.xml
和布局 main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/ReturnedImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
Manifest ...
显现 ...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="x.y"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".PhotoShoot"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Throwing "Force close" after few seconds in Android emulator 2.2from starting of Camera intent with following Exception ...
在 Android 模拟器 2.2 中几秒钟后从相机意图开始抛出“强制关闭”并出现以下异常...
07-06 15:26:00.999: ERROR/AndroidRuntime(544): FATAL EXCEPTION: GLThread 11
07-06 15:26:00.999: ERROR/AndroidRuntime(544): java.lang.IllegalArgumentException: No configs match configSpec
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:760)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:916)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1246)
07-06 15:26:00.999: ERROR/AndroidRuntime(544): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
any idea?
任何的想法?
回答by Mark
This is actually part of a bigger issue, and I'm hoping that by posting here, others who have experienced this error will read this entry. I equally hope that, if any of my conclusions are incorrect, someone comes forth with a more definitive explanation and/or solution.
这实际上是一个更大问题的一部分,我希望通过在这里发帖,其他遇到此错误的人会阅读此条目。我同样希望,如果我的任何结论不正确,有人会提出更明确的解释和/或解决方案。
The core issue is OpenGL support. Beginning at 2.2, Android supports OpenGL ES 2.0, and beginning at 4.0.3, Android emulators support OpenGL ES 2.0. Code that uses OpenGL ES 2.0 will not work on emulators before 4.0.3. [Evidently, the camera switched from ES 1.0 to 2.0 at Android 2.2]
核心问题是OpenGL支持。从 2.2 开始,Android 支持 OpenGL ES 2.0,从 4.0.3 开始,Android 模拟器支持 OpenGL ES 2.0。使用 OpenGL ES 2.0 的代码不能在 4.0.3 之前的模拟器上运行。【很明显,Android 2.2相机从ES 1.0切换到2.0】
But that's not all! None of the Android docs I've encountered mention that, in order to support Open GL ES 2.0 emulation, your box's graphic card chipset and driver must support OpenGL 2.0 as well. Therefore, if you enable GPU Emulation on the AVD and you still encounter this error, do the following:
但这还不是全部!我遇到的所有 Android 文档都没有提到,为了支持 Open GL ES 2.0 仿真,您的机器的显卡芯片组和驱动程序也必须支持 OpenGL 2.0。因此,如果在 AVD 上启用 GPU Emulation 并且仍然遇到此错误,请执行以下操作:
1) Find out the specs on your graphic card and visit the chipset manufacturer's web site to determine if the chipset is OpenGL 2.0 compatible. If it isn't, you're S.O.L. and must stick to debugging through an actual Android device instead of an emulator.
1) 找出您显卡的规格并访问芯片组制造商的网站以确定芯片组是否与 OpenGL 2.0 兼容。如果不是,那么您就是 SOL 并且必须坚持通过实际的 Android 设备而不是模拟器进行调试。
2) Determine if you have the latest graphics driver for the chipset. Drivers obtained through Microsoft (if you're using Windows) typically do not support OpenGL, so you want to download the latest driver from the manufacturer.
2) 确定您是否拥有芯片组的最新图形驱动程序。通过 Microsoft 获得的驱动程序(如果您使用的是 Windows)通常不支持 OpenGL,因此您需要从制造商处下载最新的驱动程序。
I hope this helps.
我希望这有帮助。
回答by Nikhil
Camera is not support in Android emulator so don't worry about it. This type of Error come in Android Emulator 2.2 and i have also Checked Android emulator 1.6 but not getting Error.
Android 模拟器不支持相机,所以不用担心。这种类型的错误出现在 Android 模拟器 2.2 中,我也检查了 Android 模拟器 1.6 但没有收到错误。
I have also checked above code in Android Device Samsung Galaxy Ace is working fine.
我还检查了 Android 设备中的上述代码 Samsung Galaxy Ace 工作正常。
Thanks dear.
谢谢亲爱的。