我正在尝试使用模拟器进行应用开发。在模拟器中,当我尝试打开相机时,我收到错误消息,因为相机已停止工作。我的堆栈是Cordova + Android SDK。警告我是新手!
这是我的AVD配置
avd.ini.encoding=UTF-8
abi.type=x86
disk.dataPartition.size=200M
hw.accelerometer=yes
hw.audioInput=yes
hw.battery=yes
hw.camera.back=webcam0
hw.camera.front=none
hw.cpu.arch=x86
hw.dPad=no
hw.device.hash2=MD5:6930e145748b87e87d3f40cabd140a41
hw.device.manufacturer=Google
hw.device.name=Nexus 4
hw.gps=yes
hw.keyboard=yes
hw.lcd.density=320
hw.mainKeys=no
hw.ramSize=1907
hw.sdCard=yes
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images\android-16\default\x86\
sdcard.size=512M
skin.dynamic=no
skin.name=HVGA
skin.path=platforms\android-16\skins\HVGA
tag.display=Default
tag.id=default
vm.heapSize=64
模拟器的logcat如下
E/Trace ( 1617): error opening trace file: No such file or directory (2)
V/CameraHolder( 1617): open camera 0
E/CameraService( 795): CameraService::connect X (pid 1617) rejected (invalid ca
meraId 0).
I/Choreographer( 1127): Skipped 30 frames! The application may be doing too muc
h work on its main thread.
D/dalvikvm( 1617): GC_CONCURRENT freed 223K, 5% free 6149K/6471K, paused 17ms+0m
s, total 18ms
E/CameraHolder( 1617): fail to connect Camera
E/CameraHolder( 1617): java.lang.RuntimeException: Fail to connect to camera ser
vice
E/CameraHolder( 1617): at android.hardware.Camera.native_setup(Native Method)
E/CameraHolder( 1617): at android.hardware.Camera.<init>(Camera.java:306)
E/CameraHolder( 1617): at android.hardware.Camera.open(Camera.java:268)
E/CameraHolder( 1617): at com.android.camera.CameraHolder.open(CameraHolder.jav
a:131)
E/CameraHolder( 1617): at com.android.camera.Util.openCamera(Util.java:267)
E/CameraHolder( 1617): at com.android.camera.Camera$4.run(Camera.java:1100)
E/CameraHolder( 1617): at java.lang.Thread.run(Thread.java:856)
W/dalvikvm( 1617): threadid=10: thread exiting with uncaught exception (group=0x
b3e65288)
E/AndroidRuntime( 1617): FATAL EXCEPTION: Thread-74
E/AndroidRuntime( 1617): java.lang.RuntimeException: openCamera failed
E/AndroidRuntime( 1617): at com.android.camera.Util.openCamera(Util.java:
272)
E/AndroidRuntime( 1617): at com.android.camera.Camera$4.run(Camera.java:1
100)
E/AndroidRuntime( 1617): at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime( 1617): Caused by: com.android.camera.CameraHardwareException:
java.lang.RuntimeException: Fail to connect to camera service
E/AndroidRuntime( 1617): at com.android.camera.CameraHolder.open(CameraHo
lder.java:135)
E/AndroidRuntime( 1617): at com.android.camera.Util.openCamera(Util.java:
267)
E/AndroidRuntime( 1617): ... 2 more
E/AndroidRuntime( 1617): Caused by: java.lang.RuntimeException: Fail to connect
to camera service
E/AndroidRuntime( 1617): at android.hardware.Camera.native_setup(Native M
ethod)
E/AndroidRuntime( 1617): at android.hardware.Camera.<init>(Camera.java:30
6)
E/AndroidRuntime( 1617): at android.hardware.Camera.open(Camera.java:268)
E/AndroidRuntime( 1617): at com.android.camera.CameraHolder.open(CameraHo
lder.java:131)
E/AndroidRuntime( 1617): ... 3 more
D/dalvikvm( 1617): GC_CONCURRENT freed 87K, 4% free 6482K/6727K, paused 12ms+1ms
, total 14ms
W/ActivityManager( 1006): Force finishing activity com.android.camera/.Camera
W/WindowManager( 1006): Failure taking screenshot for (164x246) to layer 21015
W/ActivityManager( 1006): Activity pause timeout for ActivityRecord{b46418d8 com
.android.camera/.Camera}
I/Process ( 1617): Sending signal. PID: 1617 SIG: 9
I/ActivityManager( 1006): Process com.android.camera (pid 1617) has died.