Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failing with 'Could not find method google() for arguments [] on repository container' #584

Closed
jskidd3 opened this issue Jan 21, 2018 · 34 comments

Comments

@jskidd3
Copy link

jskidd3 commented Jan 21, 2018

Message shown in console after react-native run-android:

Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/jskidd3/Desktop/Apps/AppName/node_modules/react-native-svg/android/build.gradle' line: 4

* What went wrong:
A problem occurred evaluating project ':react-native-svg'.
> Could not find method google() for arguments [] on repository container.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I installed the plugin in a fresh project on OSX. Versions:

react-native-cli: 2.0.1
react-native: 0.52.0
Android Studio: 3.0.1

My package.json looks like this:

{
  "name": "AppName",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.2.0",
    "react-native": "0.52.0",
    "react-native-svg": "^6.0.1-rc.3",
    "react-native-vector-icons": "^4.5.0"
  },
  "devDependencies": {
    "babel-jest": "22.1.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.1.4",
    "react-test-renderer": "16.2.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Any ideas as to how I can fix this?

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

Can you check that you have google() in both of these?
https://github.com/msand/SVGPodTest/blob/master/android/build.gradle#L6
https://github.com/msand/SVGPodTest/blob/master/android/build.gradle#L24

@jskidd3
Copy link
Author

jskidd3 commented Jan 21, 2018

@msand Sorry for the newbie question but where do I find those within the project?
Oh do you mean install that plugin and check for google()?

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

No worries. You can find it in appName/android/app/build.gradle where appName is the root of your project.

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

Oh sorry, appName/android/build.gradle is the one with the top-level repository configuration for all sub-projects/modules in the project. The one in the app folder is app specific.

@jskidd3
Copy link
Author

jskidd3 commented Jan 21, 2018

@msand Here's what that file looks like:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

Try changing to this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        google()
    }
}

@jskidd3
Copy link
Author

jskidd3 commented Jan 21, 2018

@msand That gives me this:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/joelkidd/Desktop/Apps/MyApp/android/build.gradle' line: 6

* What went wrong:
A problem occurred evaluating root project 'MyApp'.
> Could not find method google() for arguments [] on repository container.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

Make sure you have v4.1 of the gradle wrapper as well:
https://github.com/msand/SVGPodTest/blob/master/android/gradle/wrapper/gradle-wrapper.properties

#Thu Jan 18 18:05:34 EET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

When you open/build the project in the latest Android studio, it asks if you want it to make these upgrades for you.

@jskidd3
Copy link
Author

jskidd3 commented Jan 21, 2018

Now I get:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 13s
54 actionable tasks: 54 execute

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

Can you try cleaning and rebuilding the project? Preferably in android studio, as it gives better error messages and helpful automation for these things.

@jskidd3
Copy link
Author

jskidd3 commented Jan 21, 2018

Output from Gradle Build within Android Studio after clean & rebuild:

Information:Gradle tasks [clean, :app:assembleDebug, :react-native-maps:assembleDebug, :react-native-svg:assembleDebug]
Warning:The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Warning:The specified Android SDK Build Tools version (25.0.3) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
/Users/jskidd3/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/59539aab2a9f3f2996f368b98efa0b8b/res/values-v26/values-v26.xml
Error:(9, 5) error: resource android:attr/colorError not found.
Error:(13, 5) error: resource android:attr/colorError not found.
Error:(17, 5) error: style attribute 'android:attr/keyboardNavigationCluster' not found.
/Users/jskidd3/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/59539aab2a9f3f2996f368b98efa0b8b/res/values/values.xml
Error:(252, 5) error: resource android:attr/fontStyle not found.
Error:(252, 5) error: resource android:attr/font not found.
Error:(252, 5) error: resource android:attr/fontWeight not found.
Error:resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
Error:resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
/Users/jskidd3/Desktop/Apps/MyApp/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v26/values-v26.xml
Error:(7) resource android:attr/colorError not found.
Error:(11) resource android:attr/colorError not found.
Error:(15) style attribute 'android:attr/keyboardNavigationCluster' not found.
/Users/jskidd3/Desktop/Apps/MyApp/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Error:(171) resource android:attr/fontStyle not found.
Error:(171) resource android:attr/font not found.
Error:(171) resource android:attr/fontWeight not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 4s

