为什么默认相机无法在Android模拟器中工作?

时间:2012-02-08 06:02:46

标签: android camera

当我尝试打开默认情况下在模拟器上给出的Camera应用程序时,它意外停止并且logcat显示

02-08 11:18:35.005: INFO/ActivityManager(83): Starting activity: Intent {act= android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp= com.android.camera/.Camera }
02-08 11:18:35.085: INFO/ActivityManager(83): Start proc com.android.camera for activity com.android.camera/.Camera: pid=580 uid=10006 gids={1006, 1015}
02-08 11:18:35.385: INFO/WindowManager(83): Setting rotation to 1, animFlags=1
02-08 11:18:35.395: INFO/ActivityManager(83): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=2 layout=18 uiMode=17 seq=11}
02-08 11:18:35.845: DEBUG/CameraHardwareStub(34): initHeapLocked: preview size=320x240
02-08 11:18:35.895: DEBUG/Camera(580): app passed NULL surface
02-08 11:18:35.925: DEBUG/CameraHardwareStub(34): initHeapLocked: preview size=320x240
02-08 11:18:35.925: VERBOSE/camera(580): startPreview
02-08 11:18:36.005: INFO/ActivityManager(83): Displayed activity com.android.camera/.Camera: 932 ms    (total 932 ms)
02-08 11:18:36.375: DEBUG/qemud(38): fdhandler_accept_event: accepting on fd 10
02-08 11:18:36.375: DEBUG/qemud(38): created client 0x17fc8 listening on fd 15
02-08 11:18:36.375: DEBUG/qemud(38): client_fd_receive: attempting registration for service   'sensors'
02-08 11:18:36.375: DEBUG/qemud(38): client_fd_receive:    -> received channel id 11
02-08 11:18:36.450: DEBUG/qemud(38): client_registration: registration succeeded for client 11
02-08 11:18:36.495: DEBUG/qemud(38): fdhandler_event: disconnect on fd 15
02-08 11:18:36.995: DEBUG/dalvikvm(580): GC_EXTERNAL_ALLOC freed 1975 objects / 129904 bytes in 182ms
02-08 11:18:37.355: DEBUG/libEGL(580): egl.cfg not found, using default config
02-08 11:18:37.355: DEBUG/libEGL(580): loaded /system/lib/egl/libGLES_android.so
02-08 11:18:37.445: WARN/dalvikvm(580): threadid=9: thread exiting with uncaught exception (group=0x4001d800)
02-08 11:18:37.445: ERROR/AndroidRuntime(580): FATAL EXCEPTION: GLThread 11
02-08 11:18:37.445: ERROR/AndroidRuntime(580): java.lang.IllegalArgumentException: No configs match configSpec
02-08 11:18:37.445: ERROR/AndroidRuntime(580):     at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:760)
02-08 11:18:37.445: ERROR/AndroidRuntime(580):     at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:916)
02-08 11:18:37.445: ERROR/AndroidRuntime(580):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1246)
02-08 11:18:37.445: ERROR/AndroidRuntime(580):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
02-08 11:18:37.475: WARN/ActivityManager(83):   Force finishing activity com.android.camera/.Camera
02-08 11:18:37.515: VERBOSE/camera(580): stopPreview
02-08 11:18:37.755: DEBUG/dalvikvm(83): GC_EXPLICIT freed 2789 objects / 135064 bytes in 137ms
02-08 11:18:37.765: INFO/WindowManager(83): Setting rotation to 0, animFlags=1
02-08 11:18:37.839: INFO/ActivityManager(83): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=1 layout=18 uiMode=17 seq=12}
02-08 11:18:38.045: WARN/ActivityManager(83): Activity pause timeout for HistoryRecord{44f5db08 com.android.camera/.Camera}
02-08 11:18:40.555: DEBUG/dalvikvm(83): GC_EXPLICIT freed 986 objects / 59472 bytes in 131ms
02-08 11:18:41.985: INFO/Process(580): Sending signal. PID: 580 SIG: 9
02-08 11:18:42.005: INFO/WindowManager(83): WIN DEATH: Window{44ed4e48 SurfaceView paused=false}
02-08 11:18:42.005: INFO/ActivityManager(83): Process com.android.camera (pid 580) has died.
02-08 11:18:42.005: INFO/WindowManager(83): WIN DEATH: Window{44ff9fd0    com.android.camera/com.android.camera.Camera paused=false}
02-08 11:18:42.015: INFO/WindowManager(83): WIN DEATH: Window{45003ef8 SurfaceView paused=false}
02-08 11:18:42.095: WARN/InputManagerService(83): Got RemoteException sending setActive(false) notification to pid 580 uid 10006
02-08 11:18:43.805: DEBUG/dalvikvm(260): GC_EXPLICIT freed 2114 objects / 96480 bytes in 146ms
02-08 11:18:48.623: WARN/ActivityManager(83): Activity destroy timeout for HistoryRecord{44f5db08 com.android.camera/.Camera}

我无法理解错误IllegalArgumentException:No configs与configSpec匹配。我是否需要一些额外的配置来打开相机,尽管我已经在模拟器中配置了SD卡。

为了找到解决方案,我看到这个问题的一些答案是相机总是这样工作,所以我们不应该使用它。如果这是正确的,那么我应该用什么来开发相机应用程序?

2 个答案:

答案 0 :(得分:3)

确保您已在AndroidManifest.xml

中授予权限<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" />

请查看此文档Camera

希望它会对你有所帮助。如果你对这个问题感到满意。然后接受ans。这对所有人都有帮助。

答案 1 :(得分:0)

启用硬件加速解决了我的问题。您需要检查Android AVD中的使用主机GPU 选项。