Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Trying to learn camera access, getting an error even on the tutorial code...
Started by Ryan Abrahams Aug 19 2019 10:13 PM

1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Ryan Abrahams

[GLOBAL: userInfoPane.html]
Ryan Abrahams
  • Observer

  • 5 posts
  • Corona SDK

Hi All,

 

I have created a separate project that contains ONLY the code from the tutorial on the docs.

local onComplete = function( event )
    print( "Returned from camera view." )
end
 
local hasAccessToCamera, hasCamera = media.hasSource( media.Camera )
 
if ( hasAccessToCamera == true ) then
    -- There is access to the camera
    media.capturePhoto( { listener = onComplete } )
elseif ( hasCamera == true and native.canShowPopup( "requestAppPermission" ) ) then
    -- A camera exists, but there is no access to it!
    native.showPopup( "requestAppPermission", { appPermission="Camera" } )
else
    native.showAlert( "Corona", "This device does not have a camera.", { "OK" } )
end

My android build settings are as follows:

settings =
{
    android =
    {
        usesPermissions =
        {
            "android.permission.CAMERA",
            "android.permission.WRITE_EXTERNAL_STORAGE",
        },
    },
}

I compiled this to android, uploaded the apk to my device to test, and debugged through ADB. When running the app, it is requesting access for camera, but goes no further. Message on ADB log console is:

08-20 14:00:36.427 22645 22678 V Corona  : > Class.forName: shared.google.play.services.base.LuaLoader
08-20 14:00:36.457 22645 22678 V Corona  : > Class.forName: CoronaProvider.licensing.google.LuaLoader
08-20 14:00:36.457 22645 22678 V Corona  : < Class.forName: CoronaProvider.licensing.google.LuaLoader
08-20 14:00:36.464 22645 22678 V Corona  : Loading via reflection: CoronaProvider.licensing.google.LuaLoader
08-20 14:00:36.466 22645 22678 V Corona  : > Class.forName: _CoronaSetup.LuaLoader
08-20 14:00:39.336 22645 22645 D Corona  : Execute the lua listener task
08-20 14:00:39.340 22645 22645 I Corona  : ERROR: CoronaActivity.DefaultRequestPermissiosnResultHandler.forwardRequestPermissionsResultToLua():Cannot forward results to Lua as no registry ID was found!

Line seven seems to be the pertinent issue.

 

Is there something simple I have missed? This is purely the code straight from the tutorial site, I've not changed anything else.

 

 

Regards,

Ryan Abrahams



[TOPIC: post.html]
#2

Ryan Abrahams

[GLOBAL: userInfoPane.html]
Ryan Abrahams
  • Observer

  • 5 posts
  • Corona SDK

Have found solution via: https://github.com/coronalabs/samples-coronasdk/blob/master/Media/Camera/main.lua

 

So if you are also new, and also having this issue, (as I googled this error and found three results total) the code above is pretty easy to follow to implement camera functionality properly.




[topic_controls]
[/topic_controls]