I have a modern Android app that uses Kotlin and Android Architecture Components. I am trying to integrate with Circle CI, but finding Android specific documentation hard to figure out.
What went wrong:
A problem occurred evaluating root project 'message-counter'.
Could not find method google() for arguments [] on repository container.
build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.gms:oss-licenses:0.9.2"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
config.yml
version: 2
jobs: build: docker: # specify the version you desire here - image: circleci/android:api-26-alpha
working_directory: ~/repo
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- checkout
# Download and cache dependencies
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run: gradle androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Run Tests
command: ./gradlew lint test
Any pointers for fixing this issue would be appreciated. Note that I am able to configure and build using Travis CI for the same repository.
The google()
repository shortcut is only available for Gradle 4.1 and higher. Check to ensure that Circle CI is set up to use Gradle 4.1 and later, and that should resolve your issue.
Alternatively, you can directly reference the Google repository using:
maven {
url 'https://maven.google.com'
}
Updating
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
line in gradle-wrapper.properties file to the last version solved the same problem i encountered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With