java.lang.SecurityException:方法类android.media.IAudioService $ Stub $ Proxy.isCameraSoundForced []不可用

时间:2017-06-15 13:58:23

标签: android android-instant-apps

调用Camera.open(cameraIndex)(Camera 1 API)时出现以下错误

MethodInvocationProxy:调用方法时的异常public abstract boolean android.media.IAudioService.isCameraSoundForced()抛出android.os.RemoteException                                             java.lang.SecurityException:方法类android.media.IAudioService $ Stub $ Proxy.isCameraSoundForced []不适用于即时应用程序

  

06-18 10:23:43.361 26240-26359 /? E /同位素:UID:[10185] PID:[26240]   MethodInvocationStub:调用方法时出现异常   isCameraSoundForced                                               java.lang.SecurityException:方法类   android.media.IAudioService $ Stub $ Proxy.isCameraSoundForced []没有   适用于即时应用                                                   在com.google.android.instantapps.supervisor.ipc.proxies.SandboxEnforcer.enforceUnsupportedPolicy(PG:63)                                                   在com.google.android.instantapps.supervisor.ipc.proxies.SandboxEnforcer.enforceUnsupportedMethodPolicy(PG:17)                                                   在com.google.android.instantapps.supervisor.ipc.ProxyMethodHandler.handleMethod(PG:50)                                                   在com.google.android.instantapps.supervisor.ipc.base.MethodInvocationStub.onTransact(PG:56)                                                   在android.os.Binder.execTransact(Binder.java:453)06-18 10:23:43.361   26274-26274 /? E /同位素:UID:[99000] PID:[26274]   MethodInvocationProxy:调用方法public abstract时的异常   boolean android.media.IAudioService.isCameraSoundForced()抛出   android.os.RemoteException                                               java.lang.SecurityException:方法类   android.media.IAudioService $ Stub $ Proxy.isCameraSoundForced []没有   适用于即时应用                                                   在android.os.Parcel.readException(Parcel.java:1620)                                                   在android.os.Parcel.readException(Parcel.java:1573)                                                   在com.google.android.instantapps.supervisor.ipc.base.MethodInvocationProxy.readReply(PG:39)                                                   在com.google.android.instantapps.supervisor.ipc.base.MethodInvocationProxy.invoke(PG:130)                                                   在java.lang.reflect.Proxy.invoke(Proxy.java:393)                                                   在$ Proxy5.isCameraSoundForced(未知来源)                                                   在android.hardware.Camera.getCameraInfo(Camera.java:260)                                                   在com.chegg.feature.wizard.camera.CameraActivity.getBackFacingCamera(CameraActivity.java:357)                                                   在com.chegg.feature.wizard.camera.CameraActivity.startCamera(CameraActivity.java:101)                                                   在com.chegg.feature.wizard.camera.CameraActivity.startCameraSafely(CameraActivity.java:79)                                                   在com.chegg.feature.wizard.camera.CameraActivity.onResume(CameraActivity.java:74)                                                   在android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1286)                                                   在android.app.Activity.performResume(Activity.java:6987)                                                   在android.app.ActivityThread.performResumeActivity(ActivityThread.java:4144)                                                   在android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4245)                                                   在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3360)                                                   在android.app.ActivityThread.access $ 1100(ActivityThread.java:221)                                                   在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1794)                                                   在android.os.Handler.dispatchMessage(Handler.java:102)                                                   在android.os.Looper.loop(Looper.java:158)                                                   在android.app.ActivityThread.main(ActivityThread.java:7224)                                                   at java.lang.reflect.Method.invoke(Native Method)                                                   在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1230)                                                   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

4 个答案:

答案 0 :(得分:2)

android.hardware.Camera在API级别21中已被弃用,而Instant Apps仅支持来自API级别23的设备。您需要使用android.hardware.camera2。

https://developer.android.com/reference/android/hardware/camera2/package-summary.html

  

android.hardware.camera2包提供了一个接口   连接到Android设备的各个相机设备。它取代了   不推荐使用的Camera类。

此问题已在https://issuetracker.google.com/issues/38485484中解决 工程师提供以下信息:

  

"即时应用不支持旧的已弃用的android.hardware.Camera。他们只支持camera2 API"

答案 1 :(得分:0)

即时应用程序功能受限,显然不支持该方法。您可以使用InstantApps.isInstantApp()方法确定是安装了还是即时应用,并仅在安装时调用isCameraSoundForced

更多信息:https://developer.android.com/topic/instant-apps/reference.html

答案 2 :(得分:0)

即时应用程序在Android O和以前版本上本机运行,它们使用Google Play服务运行。因此,在API 26之前的即时应用程序中不支持相机1,因为它们不是本机运行的。但是,您可以在API 26上的即时应用程序中使用Camera 1 api,直到我想象的相机1 api的时间。

但是,我在即时应用中使用了相机2 api,在已安装的应用中使用了相机1 api。

答案 3 :(得分:0)

这是当前实施Google Play服务即时应用支持的错误。

它将在未来版本中修复,此时android.hardware.Camera API应该能够正常运行。

不幸的是,我没有关于修复程序可用时间的具体细节。