nativescript-cordova-support
nativescript-cordova-support copied to clipboard
I am doing an experiment with this nativescript-cordova-support plugin to use with Azure Mobile Apps Cordova plugin
I am trying to do a sample for performing offline data sync with Azure Mobile App Service.
The below are the dependencies in my package.json
"dependencies": {
"cordova-nativescript-plugin": "file:cordova-nativescript-plugin",
"cordova-plugin-inappbrowser": "1.5.0",
"cordova-plugin-ms-azure-mobile-apps": "2.0.2",
"cordova-plugin-whitelist": "1.3.3",
"cordova-sqlite-ext": "2.2.0",
"cordova-sqlite-storage": "2.2.0",
"cordova-sqlite-storage-dependencies": "1.2.0",
"cordova-sqlite-ext-deps": "1.1.0",
"nativescript-theme-core": "~1.0.4",
"tns-core-modules": "~4.0.0"
},
I have set the mimimum sdk Version to 19 as suggested by cordova-plugin-ms-azure-mobile-apps documentation in AndroidManifest.xml
On running tns build android it fails with the below exception. The following folders are created in the platform folder.
- Android
- Cordova
- TempPlugin
Failed to build plugin cordova-nativescript-plugin :
Error: Command gradlew.bat failed with exit code 1 Error output:
..\platforms\tempPlugin\cordova_nativescript_plugin\src\main\java\com\microsoft\windowsazure\mobileservices\cordova\MobileServices.java:18: error: cannot find symbol
import org.apache.cordova.CallbackContext;
^
symbol: class CallbackContext
location: package org.apache.cordova
..\platforms\tempPlugin\cordova_nativescript_plugin\src\main\java\com\microsoft\windowsazure\mobileservices\cordova\MobileServices.java:19: error: cannot find symbol
import org.apache.cordova.CordovaArgs;
^
symbol: class CordovaArgs
location: package org.apache.cordova
..\platforms\tempPlugin\cordova_nativescript_plugin\src\main\java\com\microsoft\windowsazure\mobileservices\cordova\MobileServices.java:20: error: cannot find symbol
import org.apache.cordova.CordovaPlugin;
^
symbol: class CordovaPlugin
location: package org.apache.cordova
..\platforms\tempPlugin\cordova_nativescript_plugin\src\main\java\com\microsoft\windowsazure\mobileservices\cordova\MobileServices.java:21: error: cannot find symbol
import org.apache.cordova.PluginResult;
^
symbol: class PluginResult
location: package org.apache.cordova
..\platforms\tempPlugin\cordova_nativescript_plugin\src\main\java\com\microsoft\windowsazure\mobileservices\cordova\MobileServices.java:22: error: package org.apache.cordova.PluginResult does not exist
import org.apache.cordova.PluginResult.Status;
^
...\platforms\tempPlugin\cordova_nativescript_plugin\src\main\java\com\microsoft\windowsazure\mobileservices\cordova\MobileServices.java:30: error: cannot find symbol
public class MobileServices extends CordovaPlugin {
^
symbol: class CordovaPlugin
...\platforms\tempPlugin\cordova_nativescript_plugin\src\main\java\com\microsoft\windowsazure\mobileservices\cordova\MobileServices.java:35: error: cannot find symbol
private CallbackContext resultContext;
location: class SQLiteConnectorDatabase
...\platforms\tempPlugin\cordova_nativescript_plugin\src\main\java\io\sqlc\SQLitePlugin.java:61: error: method does not override or implement a method from a supertype
@Override
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
100 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full
insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
To verify the plugin I performed the below using cordova
cordova create hello com.example.hello HelloWorld
Navigate to hello folder and run the below
cordova platform add android
cordova plugin add cordova-plugin-ms-azure-mobile-apps
cordova build android
It builds properly.
I verified the build.gradle settings in cordova project under path (C:\CordovaProjects\hello\platforms\android\app) . It had the below entries.
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
compile "com.microsoft.azure:azure-mobile-android:3.4.0@aar"
compile "com.google.code.gson:gson:2.3"
// SUB-PROJECT DEPENDENCIES END
}
Verified the build.gradle file under NativeScript project (C:\NativeScriptProjects\DataProject\platforms\tempPlugin\cordova_nativescript_plugin) .
It had the below entries.
dependencies {
def supportVer = "27.0.1"
if (project.hasProperty("supportVersion")) {
supportVer = supportVersion
}
compileOnly "com.android.support:support-v4:$supportVer"
compileOnly "com.android.support:appcompat-v7:$supportVer"
}
dependencies {
compile "com.microsoft.azure:azure-mobile-android:3.4.0@aar"
compile "com.google.code.gson:gson:2.3"
}
It looks like the required project class files are not referenced from the nativescript generated cordova temp plugin folder.
There is a nativescript version of azure mobile apps plugin but it does not include offline sync capability.