Reputation: 4837
I'm getting the following error when calling Camera.open(cameraIndex) (Camera 1 API)
MethodInvocationProxy : Exception while calling method public abstract boolean android.media.IAudioService.isCameraSoundForced() throws android.os.RemoteException java.lang.SecurityException: Method class android.media.IAudioService$Stub$Proxy.isCameraSoundForced[] not available to instant apps
06-18 10:23:43.361 26240-26359/? E/Isotope: UID: [10185] PID: [26240] MethodInvocationStub : Exception while calling method isCameraSoundForced java.lang.SecurityException: Method class android.media.IAudioService$Stub$Proxy.isCameraSoundForced[] not available to instant apps at com.google.android.instantapps.supervisor.ipc.proxies.SandboxEnforcer.enforceUnsupportedPolicy(PG:63) at com.google.android.instantapps.supervisor.ipc.proxies.SandboxEnforcer.enforceUnsupportedMethodPolicy(PG:17) at com.google.android.instantapps.supervisor.ipc.ProxyMethodHandler.handleMethod(PG:50) at com.google.android.instantapps.supervisor.ipc.base.MethodInvocationStub.onTransact(PG:56) at android.os.Binder.execTransact(Binder.java:453) 06-18 10:23:43.361 26274-26274/? E/Isotope: UID: [99000] PID: [26274] MethodInvocationProxy : Exception while calling method public abstract boolean android.media.IAudioService.isCameraSoundForced() throws android.os.RemoteException java.lang.SecurityException: Method class android.media.IAudioService$Stub$Proxy.isCameraSoundForced[] not available to instant apps at android.os.Parcel.readException(Parcel.java:1620) at android.os.Parcel.readException(Parcel.java:1573) at com.google.android.instantapps.supervisor.ipc.base.MethodInvocationProxy.readReply(PG:39) at com.google.android.instantapps.supervisor.ipc.base.MethodInvocationProxy.invoke(PG:130) at java.lang.reflect.Proxy.invoke(Proxy.java:393) at $Proxy5.isCameraSoundForced(Unknown Source) at android.hardware.Camera.getCameraInfo(Camera.java:260) at com.chegg.feature.wizard.camera.CameraActivity.getBackFacingCamera(CameraActivity.java:357) at com.chegg.feature.wizard.camera.CameraActivity.startCamera(CameraActivity.java:101) at com.chegg.feature.wizard.camera.CameraActivity.startCameraSafely(CameraActivity.java:79) at com.chegg.feature.wizard.camera.CameraActivity.onResume(CameraActivity.java:74) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1286) at android.app.Activity.performResume(Activity.java:6987) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4144) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4245) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3360) at android.app.ActivityThread.access$1100(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Upvotes: 0
Views: 1033
Reputation: 18137
This is a bug in the current implementation of Google Play Services support of instant apps.
It will be fixed in a future release, at which point the android.hardware.Camera API should function correctly.
Unfortunately I don't have any specifics on the timeframe of the fix being available.
Upvotes: 0
Reputation: 3717
Instant apps run natively on Android O and on previous versions, they use google play services to run. So camera 1 is not supported in instant apps prior to API 26 as they don't run natively. However, you can use Camera 1 api in an instant app on API 26 and till the time Camera 1 api lives I would imagine.
However, I'm using camera 2 api in the instant app and camera 1 api in the installed app.
Upvotes: 0
Reputation: 591
android.hardware.Camera was deprecated in API level 21, while Instant Apps support devices only from API level 23. You need to use android.hardware.camera2 instead.
https://developer.android.com/reference/android/hardware/camera2/package-summary.html
The android.hardware.camera2 package provides an interface to individual camera devices connected to an Android device. It replaces the deprecated Camera class.
This issue was addressed in https://issuetracker.google.com/issues/38485484 where Engineers provided the following information:
"Instant apps don't support the old deprecated android.hardware.Camera. They only support the camera2 APIs"
Upvotes: 2
Reputation: 2677
Instant apps have restricted functionality, obviously that method is not supported. You can use InstantApps.isInstantApp()
method to determine whether it is installed or instant app and call isCameraSoundForced
only for installed.
More info: https://developer.android.com/topic/instant-apps/reference.html
Upvotes: 0