oscarfonts / mapbox-gl-cordova-offline

Offline vector maps in Cordova using Mapbox GL JS
Other
60 stars 36 forks source link

UnhandledPromiseRejectionWarning: Error: spawn EACCES #21

Open cerw opened 6 years ago

cerw commented 6 years ago

Hello,

When I download your repo and run

npm install
cordova platform add android

all seem fine but having issue with :

cordova run android
ANDROID_HOME=/Users/cerw/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
(node:43973) UnhandledPromiseRejectionWarning: Error: spawn EACCES
    at ChildProcess.spawn (internal/child_process.js:330:11)
    at Object.exports.spawn (child_process.js:500:9)
    at Object.exports.spawn (/Users/cerw/Work/slsa/mapbox-gl-cordova-offline-master/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:134:31)
    at GradleBuilder.runGradleWrapper (/Users/cerw/Work/slsa/mapbox-gl-cordova-offline-master/platforms/android/cordova/lib/builders/GradleBuilder.js:78:27)
    at /Users/cerw/Work/slsa/mapbox-gl-cordova-offline-master/platforms/android/cordova/lib/builders/GradleBuilder.js:177:21
    at _fulfilled (/Users/cerw/Work/slsa/mapbox-gl-cordova-offline-master/platforms/android/cordova/node_modules/q/q.js:854:54)
    at self.promiseDispatch.done (/Users/cerw/Work/slsa/mapbox-gl-cordova-offline-master/platforms/android/cordova/node_modules/q/q.js:883:30)
    at Promise.promise.promiseDispatch (/Users/cerw/Work/slsa/mapbox-gl-cordova-offline-master/platforms/android/cordova/node_modules/q/q.js:816:13)
    at /Users/cerw/Work/slsa/mapbox-gl-cordova-offline-master/platforms/android/cordova/node_modules/q/q.js:570:49
    at runSingle (/Users/cerw/Work/slsa/mapbox-gl-cordova-offline-master/platforms/android/cordova/node_modules/q/q.js:137:13)
(node:43973) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:43973) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
npm --version
n5.6.0
node --version
v9.7.1
MacOS: 10.13.3

Any idea? Thanks

bg-wa commented 6 years ago

Did you add the plugins listed in the docs?

cerw commented 6 years ago

I woudl thing running cordova platform add android did the job?


└─(~/Work/slsa/mapbox-gl-cordova-offline-master)─(10 files, 1928b)─> cordova platform add android
Using cordova-fetch for cordova-android@6.3.0
Adding android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Package: co.geomati.mapboxGLCordovaOffline
    Name: Mapbox_GL_Cordova_Offline
    Activity: MainActivity
    Android target: android-26
Subproject Path: CordovaLib
Android project created with cordova-android@6.3.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Installing "cordova-plugin-whitelist" for android

               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

Adding cordova-plugin-whitelist to package.json
Saved plugin info for "cordova-plugin-whitelist" to config.xml
Discovered plugin "cordova-plugin-file" in config.xml. Adding it to the project
Installing "cordova-plugin-file" for android

The Android Persistent storage location now defaults to "Internal". Please check this plugin's README to see if your application needs any changes in its config.xml.

If this is a new application no changes are required.

If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:

      "<preference name="AndroidPersistentFileLocation" value="Compatibility" />"

to config.xml in order for the application to find previously stored files.

Adding cordova-plugin-file to package.json
Saved plugin info for "cordova-plugin-file" to config.xml
Discovered plugin "cordova-sqlite-ext" in config.xml. Adding it to the project
Installing "cordova-sqlite-ext" for android
installing external dependencies via npm
npm install of external dependencies ok
Adding cordova-sqlite-ext to package.json
Saved plugin info for "cordova-sqlite-ext" to config.xml
Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
Installing "cordova-plugin-device" for android
Adding cordova-plugin-device to package.json
Saved plugin info for "cordova-plugin-device" to config.xml
--save flag or autosave detected
Saving android@~6.3.0 into config.xml file ...
bg-wa commented 6 years ago

Yep, looks good! Can you open the project in android studio and run it manually? I feel like I ran into this a while back and it was a problem with gradle. I've got this running successfully on Android, so I can say it does work with the latest version of cordova...

cerw commented 6 years ago

It prompted me to upgrade to Gradle 3.1.0 so doing that now. I will try just create new cordova project and only include the libs and plugins i need. it shoudl compile fine i guess...

cerw commented 6 years ago

Hmm Android Studio did not work either :(

Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018

Configuration 'debugCompile' is obsolete and has been replaced with 'debugImplementation'.
It will be removed at the end of 2018

Configuration 'releaseCompile' is obsolete and has been replaced with 'releaseImplementation'.
It will be removed at the end of 2018

Unable to resolve dependency for ':@debug/compileClasspath': Could not resolve project :CordovaLib.
Open File
Show Details

Unable to resolve dependency for ':@debugAndroidTest/compileClasspath': Could not resolve project :CordovaLib.
Open File
Show Details

Unable to resolve dependency for ':@debugUnitTest/compileClasspath': Could not resolve project :CordovaLib.
Open File
Show Details

Unable to resolve dependency for ':@release/compileClasspath': Could not resolve project :CordovaLib.
Open File
Show Details

Unable to resolve dependency for ':@releaseUnitTest/compileClasspath': Could not resolve project :CordovaLib.
Open File
Show Details
cerw commented 6 years ago

IOS

─(~/Work/slsa/mapbox-gl-cordova-offline-master)─(12 files, 1936b)─> cordova run ios
Discovered platform "ios@4.5.4" in config.xml or package.json. Adding it to the project
Using cordova-fetch for cordova-ios@4.5.4
Adding ios project...
Creating Cordova project for the iOS platform:
    Path: platforms/ios
    Package: co.geomati.mapboxGLCordovaOffline
    Name: Mapbox GL Cordova Offline
iOS project created with cordova-ios@4.5.4
Installing "cordova-plugin-device" for ios
Installing "cordova-plugin-file" for ios
Installing "cordova-plugin-whitelist" for ios
Installing "cordova-sqlite-ext" for ios
installing external dependencies via npm
npm install of external dependencies ok
(node:39454) UnhandledPromiseRejectionWarning: Error: Command failed: xcrun simctl list --json
dyld: Symbol not found: _SimDeviceBootKeyDisabledJobs
  Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/simctl
  Expected in: /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator
 in /Applications/Xcode.app/Contents/Developer/usr/bin/simctl

    at ChildProcess.exithandler (child_process.js:273:12)
    at ChildProcess.emit (events.js:127:13)
    at maybeClose (internal/child_process.js:936:16)
    at Socket.stream.socket.on (internal/child_process.js:353:11)
    at Socket.emit (events.js:127:13)
    at Pipe._handle.close [as _onclose] (net.js:558:12)
(node:39454) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:39454) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
cerw commented 6 years ago

When i craeted new project, and just copy the www over i manage to get it compilied. but now I get Failed to initialize WebG Do you need to run Crosswalk or how do you get it to run ?

bg-wa commented 6 years ago

I didn't need to use crosswalk on Android, but I did change ln.42 from }).then((map) => { to }).then(function(map){

Howver, I'm getting CORS errors on iOS loading the map tiles ( issue #20 )

cerw commented 6 years ago

On IOS the app wont even run just dies after executing it.

No target specified for emulator. Deploying to iPhone-4s, 9.3 simulator
An error was encountered processing the command (domain=FBSOpenApplicationErrorDomain, code=1):
The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 1.)
io.cordova.hellocordova: -1
logPath: /Users/cerw/Work/slsa/mapOfflineCordova/platforms/ios/cordova/console.log

And there is no console.log file either :(

cerw commented 6 years ago

Turns out it's new Xcode 9.3 issue you can make it run using

cordova run ios -l --target="iPhone-X"

!

bg-wa commented 6 years ago

Cool! And are you able to view the map on iOS? I just get an empty map container with controls, but no tiles...

cerw commented 6 years ago

IOS

image

Android image

It seem the Android can not detect WebGL and complains about it, but the WebView def has WebGL support ( goging to http://html5test.com/s/823f29378ed7958e.html show it's ON)

bg-wa commented 6 years ago

Ha, this whole time I was testing iOS on an actual device... when I boot to the emulator (or a newer device) I get the correct results! (UGH... I wasted a whole week on this!!) So I'm testing android on a 7.0 device. What OS version is your android emulator set to?

cerw commented 6 years ago

I am testing Pixel_2_API_26

bg-wa commented 6 years ago

I just tested Pixel_2_API_26 and get your same results... the same code works on my device. is webgl disabled on emulators? I don't have any other android devices to test on right now.

cerw commented 6 years ago

Its not disable use DevTool to go to http://html5test.com/s/823f29378ed7958e.html in the same Cordova WebView and you will see its ON.

cerw commented 6 years ago

I can confirm it works on real device Pixel 1 👍

oscarfonts commented 6 years ago

I just added a comment to the README file stating that the android emulator doesn't display webgl content. Also replaced the arrow function in https://github.com/oscarfonts/mapbox-gl-cordova-offline/blob/master/www/index.html#L42

About the iOS issue. I have little iOS experience and no real device. I understand it has to do with some specific iOS or hardware version, but don't get exactly which ones. Could you state exactly in which environment the error arises and how did you overcome it? Thanks!

bg-wa commented 6 years ago

I'll do some more testing after the weekend, but it looks like iOS 10 is the minimum version (hardware & emulator).