Camera API issues

Hello again!

We seem to have some issues when using RhoMobile and the Camera API on iOS and Android devices. We access the Camera with either of the following options:

# When the user clicks the "Camera" button, we start the camera

Camera::take_picture( callback_url, {} )

# When the user clicks the "Add file" button, we start it with the file picker.

Camera::choose_picture( callback_url, {} )

# In both cases, the {} is an options hash with the default settings.

This method for starting the camera is documented here: http://docs.rhomobile.com/en/2.2.0/rhodesapi/camera-api

Now we run into 2 different problems. Lets see if we can solve this in one discussion:

Android (RhoStudio 4.0)

Using the "Add file" button with this method makes our app crash. We get the default crash message "<appname>  has crashed" and a close button. The only thing I can retrieve is this log message from the android logcat.

03-11 15:00:32.256: E/AndroidRuntime(27596): FATAL EXCEPTION: main

03-11 15:00:32.256: E/AndroidRuntime(27596): Process: com.viadata.connectit, PID: 27596

03-11 15:00:32.256: E/AndroidRuntime(27596): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.viadata.connectit/com.rhomobile.rhodes.ui.FileList}: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=27596, uid=10097 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.app.ActivityThread.access$800(ActivityThread.java:135)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.os.Handler.dispatchMessage(Handler.java:102)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.os.Looper.loop(Looper.java:136)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.app.ActivityThread.main(ActivityThread.java:5017)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at java.lang.reflect.Method.invokeNative(Native Method)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at java.lang.reflect.Method.invoke(Method.java:515)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at dalvik.system.NativeStart.main(Native Method)

03-11 15:00:32.256: E/AndroidRuntime(27596): Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=27596, uid=10097 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.os.Parcel.readException(Parcel.java:1465)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.content.ContentProviderProxy.query(ContentProviderNative.java:413)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.content.ContentResolver.query(ContentResolver.java:461)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.content.ContentResolver.query(ContentResolver.java:404)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.provider.MediaStore$Images$Media.query(MediaStore.java:778)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at com.rhomobile.rhodes.ui.FileList.getImages(FileList.java:67)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at com.rhomobile.rhodes.ui.FileList.onCreate(FileList.java:94)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.app.Activity.performCreate(Activity.java:5231)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

03-11 15:00:32.256: E/AndroidRuntime(27596):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)

03-11 15:00:32.256: E/AndroidRuntime(27596):     ... 11 more

I think this looks like a permission that is not set in the Android manifest. But shouldnt we have nothing to do with this?

iOS (RhoStudio 2.2 and 4.0)

Whenever a user starts the camera and takes a picture, this picture gets turned sideways and has a huge black square on it. An example would be this:

2014-03-11_13.35.41.jpg

This is a picture taken in an application made with RhoMobile from an iphone, and I can tell that my collegue normally does not look like this

Can anyone provide me with some information about these issues?

Kutir Mobility
Hi Bart,Have you tried to run

Hi Bart,

Have you tried to run the kitchen sink app (apk link and repo link) on your devices ? Is it giving the same results ?

Visnupriya R

Kutir Mobility

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bart Fukkink
Hello Visnupriya,I have just

Hello Visnupriya,

I have just installed the kitchen sink app for Android. And when installing it I see that the application requires the permission to read and modify the storage. However, when we install our application, this is not there in the permission list. Do we have to add things to our Build.yml to add this permission that was not needed in RhoMobile 2.2?

Bart

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Kutir Mobility
Bart,I am not sure about Read

Bart,

I am not sure about Read-Write permission which I can address bit later.

For now, could you please check whether the Camera sample in Kitchen sink is working fine for you ?

Visnupriya R

Kutir Mobility

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bart Fukkink
The camera sample in the

The camera sample in the kitchen sink is working fine on Android indeed

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bart Fukkink
It has been a couple of weeks

It has been a couple of weeks now, do you have any information or tests for me to try and pinpoint the root of this problem?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Mark Ross
Bart,Just saw this as I was

Bart,

Just saw this as I was wrestling with Camera access in 4.0 as well.  I got it working, albeit, for me I'm using javascript only.  You may already have this, but make sure in your build.yml you have:

capabilities:

  - camera


I don't have anything special in my Android section, but just in case, its:


android:

  version: "4.0.2"

  android_title: 0

  capabilities:


So, check that to see if it helps.  I can use the Camera in Android and iOS without issue.  Good luck.


-Mark


Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bart Fukkink
Hello Mark,Thanks for the

Hello Mark,

Thanks for the pointers, but our build.yml is complete and has all the required fields that you mentioned.

Bart

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Rob Richard
Bart:I also have random

Bart:

I also have random Android crashes of my app when attempting to use the camera to take pictures.  I did find, however, that this happens typically on "no-name" brand of Android tablets.  Have you had the same experience?  What brand/model of Android tablets are you using?

Rob

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bart Fukkink
Hello Rob,We are using

Hello Rob,

We are using several high end devices, such as the HTC One (M7) and the Nexus 4. The problems we see occuring there are all due to the fact that not all the correct permissions are set in the Android Manifest file. It is missing the read external storage permission (http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE)

This is not a problem in older versions of Android, but only in Android 4.4 (Kitkat), as can be made out of the note in the Android documentation:

This permission is enforced starting in API level 19.

Bart

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Pietro Francesc...
Hi Bart,RhoMobile Suite v4.1

Hi Bart,

RhoMobile Suite v4.1 has introduced an AndroidManifest template that you can use to add the READ_EXTERNAL_STORAGE permission if this is not already available in this new version.

RMS v4.0 was released before KitKat release.

~Pietro

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bart Fukkink
So Pietro,Do I understand you

So Pietro,

Do I understand you correctly that, everyone who wants to use the FilePicker (that can be found in the Camera API) on Android devices that run Android KitKat and up, have to add the permission READ_EXTERNAL_STORAGE manually?

Or is this fixed in RMS 4.1 and is that added automaticly?

Bart

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bart Fukkink
Seems like this wasn't fixed

Seems like this wasn't fixed automaticly, but we managed to solve the file picker issue by adding the sdcard capability to the Android section of our build.yml:

android:

  capabilities:

    - sdcard

On the camera issues: There where some issues with the resize script that we used for images wich seems to have caused the problems. Due to memory limitations that iOS gives to the smartphone version of their operating system, certain image information can get lost if you redraw the image on a canvas. In the end we turned to the script found here to resolve the issue: stomita/ios-imagefile-megapixel · GitHub

Case closed...

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments