简体   繁体   English

谷歌地图插件科尔多瓦不加载getMap()

[英]google map plugin cordova not load getMap()

Everything worked before. 之前一切正常。 But suddenly it's showing white screen and throwing this below error. 但是突然间它显示白屏,并在错误下方抛出该错误。

getMap is not defined getMap

在此处输入图片说明

在此处输入图片说明

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="'26.0.2'" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=26 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=26 //Integer - We ALWAYS compile with the latest by default
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

The dependency section of platform/android/app/build.gradle is probably like this: platform/android/app/build.gradle的依赖项部分可能像这样:

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: ":CordovaLib"))
    compile "com.google.android.gms:play-services-maps:12.0.0"
    compile "com.google.android.gms:play-services-location:12.0.0"
    compile "com.android.support:support-core-utils:24.1.0"
    compile "com.google.gms:google-services:+"
    compile "com.google.android.gms:play-services-tagmanager:+"
    compile "com.google.firebase:firebase-core:+"
    compile "com.google.firebase:firebase-messaging:+"
    compile "com.google.firebase:firebase-crash:+"
    compile "com.google.firebase:firebase-config:+"
    // SUB-PROJECT DEPENDENCIES END
}

The problem is some plugin specifies + , but the maps plugin specifies 12.0.0 (or maybe other versions) 问题是某些插件指定+ ,但maps插件指定12.0.0 (或其他版本)

The version number + is very danger keyword. 版本号+是非常危险的关键字。 The gradle use the latest version at the build time when you specified + , but it does not work sometimes. 指定+ ,gradle在构建时使用最新版本,但是有时不起作用。 That's why the maps plugin specifies particular version, but you can specify the version with --variable . 这就是为什么maps插件指定特定版本,但是您可以使用--variable指定版本。

You need to modify the build.grale file. 您需要修改build.grale文件。 Specify the same version of all dependencies that use Google Play Services SDK. 指定使用Google Play服务SDK的所有依赖项的相同版本。

For example: 例如:

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: ":CordovaLib"))
    compile "com.google.android.gms:play-services-maps:12.0.1"
    compile "com.google.android.gms:play-services-location:12.0.1"
    compile "com.android.support:support-core-utils:24.1.0"
    compile "com.google.android.gms:play-services-tagmanager:12.0.1"
    compile "com.google.firebase:firebase-core:12.0.1"
    compile "com.google.firebase:firebase-messaging:12.0.1"
    compile "com.google.firebase:firebase-crash:12.0.1"
    compile "com.google.firebase:firebase-config:12.0.1"
    // SUB-PROJECT DEPENDENCIES END
}

By the way com.google.gms:google-services:+ installs all packages. 通过com.google.gms:google-services:+安装所有软件包。 This increases apk file size. 这会增加apk文件的大小。 And it causes troubles. 这会引起麻烦。 I recommend to remove it. 我建议将其删除。

update: Also classpath 'com.google.gms:google-services:3.0.0' should be removed because of the same reason. 更新:同样, classpath 'com.google.gms:google-services:3.0.0'同样的原因,也应删除classpath 'com.google.gms:google-services:3.0.0'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM