ISSUE CAMERA CRASH


#1

Version fuse and so

fuse v1.5.0 mac sierra hight

What do I expect?

I expect the URL of the photo to be printed on the console correctly when i use takephoto of Fuse.Camera Module

What’s going on?

An exception thrown System.err: android.os.FileUriExposedException. This happens with Android versions > = 8.0. With earlier versions and with iOS it works properly.
I have noticed that the cause is having added these specs in the project file:

"Android": {
    "SDK": {
      "BuildToolsVersion": "25.0.3",
      "CompileVersion": 25,
      "MinVersion": 16,
      "TargetVersion": 25
    }
  }

Reproduce the issue

Mainview.ux

<App>
	<JavaScript>
		
		var camera = require('FuseJS/Camera');
		var cameraRoll = require("FuseJS/CameraRoll");

		function takePhoto(){
			console.log("take photo");
			camera.takePicture(1920, 1080).then(function(newImage) {
		//HERE CRASH 
				console.log(newImage.path);
				}).catch(function(error) {
					cameraRoll.getImage().then(function(imageRoll) {
					console.log(imageRoll.path);
					}.bind(this),
						function(error) {
							console.log("error", JSON.stringify(error));
						});
			});
		}
		module.exports={takePhoto:takePhoto}
	</JavaScript>

	<Button Clicked="{takePhoto}" Text="Take photo"/>
</App>

*.unoproj

{
  "RootNamespace":"",
  "Packages": [
    "Fuse",
    "FuseJS",
    "Fuse.Camera",
    "Fuse.CameraRoll"
  ],
  "Includes": [
    "*"
  ],
  "Android": {
    "SDK": {
      "BuildToolsVersion": "25.0.3",
      "CompileVersion": 25,
      "MinVersion": 16,
      "TargetVersion": 25
    }
  }
}

EXCEPTION

System.err: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.sandos.precheckin/cache/images/IMG_696f3530-2789-419a-aa44-1f9a788925b9.jpg exposed beyond app through ClipData.Item.getUri()

01-09 18:23:22.701 22775 22775 W System.err: at android.os.StrictMode.onFileUriExposed(StrictMode.java:1960)
01-09 18:23:22.701 22775 22775 W System.err: at android.net.Uri.checkFileUriExposed(Uri.java:2348)
01-09 18:23:22.701 22775 22775 W System.err: at android.content.ClipData.prepareToLeaveProcess(ClipData.java:942)
01-09 18:23:22.701 22775 22775 W System.err: at android.content.Intent.prepareToLeaveProcess(Intent.java:9850)
01-09 18:23:22.701 22775 22775 W System.err: at android.content.Intent.prepareToLeaveProcess(Intent.java:9835)
01-09 18:23:22.701 22775 22775 W System.err: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1610)
01-09 18:23:22.702 22775 22775 W System.err: at android.app.Activity.startActivityForResult(Activity.java:4487)
01-09 18:23:22.702 22775 22775 W System.err: at android.app.Activity.startActivityForResult(Activity.java:4445)
01-09 18:23:22.702 22775 22775 W System.err: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:842)
01-09 18:23:22.702 22775 22775 W System.err: at com.foreign.Android.ActivityUtils.StartForResultJava72(ActivityUtils.java:55)
01-09 18:23:22.702 22775 22775 W System.err: at com.Bindings.ExternedBlockHost.StartForResultJava72(ExternedBlockHost.java:416)
01-09 18:23:22.702 22775 22775 W System.err: at com.Bindings.ExternedBlockHost.callUno_Uno_Permissions_Permissions_Succeeded60(Native Method)
01-09 18:23:22.702 22775 22775 W System.err: at com.foreign.Uno.Permissions.Permissions.permissionRequestSucceeded(Permissions.java:33)
01-09 18:23:22.702 22775 22775 W System.err: at com.Bindings.ExternedBlockHost.permissionRequestSucceeded(ExternedBlockHost.java:364)
01-09 18:23:22.703 22775 22775 W System.err: at com.fuse.Permissions.onRequestPermissionsResult(Permissions.java:93)
01-09 18:23:22.703 22775 22775 W System.err: at com.fuse.App.onRequestPermissionsResult(App.java:260)
01-09 18:23:22.703 22775 22775 W System.err: at com.sandos.precheckin.SandosCheckin.onRequestPermissionsResult(SandosCheckin.java:133)
01-09 18:23:22.703 22775 22775 W System.err: at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7419)
01-09 18:23:22.703 22775 22775 W System.err: at android.app.Activity.dispatchActivityResult(Activity.java:7270)
01-09 18:23:22.703 22775 22775 W System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:4264)
01-09 18:23:22.703 22775 22775 W System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312)
01-09 18:23:22.703 22775 22775 W System.err: at android.app.ActivityThread.-wrap19(Unknown Source:0)
01-09 18:23:22.703 22775 22775 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644)
01-09 18:23:22.703 22775 22775 W System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
01-09 18:23:22.704 22775 22775 W System.err: at android.os.Looper.loop(Looper.java:164)
01-09 18:23:22.704 22775 22775 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6494)
01-09 18:23:22.704 22775 22775 W System.err: at java.lang.reflect.Method.invoke(Native Method)
01-09 18:23:22.704 22775 22775 W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
01-09 18:23:22.704 22775 22775 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)))))

#2

Thanks for an excellent bug report! I’ve now raised a ticket.


#3

Is there something new?
I have got a complete app, and everything is running (when I dont set TargetVersion). But when I set the TargetVersion to 26 it crashes on using the camera with following code:

08-04 00:58:00.737  4130  4212 W System.err: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/..../cache/images/IMG_926fc6ac-219e-4e73-bba5-40c001974bec.jpg exposed beyond app through ClipData.Item.getUri()
08-04 00:58:00.738  4130  4212 W System.err: 	at android.os.StrictMode.onFileUriExposed(StrictMode.java:1958)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.net.Uri.checkFileUriExposed(Uri.java:2361)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.content.ClipData.prepareToLeaveProcess(ClipData.java:941)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.content.Intent.prepareToLeaveProcess(Intent.java:9745)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.content.Intent.prepareToLeaveProcess(Intent.java:9730)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1611)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.app.Activity.startActivityForResult(Activity.java:4472)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:67)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.app.Activity.startActivityForResult(Activity.java:4430)
08-04 00:58:00.739  4130  4212 W System.err: 	at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:720)
08-04 00:58:00.739  4130  4212 W System.err: 	at com.foreign.Android.ActivityUtils.StartForResultJava75(ActivityUtils.java:55)
08-04 00:58:00.739  4130  4212 W System.err: 	at com.Bindings.ExternedBlockHost.StartForResultJava75(ExternedBlockHost.java:431)
08-04 00:58:00.741  4130  4212 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7 in tid 4212 (Thread-3)

#4

Sorry for spaming! But I really need your help!
I need to publish my app, but with this issue it is not useful :speak_no_evil::-1:t3:


#5

Hello! Since Google requires a newer SDK version since August, we can’t publish apps using takePhoto to the Google Play Store anymore. Also getImage on iOS has issues, so working with images from the user’s device is really a problem. I also hope someone could find a solution to this issue…


#6

Issue happens when using the Share module too.


#7

Thanks Casey! But this doesn´t work for me :speak_no_evil:


#8

Hi @treviz, I was just saying that I got the same error when I was using the shareFile() method from the Share module.


#9

I guess that’s the way solve this, but my expertise ends with Java and Android. Could someone help implementing this?


#10

I think this issue appers on more Project then ours?
Is there No one who has solved this Problem or could help? :speak_no_evil:


#11

Hi all,

I have fixed this issue and all issues related i will create PR for all soon :wink:


#12

You are my hero :grimacing: I stay tuned :ok_hand:t3:


#13

I dont want you to hurry, just want to ask: Do you know when I can See the PR? :slight_smile:


#14

Thank you Ahmed! Can’t wait :+1:


#15

I will create the PR by this night :wink:


#16

I am so nervous :sweat_smile::eyes::tada::sunglasses::stuck_out_tongue_closed_eyes::grimacing:


#17

This is the Place where I can find it then, right? :slight_smile:


#18

I think the update will be in the Fuselibs.


#19

someone managed to solve this, I have the same problem, after setting TargetVersion to 26 the camera stopped. Help me.


#20

Hello!
treviz told me that he fixed the issue with this:
MyFuseCamera.zip (9.2 KB)