At start google-services ver. is classpath \'com.google.gms:google-services:4.1.0\'
, but when I change it to 4.2.0
the error occurs during Sy
@NickUnuchek leave the dependencies block out of the gradle file of your root project, then it will work
In result top level gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'kotlin'
buildscript {
ext.kotlin_version = '1.3.20'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
//region realm
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
//endregion
}
dependencies {
//region google()
classpath 'com.android.tools.build:gradle:3.3.0'
//endregion
//region jcenter()
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.orhanobut.tracklytics:tracklytics-plugin:2.0.0'
//endregion
//region maven { url 'https://maven.fabric.io/public' }
//to check fabric gradle ver
//https://s3.amazonaws.com/fabric-artifacts/public/io/fabric/tools/gradle/maven-metadata.xml
classpath 'io.fabric.tools:gradle:1.+'
//endregion
//region realm
classpath "io.realm:realm-gradle-plugin:5.8.0"
//endregion
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://dl.bintray.com/nickunuchek/maven" }
maven { url "https://jitpack.io" }
}
configurations.all {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jre7'
}
}
dependencies {
//REMOVED FROM TOP-LEVEL implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
app/build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
...
defaultConfig {
...
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "8g"
preDexLibraries = false
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
...
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"//MOVED HERE FROM TOP-LEVEL GRADLE
}
apply plugin: 'com.google.gms.google-services'
I resolved the ArrayIndexOutOfBoundsException by adding the following after applying the google-services plugin at the end of my build script:
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
This disables the version check which is buggy in google-services 4.2.0
I have the same problem when I'm trying to update to com.google.gms:google-services:4.2.0. Deleting the gradle cache also did not help.
The only thing which made the AIOOBE dissapear was completely commenting out the app's maven repo dependencies.
android {
...
dependencies {
// commented out
// implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// this works
implementation fileTree(dir: 'libs/dropbox', includes: ['dropbox*.jar', 'json*.jar'])**
}
}
As you can see in my example, local file dependencies work. However, this is not the solution, maybe only a step in the direction of finding the cause of the error.
After more digging:
It looks like a bug of the google services plugin, and more exactly a bug of the StrictVersionMatcherPlugin which is automatically added with the google play services plugin.
They are checking version of the firebase and play-services libraries and somehow the check runs into an exception. It's a string.indexOf which bugs around.
if (depFromString.startsWith("project ")) {
// TODO(paulrashidi): Figure out if a third level dependency shows depFromString.
// In a project with other project dependencies the dep
// string will be "project :module1"
String depName = depFromString.split(":")[1];
depName is project :
, so split[1]
will fail
the stack-trace hints for the Google Services Gradle plugin:
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at com.google.android.gms.dependencies.DependencyInspector
and you add the plugin: classpath "com.google.gms:google-services:4.2.0"
, but never apply it with: apply plugin: "com.google.gms.google-services"
(this belongs to the bottom of the file).
having no associated Java dependencies might also cause that; for example:
implementation "com.google.android.gms:play-services-base:16.1.0"