nativescript-cordova-support icon indicating copy to clipboard operation
nativescript-cordova-support copied to clipboard

Cannot make cordova-plugin-intercom work

Open jpfortin opened this issue 6 years ago • 3 comments

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$

jpfortin avatar May 27 '19 20:05 jpfortin

Any help would be appreciated, thanks!

jpfortin avatar Jun 11 '19 13:06 jpfortin

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.xml is wrong, but you can define pushType directly 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")
    }
  • cdvCompileSdkVersion and cdvBuildToolsVersion are 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]()

Note that I was just able to build the intercom plugin and I haven't tested any of its features.

TomaNikolov avatar Jun 13 '19 15:06 TomaNikolov

Thank you very much @TomaNikolov! I'll try that :).

jpfortin avatar Jun 13 '19 15:06 jpfortin