离子cordova如何运行android?

时间:2018-11-27 06:02:44

标签: cordova ionic-framework

在项目类型中 离子科尔多瓦运行android

错误消息是:

Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
For input string: "+"

cordova_plugin_firebase-build.gradle中的代码是:

buildscript {
repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:+'
    classpath 'com.google.gms:google-services:3.2.0'
}

}

project.properties中的代码是:

target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.gradle.include.1=cordova-android-support-gradle-release/cordova_plugin_firebase-cordova-android-support-gradle-release.gradle
cordova.system.library.1=com.android.support:support-v4:+
cordova.system.library.2=com.android.support:support-v4:25.+
cordova.system.library.3=com.android.support:appcompat-v7:25.+
cordova.gradle.include.2=cordova-plugin-firebase/cordova_plugin_firebase-build.gradle
cordova.system.library.4=com.google.android.gms:play-services-tagmanager:+
cordova.system.library.5=com.google.firebase:firebase-core:+
cordova.system.library.6=com.google.firebase:firebase-messaging:+
cordova.system.library.7=com.google.firebase:firebase-config:+
cordova.system.library.8=com.google.firebase:firebase-perf:+
cordova.system.library.9=com.android.support:support-annotations:27.+
cordova.gradle.include.3=cordova-support-google-services/cordova_plugin_firebase-build.gradle
cordova.gradle.include.4=phonegap-plugin-multidex/cordova_plugin_firebase-multidex.gradle
cordova.system.library.10=com.android.support:support-v13:27.+
cordova.system.library.11=me.leolin:ShortcutBadger:1.1.17@aar
cordova.system.library.12=com.google.firebase:firebase-messaging:11.6.2

问题出在哪里?

谢谢。

2 个答案:

答案 0 :(得分:0)

我的cordova项目也遇到了同样的问题,请尝试通过Google Play Services(用户1.1.0版)对使用特殊Push-Plugin的插件进行兼容性检查,如果可以共享插件版本,我可以提供更多帮助。尝试使用以下版本,它解决了我的问题。而且不要包括依赖项多重边框检查6和12。

 com.google.firebase:firebase-messaging:15.0.2

答案 1 :(得分:0)

.. \ platforms \ android \ cordova-plugin-firebase 更改代码cordova_plugin_firebase-build

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:4.1.0'
    }
}
repositories {
    mavenCentral()
    maven {
        url "https://maven.google.com"
    }
}

dependencies {
    compile 'me.leolin:ShortcutBadger:1.1.4@aar'
    compile 'com.google.firebase:firebase-auth:16.0.5'
    compile('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
       transitive = true
    }
}

cdvPluginPostBuildExtras.add({
    apply plugin: 'com.google.gms.google-services'
    apply plugin: 'io.fabric'
})

classpath 'com.android.tools.build:gradle:2.2.1'

.. \ platforms \ android \ cordova-support-google-services 并更改代码为:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:3.2.0'
    }
}

// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
ext.postBuildExtras = {
   // apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

classpath 'com.android.tools.build:gradle:2.2.1'

并更改

target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.gradle.include.1=cordova-android-support-gradle-release/cordova_plugin_firebase-cordova-android-support-gradle-release.gradle
cordova.system.library.1=com.android.support:support-v4:24.1.1      
cordova.system.library.2=com.android.support:support-v4:25.1.1
cordova.system.library.3=com.android.support:appcompat-v7:25.1.1
cordova.gradle.include.2=cordova-plugin-firebase/cordova_plugin_firebase-build.gradle
cordova.system.library.4=com.google.android.gms:play-services-tagmanager:16.0.4
cordova.system.library.5=com.google.firebase:firebase-core:16.0.4
cordova.system.library.6=com.google.firebase:firebase-messaging:17.3.4
cordova.system.library.7=com.google.firebase:firebase-config:16.1.0
cordova.system.library.8=com.google.firebase:firebase-perf:16.2.0
cordova.system.library.9=com.android.support:support-annotations:27.1.1
cordova.gradle.include.3=cordova-support-google-services/cordova_plugin_firebase-build.gradle
cordova.gradle.include.4=phonegap-plugin-multidex/cordova_plugin_firebase-multidex.gradle
cordova.system.library.10=com.android.support:support-v13:27.1.1
cordova.system.library.11=me.leolin:ShortcutBadger:1.1.17@aar
cordova.system.library.12=com.google.firebase:firebase-messaging:17.3.4