Appreciate the fast responses whilst trying to sort this by the way 👍

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

Now its probably the app specific build.gradle file:
android/app/build.gradle

@@ -94,12 +94,12 @@ def enableSeparateBuildPerCPUArchitecture = false
 def enableProguardInReleaseBuilds = false
 
 android {
-    compileSdkVersion 25
+    compileSdkVersion 27
 
     defaultConfig {
         applicationId "com.svgpodtest"
         minSdkVersion 16
-        targetSdkVersion 25
+        targetSdkVersion 27
         versionCode 1
         versionName "1.0"
         ndk {
@@ -138,7 +138,7 @@ android {
 dependencies {
     compile project(':react-native-svg')
     compile fileTree(dir: "libs", include: ["*.jar"])
-    compile "com.android.support:appcompat-v7:25.4.0"
+    compile "com.android.support:appcompat-v7:27.0.2"
     compile "com.facebook.react:react-native:+"  // From node_modules
 }

@jskidd3
Copy link
Author

jskidd3 commented Jan 21, 2018

@msand Still getting errors so going to create a new project and start and build from Android Studio to see if it resolves. Just to confirm I should be using version v6.0.1-rc.2 right?

@msand
Copy link
Collaborator

msand commented Jan 21, 2018

The last changes, the ones in the app specific build.gradle are for rc-3, everything else should work fine with rc-2 as well.

@jskidd3
Copy link
Author

jskidd3 commented Jan 21, 2018

@msand Sorted by installing rc-3 and following instructions again, built successfully after following steps here. Many thanks for your help

@jskidd3
Copy link
Author

jskidd3 commented Jan 21, 2018

@msand Created a separate issue at #585. Couldn't continue with these hacks as conflicted with other plugins so started a fresh and reverted to last major version

@laurindo
Copy link

I had the same problem and I've resolved change the version of my "react-native-svg": "^6.0.1-rc.1" to "react-native-svg": "6.0.1-rc.1" and run again npm install .

My react-native-svg module had the version: [Error]
error-react-native-svg

@msand
Copy link
Collaborator

msand commented Jan 25, 2018

@laurindo Did you try making the required changes to these three files? #583 (comment)

@derekbar90
Copy link

Thanks for solving this but doesn't updating the API to 25-27 make the apps using this module limited to supporting only 5% of the android market?

@msand
Copy link
Collaborator

msand commented Jan 25, 2018

It should mostly make it so that newer android version don't need to run in backwards compatibility mode. The minSdkVersion 16 set the minimum sdk support level and decided how old versions it works with.
https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd

https://developer.android.com/training/basics/supporting-devices/platforms.html#sdk-versions

To maintain your application along with each Android release, you should increase the value of this attribute to match the latest API level, then thoroughly test your application on the corresponding platform version.
https://developer.android.com/guide/topics/manifest/uses-sdk-element.html

@nikolaigeorgie
Copy link

same issue

@msand
Copy link
Collaborator

msand commented Jan 29, 2018

@nikolas7892 Check this: #465 (comment)

@KalaiselvanMahendran
Copy link

KalaiselvanMahendran commented Feb 1, 2018

@msand What is the final solution for this issue? am also facing the same issue.

@msand
Copy link
Collaborator

msand commented Feb 1, 2018

@KalaiselvanMahendran Have you tried making the changes mentioned in the previous linked comment? #465 (comment)

@KalaiselvanMahendran
Copy link

KalaiselvanMahendran commented Feb 1, 2018

@msand yeah i did, but still getting below error

Scanning folders for symlinks in D:\Development\React_Projects\ReactChartApp\nod
e_modules (66ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat install
Debug)...

> Configure project :app
Checking the license for package Android SDK Build-Tools 25.0.3 in C:\Users\kala
1818\AppData\Local\Android\Sdk\licenses
License for package Android SDK Build-Tools 25.0.3 accepted.
Preparing "Install Android SDK Build-Tools 25.0.3".
"Install Android SDK Build-Tools 25.0.3" ready.
Finishing "Install Android SDK Build-Tools 25.0.3"
Installing Android SDK Build-Tools 25.0.3 in C:\Users\kala1818\AppData\Local\And
roid\Sdk\build-tools\25.0.3
"Install Android SDK Build-Tools 25.0.3" complete.

> Configure project :react-native-svg
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configur
ation failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.
        at com.google.common.base.Preconditions.checkState(Preconditions.java:17
3)
        at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.jav
a:645)
        at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:608)
        at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:605)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java
:156)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java
:120)
        at com.android.build.gradle.BasePlugin.lambda$createTasks$1(BasePlugin.j
ava:603)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.d
ispatch(BroadcastDispatch.java:91)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.d
ispatch(BroadcastDispatch.java:80)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(Abstract
BroadcastDispatch.java:42)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatc
h(BroadcastDispatch.java:230)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatc
h(BroadcastDispatch.java:149)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(Abstract
BroadcastDispatch.java:58)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatc
h(BroadcastDispatch.java:324)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatc
h(BroadcastDispatch.java:234)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcas
t.java:140)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcas
t.java:37)

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Development\React_Projects\ReactChartApp\node_modules\react-nativ
e-svg\android\build.gradle' line: 39

