Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Circle CI Could not find method google() for arguments [] on repository container

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.

like image 451
midhunhk Avatar asked Mar 05 '23 17:03

midhunhk


2 Answers

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' 
}
like image 81
Kevin Coppock Avatar answered Apr 28 '23 08:04

Kevin Coppock


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.

like image 43
metis Avatar answered Apr 28 '23 08:04

metis