开发者

" java.lang.IllegalArgumentException: No configs match configSpec " While opening Camera Intent

开发者 https://www.devze.com 2023-03-17 20:48 出处:网络
This is my simple Camera Intent Demo in which i have only one Activity ..... package x.y; import android.app.Activity;

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

<?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">
      开发者_Go百科  <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.2 from starting of Camera intent with following Exception ...

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?


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]

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:

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.

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.

I hope this helps.


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.

I have also checked above code in Android Device Samsung Galaxy Ace is working fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号