Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "ERROR: Could not find method google() for arguments [] on repository container." in android studio 3.5

I am trying to build and android project from an imported android source code; but each time I try building, I get this >> "ERROR: Could not find method google() for arguments [] on repository container". How do I fix it

I recently converted my Web Application to a Native android app via goNative.io; of which it built an apk I can install on my phone and the android source code. on building the project in my android studio, I get the error >> "ERROR: Could not find method google() for arguments [] on repository container". The bug was traced to my build.gradle. Here is what it looks like

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        //classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

I expected a "Build Successful" message so that I can upgrade my API Level to 28 the rebuild back to apk so that I can finally publish on google play store. Please help fellas

like image 482
DUG Avatar asked Sep 02 '19 10:09

DUG


3 Answers

set gradle-wrapper.properties file to:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

or higher

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
like image 154
Mohammed Hamed Avatar answered Oct 21 '22 15:10

Mohammed Hamed


enter image description here only add this line of code in build.gradle(module:app) file.

allprojects {
    repositories {
        jcenter()
         maven {
            url 'https://maven.google.com'
         }
    }
}
like image 45
user10116728 Avatar answered Oct 21 '22 15:10

user10116728


This solution working for me to replace google() tag with.

maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
like image 4
Pankaj Kant Patel Avatar answered Oct 21 '22 15:10

Pankaj Kant Patel