20

So I'm trying to sync an android studio project but flexbox keeps failing to resolve. As far as I'm aware all relevant repositories are included. I've tried on multiple internet connections (no proxies involved) to no avail.

I've tried different versions of flexbox as well.

Here's my app build.gradle:

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        maven { url 'https://maven.fabric.io/public' }

    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

allprojects {
    repositories {
        flatDir {
            dirs 'libs'
        }
        maven { url "https://jitpack.io" }
    }
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.jetbrains.kotlin.android.extensions'
androidExtensions {
    experimental = true
}
apply plugin: 'io.fabric'
apply plugin: 'jacoco'

repositories {
    google()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://maven.google.com' }
    mavenCentral()
}

All other google dependencies download and install and it appears that flexbox does download during the gradle sync but always fails afterwards. I really don't know what could be causing this. I've completely removed Android Studio (inc Gradle files, sdk files, preferences, etc) and reinstalled from scratch but this error just keeps occurring. I'm really at a loss here.

The dependency is listed as:

implementation 'com.google.android:flexbox:1.1.0'

EDIT: So while trying to sync again I managed to screengrab the statusbar at the bottom of Android Studio to see what was going on when I saw 'flexbox' flash up:

Screen grab of Android Studio status bar When I try to go to this URL in the browser I get a 404

Is this even the correct repo?

Chris
  • 413
  • 1
  • 5
  • 11
  • 1
    This issue is related to the one posted here: https://stackoverflow.com/questions/53706565/error-could-not-find-com-google-gmsgoogle-services4-2-0 – Mike Dec 10 '18 at 20:41

4 Answers4

41

For those of you who came to this question after removing jcenter() from their gradle files:

According to this comment (https://github.com/google/flexbox-layout/issues/566#issuecomment-844630491) the flexbox library is available from the google maven repository now.

This however requires to change the reference to:

dependencies {
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
}
Volker Voecking
  • 5,203
  • 2
  • 38
  • 35
  • Thank you, Volker! Looks like the accepted answer is outdated now, and this one should be pushed to the top. – gregko Jul 31 '21 at 13:09
  • 5
    This does solve the issue if you are using flexbox directly in your project, however I have a library that has dependency to flexbox 2.0.1 and I don't have source code for that library to upgrade it. – AaA Aug 21 '21 at 08:23
  • @AaA can you fix the problem with flex box 2.0.1, I have the same situation. – Vinithius Nov 23 '22 at 17:05
  • Well no! I was lucky that library owner updated the library themselves, otherwise I was planning to remove their library from my code. – AaA Dec 03 '22 at 07:45
15

Deprecated

Add this to your gradle file

maven {
    url "https://google.bintray.com/flexbox-layout" }

update

Thanks to @Volker Voecking answer

dependencies {
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
}
Oussema Aroua
  • 5,225
  • 1
  • 24
  • 44
  • 2
    This answer is no longer valid after the upgrade to Gradle 7 (or higher). Look instead the answer by @Volker Voecking – gregko Jul 31 '21 at 13:10
4

For those looking for a way to fix this issue as a dependency in a third-party library

Try to put this in your project level gradle file:

allprojects {

    dependencies{
        modules {
            module("com.google.android:flexbox") {
                replacedBy("com.google.android.flexbox:flexbox")
            }
        }
    }
}
Inliner
  • 1,061
  • 7
  • 10
2

You can also check this thread https://github.com/google/flexbox-layout/issues/475 In my opinion it seems to be wider than flexbox.. I have face many dependencies missing from google(), jCenter() and mavenCentral()...

Julien
  • 25
  • 4
  • 1
    It's so annoying when these kinds of things coincidentally happen when you've just fixed an unrelated error. – Chris Dec 10 '18 at 17:24