JaneaSystems / nodejs-mobile

Full-fledged Node.js on Android and iOS
https://code.janeasystems.com/nodejs-mobile
Other
2.58k stars 182 forks source link

Build failure with Cordova plugin on Android #138

Open ndarilek opened 6 years ago

ndarilek commented 6 years ago

I create a fresh Cordova project with cordova init, cordova add android, cordova plugin add nodejs-mobile-cordova. Then I create an empty www/node-project/index.js file. Next I run cordova build android and I get the following:

Android Studio project detected
Android Studio project detected
Android Studio project detected
Android Studio project detected
Android Studio project detected
Android Studio project detected
ANDROID_HOME=/sysroot/home/nolan/opt/android
JAVA_HOME=/sysroot/home/nolan/.asdf/installs/java/oracle-8.181/
studio
Subproject Path: CordovaLib
Subproject Path: CordovaLib
Subproject Path: CordovaLib
Subproject Path: app
Subproject Path: app
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
    at build_2mwkmnx773om9lrjjbfg464fq.run(/sysroot/home/nolan/Projects/Waynav/waynav/test/platforms/android/app/build.gradle:144)
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:checkDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:javaPreCompileDebug UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:generateJsonModelDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:generateJsonModelDebug'.
> File '/sysroot/home/nolan/Projects/Waynav/waynav/test/platforms/android/app/src/com/janeasystems/cdvnodejsmobile/jni/CMakeLists.txt' specified for property 'externalNativeJsonGenerator.makefile' does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
28 actionable tasks: 1 executed, 27 up-to-date
/sysroot/home/nolan/Projects/Waynav/waynav/test/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:generateJsonModelDebug'.
> File '/sysroot/home/nolan/Projects/Waynav/waynav/test/platforms/android/app/src/com/janeasystems/cdvnodejsmobile/jni/CMakeLists.txt' specified for property 'externalNativeJsonGenerator.makefile' does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

This happens on both a newly-created project and on a project to which I'm attempting to add this plugin. I created a test project at https://github.com/ndarilek/cordova-nodejs-mobile-failure that demonstrates the issue.

Thanks!

jaimecbernardo commented 6 years ago

Hi @ndarilek , I suspect the reason is that your project is created with cordova 8, which is not supported: https://github.com/janeasystems/nodejs-mobile-cordova#requirements

ndarilek commented 6 years ago

Yeah, I'd read that 8 isn't supported. Is my Cordova version what I get from cordova -v, or the major version of the platform in package.json? In my case I see:


         "cordova-android": "^7.1.1",

So I assumed I was on 7. Is it the CLI tool rather than the platform major version that determines I'm on 8 rather than 7?

jaimecbernardo commented 6 years ago

Cordova 8.X tools install cordova-android 7.X Cordova 7.X tools install cordova-android 6.X

cordova-android 7.X is not supported

ndarilek commented 6 years ago

Got it. I wonder if the installation process might be modified to check for this? I knew that 7 wasn't supported, but am fairly new to Cordova, and thought that the 7 in the Android platform version was also Cordova's version.

Also, are there plans to upgrade to 8? I'm starting a new project because I specifically need nodejs-mobile, and notice that 7 is a year behind. Maybe Cordova isn't the best choice if my primary drivers is a need to use Nodejs-mobile?

Thanks.

jaimecbernardo commented 6 years ago

Hi @ndarilek ,

A workaround has been proposed on a similar issue, for using more recent versions of cordova android: https://github.com/janeasystems/nodejs-mobile/issues/48#issuecomment-366858320

No ETA for upgrading to cordova 8 at the moment.

The best approach depends on your application needs. There's also a react-native plugin and the standalone native library, but the standalone native library leaves more integration details to the developer.