nativescript-cordova-support
nativescript-cordova-support copied to clipboard
Cannot make cordova-plugin-intercom work
Hi! I receive the following error when trying to build or run my app. I followed all the instructions, got the message your plugin was installed successfully using both methods, followed instructions in the Troubleshooting section and downgraded npm.
Thanks for helping!
test-jack$ tns build android
Copying template files...
Platform android successfully added. v4.2.0
Executing before-prepare hook from /Users/jack/sources/test-jack/hooks/before-prepare/nativescript-cordova-support.js
Creating temporary Cordova project in /var/folders/jj/wgl0g4_x3mgf6xcmw_751scm0000gn/T/cordova-project119427-18623-o7y73j.ytdii/myProject...
Creating a new cordova project.
Using cordova-fetch for cordova-android@~7.1.1
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: zzz123zzz.zzz123zzz.zzz123zzz
Name: HelloCordova
Activity: MainActivity
Android target: android-27
Android project created with [email protected]
Android Studio project detected
Android Studio project detected
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
--save flag or autosave detected
Saving android@~7.1.4 into config.xml file ...
Adding plugin cordova-plugin-intercom...
Installing "cordova-plugin-intercom" for android
Android Studio project detected
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-intercom to package.json
Saved plugin info for "cordova-plugin-intercom" to config.xml
Running 'cordova prepare android'...
Android Studio project detected
Cannot read property 'attrib' of null
Execution of command 'node /Users/jack/sources/test-jack/node_modules/cordova/bin/cordova prepare android' failed.
stdout:
null
stderr:
null
test-jack jack$
Any help would be appreciated, thanks!
Hi @jpfortin,
The changes in https://github.com/NativeScript/nativescript-cordova-support/pull/9 seem to fix your issue. However, if you wont to use cordova-plugin-intercom with nativescript-cordova-support you will need to make some changes in intercom.gradle and build-extras-intercom.gradle of the intercom.
ext {
pushType = ''
new XmlSlurper().parse(file('../app/src/main/res/xml/config.xml')).preference.each {
if ([email protected]() == 'intercom-android-push-type') {
pushType = [email protected]().toLowerCase()
}
}
}
- The path to the
config.xmlis wrong, but you can definepushTypedirectly in the gradle file and skip the xml parse.
if (cdvCompileSdkVersion != null && cdvCompileSdkVersion =~ /.*(1[6-9]|2[0-6])$/) {
logger.error("${errorPrefix()} cdvCompileSdkVersion = ${cdvCompileSdkVersion}. \n" +
"You need to use a cdvCompileSdkVersion of at least 27.\n" +
"See here for more: ${guideUrl()}\n")
}
if (cdvBuildToolsVersion != null && cdvBuildToolsVersion =~ /(1[6-9]|2[0-6])\..+$/) {
logger.error("${errorPrefix()} cdvBuildToolsVersion = ${cdvBuildToolsVersion}. \n" +
"You need to use a cdvBuildToolsVersion of at least 27.0.0.\n" +
"See here for more: ${guideUrl()}\n")
}
cdvCompileSdkVersionandcdvBuildToolsVersionare not present in the nativescript gradle project.
// Uses the app id as a prefix (instead of com.google.android). This prevents
// INSTALL_FAILED_CONFLICTING_PROVIDER error when installing the app.
//
// @link https://issues.apache.org/jira/browse/CB-10014
def manifest = new XmlSlurper().parse(file("src/main/AndroidManifest.xml"))
android.defaultConfig.applicationId [email protected]()
- You will get this error
Library projects cannot set applicationid. The reason is that we create a library project and add it to the nativescript project. By design you cannot useapplicationIdto customize the package of a library project.
Note that I was just able to build the intercom plugin and I haven't tested any of its features.
Thank you very much @TomaNikolov! I'll try that :).