* What went wrong:
A problem occurred evaluating project ':react-native-svg'.
> Could not find method api() for arguments [com.android.support:appcompat-v7:27
.0.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.Defau
ltDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

@msand
Copy link
Collaborator

msand commented Feb 2, 2018

@KalaiselvanMahendran Those instructions are for the latest version, seems you're trying to build an older one? Can you paste your package.json?

@wassgha
Copy link

wassgha commented Feb 3, 2018

I am getting the same error
Could not find method api() for arguments [com.android.support:appcompat-v7:27.0.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
did anyone fix it?

@msand
Copy link
Collaborator

msand commented Feb 3, 2018

Seems you're using an older version of gradle. Make sure you have v4.1 in:
android/gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,6 @@
+#Mon Jan 29 13:59:51 EET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip

@msand
Copy link
Collaborator

msand commented Feb 3, 2018

@KalaiselvanMahendran @nikolas7892 @derekbar90 @jskidd3 @wassgha I've released a new version, which aligns all versions with react-native init. Please check to see everything works correctly.

@gokujy
Copy link

gokujy commented Dec 7, 2018

I am getting the same error:
Could not find method google() for arguments [] on repository container
Solve: I'm working on firebase crud and i installed angularfire2 and firebase plugin both.
So i uninstall firebase and error solved, i mean this error coming because conflict.

@volov157
Copy link

I got the same error when I use react-native-sqlite-storage , only this website solve my problem ,
https://github.com/react-native-community/react-native-camera/blob/master/docs/GradleUpgradeGuide.md

@kaszona
Copy link

kaszona commented Mar 9, 2019

Just delete the whole android folder and run a command to add.

@steve721
Copy link

Can you check that you have google() in both of these?
https://github.com/msand/SVGPodTest/blob/master/android/build.gradle#L6
https://github.com/msand/SVGPodTest/blob/master/android/build.gradle#L24

Screenshot_1

I Got an error that

Could not find method google() for arguments [] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.

and my build.gradle looks like this

buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 19
compileSdkVersion = 29
targetSdkVersion = 29
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "+"
googlePlayServicesAuthVersion = "17.0.0"
googlePlayServicesAuthVersion = "16.0.1"
firebaseMessagingVersion = "+"
}
repositories
google()
mavenCentral()
jcenter()

}
dependencies {
    classpath("com.android.tools.build:gradle:4.2.2")

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

allprojects {
repositories {
google()
mavenCentral()
//jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
maven {
url "https://sdk.smartlook.com/android/release"
}
google()
//jcenter()
maven { url 'https://www.jitpack.io' }

}

}

would you please help me it fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests