Google Drive Plugin Error in device

I was trying the google drive plugin with the example supplied by the developer at

https://github.com/scottrules44/drive-plugin

It doesn’t work in Windows simulator because the webview is not available so I built it for Android without problems.

When I ran it from the phone it asked for the login info and authorization correctly.  But when I tried the request to upload the example file (arrow.png) I get the following error: 

I/Corona  (29726): WARNING: Could not load ‘googleDrive.LuaLoader’

I/Corona  (29726): ERROR: Runtime error

I/Corona  (29726): /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:838: module ‘googleDrive’ not found:resource (googleDrive.lu) does not exist in archive

I/Corona  (29726):      no field package.preload[‘googleDrive’]

I/Corona  (29726):      no file ‘(null)/googleDrive.lua’

I/Corona  (29726):      no file ‘(null)/googleDrive.lua’

I/Corona  (29726):      no file ‘/data/app/cr.enz.drive_plugin_master-1/lib/arm/libgoogleDrive.so’

I/Corona  (29726):      no file ‘./googleDrive.so’

I/Corona  (29726):      no file ‘(null)/googleDrive.so’

I/Corona  (29726):      no file ‘/data/app/cr.enz.drive_plugin_master-1/lib/arm/libgoogleDrive.so’

I/Corona  (29726):      no file ‘./googleDrive.so’

I/Corona  (29726):      no file ‘(null)/googleDrive.so’

I/Corona  (29726): stack traceback:

I/Corona  (29726):      [C]: in function ‘require’

I/Corona  (29726):      /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:838: in function ‘require’

Any ideas?

Is the plugin actived?

https://marketplace.coronalabs.com/plugin/google-drive

Hi Scott,

Yes, the plugin is active.

First I had the same problem reported by gc34 here:

https://forums.coronalabs.com/topic/65160-google-drive/?hl=googledrive

The Corona Simulator (Windows) didn´t find googleDrive.lua. So I checked C:\Users\MYUSER\AppData\Roaming\Corona Labs\Corona Simulator\Plugins and the googleDrive.lua and googleDrive folder with 2 more lua files was inside another folder “plugin”, so I moved those directly to “Plugins” and the Simulator now finds it and the login part works (It opens a browser tab to log in), but I can’t test the request part to upload from the Simulator (I tried setting the drive.Code but when I set it it works as usual opening a browser tab and not getting to show the “Request” button. If I force the Request button to show, I get the message: “not logged in”).   

In the device I get the error showed in the first post.

Thanks!

What version are you using?

^of corona

my bad, 

change this:

local drive = require("googleDrive")

to this

local drive = require("plugin.googleDrive")

sample updated

Thank you Scott

My Corona version: 2016.2906 - Windows

Changed to: local drive = require(“plugin.googleDrive”)

And now I got “Assertion failed!” error when trying the request to upload the example file (arrow.png)

I/Corona  (13621): ERROR: Runtime error

I/Corona  (13621): assertion failed!

I/Corona  (13621): stack traceback:

I/Corona  (13621):      [C]: in function ‘assert’

I/Corona  (13621):      ?: in function ‘getBody’

I/Corona  (13621):      ?: in function ‘requestAndFile’

I/Corona  (13621):      ?: in function ‘request’

I/Corona  (13621):      C:\Users\MYUSR\Documents\Corona Projects\drive-plugin-master\main.lua:40: in function ‘func’

I/Corona  (13621):      /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:186: in function </Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:169>

Any ideas?

what does you code look like i just tested, worked for me

 local fileName = "test.zip" drive.request("https://www.googleapis.com/upload/drive/v3/files/", "POST", function ( e ) print(e.response) end, {uploadType= "multipart"}, {name = fileName}, fileName, system.ResourceDirectory, "application/zip", fileName )

No, I’m using your sample…just uncommented the part for uploading and image:

requestButton.box:addEventListener( "tap", function ( e ) --upload image local fileName = "arrow.png" drive.request("https://www.googleapis.com/upload/drive/v3/files/", "POST", function ( e ) print(e.response) end, {uploadType= "multipart"}, {name = fileName}, fileName, system.ResourceDirectory, "image/png", fileName ) --delete file...

What version of Corona are you using?

Mine is 2016.2906 - Windows

CoronaSDK-2972 mac

Hi Scott,

I get the below error when I run the example at https://github.com/scottrules44/drive-plugin on my device.

I activated the plugin in the corona plugin marketplace.

I see that it is no longer visible on the marketplace however, only google searches bring it up. Is this plugin no longer supported in later versions of corona? I’m using corona Build: 2017.3128 on windows.

I set up the OAuth 2.0 client ID on the google console and have a redirect url, clientSecret and clientID that I set at the top of your example by doing the followoing (I just x’d out the actual keys in order to post here)

       local clientID=“xxxxxxxxxxxxxxxxxxxxxxxxx”
     local clientSecret=“xxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
     local redirectUrl=“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”

     drive.init(clientId, clientSecret, redirectUrl)

this is the error I get on the device (Android):

-10 11:29:03.752 12799 12817 I Corona  : ERROR: Runtime error
-10 11:29:03.752 12799 12817 I Corona  : bad argument #5 to ‘format’ (string expected, got nil)
-10 11:29:03.752 12799 12817 I Corona  : stack traceback:
-10 11:29:03.752 12799 12817 I Corona  :      [C]: ?
-10 11:29:03.752 12799 12817 I Corona  :      [C]: in function ‘format’
-10 11:29:03.752 12799 12817 I Corona  :      ?: in function ‘signInUser’
-10 11:29:03.752 12799 12817 I Corona  :      ?: in function ‘signIn’
-10 11:29:03.752 12799 12817 I Corona  :      ?: in function ‘login’
-10 11:29:03.752 12799 12817 I Corona  :      ?: in function ‘func’
-10 11:29:03.752 12799 12817 I Corona  :      /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:203: in function </Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:190>

Thanks for your help.

John

Yes it is not longer supported by me, I open sourced this plugin a while back. I am actually working on my website now, it be removed from there as well.

https://github.com/scottrules44/google-drive-source

I do have a google sign in plugin now which could help on mobile. Google removed webview base sign in from there api and now requires the sdk to work, which was the main reason I no longer support it. It probably could still work with some reworking with google sign in but I have moved past it

https://marketplace.coronalabs.com/plugin/google-sign-in

Ok thanks Scott for the fast reply, I appreciate it. That’s a shame they changed their api and it breaks our code.  I guess to get your new sign-in plugin to work for uploading files to google drive, I’d have to study up on the google drive api and develop my own solution? Or do you know if it’s just a matter of using your piugin to sign in and then do a simple POST to send the file up to google drive?

Thanks again,

John

I have not tested it in awhile since it is no longer supported you are kind of on your own. If you want to roll your own solution, great. The reason it is no longer supported is that Google changed the way you login in. It should in theory work if you can get an access token from the google sign in a plugin.

Thanks,
Scott

Thanks Scott