之前的一切都有效。但突然之间,它显示白屏并将其抛到错误之下。
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
}
答案 0 :(得分:0)
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
}
问题是某些插件指定+
,但地图插件指定12.0.0
(或者其他版本)
版本号+
是非常危险的关键字。
当您指定+
时,gradle会在构建时使用最新版本,但有时它不起作用。这就是地图插件指定特定版本的原因,但您可以使用--variable
指定版本。
您需要修改build.grale
文件。指定使用Google Play Services SDK的所有依赖项的相同版本。
例如:
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
}
顺便说一下com.google.gms:google-services:+
安装所有包。这会增加apk文件的大小。它会引起麻烦。我建议删除它。
<强>更新强>
由于同样的原因,也应删除classpath 'com.google.gms:google-services:3.0.0'
。