Search code examples
androidiostypescriptcordovababylonjs

Cordova Web App


I'm trying to make an apk of the web app I made in babylonjs.

From my understanding you can use Cordova to convert a web app into an apk. I was able to install Cordova and make its hello world apk download to my phone and open and run it just fine.

However my problem occurs when I put all of my web app files into the www folder in my Cordova project folder. After I do that Cordova gives me this error

Error: ENOENT: no such file or directory, stat '/Users/dylan/practiceApk/www/node_modules/.bin/nopt'


when I try to build the android version.

Here is some information about my setup I believe is relevant.

OS: Mac

cordova -v: 7.1.0

Cordova requirements: Requirements check results for android: Java JDK: installed 1.8.0 Android SDK: installed true Android target: installed android-26,android-24 Gradle: installed /Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle


cordova info also gives this error(similar error I believe to the one above):

Error retrieving Android platform information:

Android SDK is not set up properly. Make sure that the Android SDK 'tools' and 'platform-tools' directories are in the PATH variable.

Error: android: Command failed with exit code ENOENT


But I tried a lot of different things to fix this. Most of them involved making the android tools in the path (er something..?) I also downgraded from the most recent version of Cordova and android. I believe the problem is in my web app node_modules/.bin/nopt But I don't know why its is a problem.

Also im not sure how this affects it, but I'm not hosting the website anywhere I just assumed I can used Cordova to create the web app as an apk that could be used offline, all resource are in the project folder though.

Any ideas on how to fix this? I only started using Cordova today so I don't know much about it. Thanks for your time!

Update: I tried building an iOS version and I get the same error. I believe this is an issue with my npm setup...


Solution

  • It seems that when I was copying over my project to the newly made Cordova project folder I also copied the node_modules folder and didn't actually initialize npm. After initializing it and then updating it would build the app.