34

I'm following official instructions of fabric

https://www.fabric.io/kits/android/crashlytics/install

This is my gradle.build file

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'

buildscript {
ext.kotlin_version = '1.1.51'
repositories {
    jcenter()
    mavenCentral()
    maven {
        url 'https://maven.google.com'
    }
}
dependencies {
...
    classpath 'io.fabric.tools:gradle:1.24.3'

    }
}

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

}

android {

compileSdkVersion 22

buildToolsVersion '25.0.3'
defaultConfig {
    ....
}

}
dependencies {
......
   compile('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') {
    transitive = true
  }
}

apply plugin: 'com.google.gms.google-services'

but when I try to sync my project, it says that could not find io.fabric.tools:gradle:1.24.3 searched in following locations:

Error:Could not find io.fabric.tools:gradle:1.24.3.
Searched in the following locations:

    file:/home/dev-00/soft/android-studio-3.0.0/android-studio/gradle/m2repository/io/fabric/tools/gradle/1.24.3/gradle-1.24.3.pom
    file:/home/dev-00/soft/android-studio-3.0.0/android-studio/gradle/m2repository/io/fabric/tools/gradle/1.24.3/gradle-1.24.3.jar
    https://jcenter.bintray.com/io/fabric/tools/gradle/1.24.3/gradle-1.24.3.pom
    https://jcenter.bintray.com/io/fabric/tools/gradle/1.24.3/gradle-1.24.3.jar
 ...    Required by:
    project :
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Jemo Mgebrishvili
  • 5,187
  • 7
  • 38
  • 63

1 Answers1

67

In your buildscript block you have to add also the fabric repo.

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

  dependencies {
     //......
  }
}
Gastón Saillén
  • 12,319
  • 5
  • 67
  • 77
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • o right :/ now error is gone, but I can't use any instance of Fabric or Crashlytic for example: Fabric.with(this, new Crashlytics()); says cannot resolve symbol Fabric – Jemo Mgebrishvili Oct 17 '17 at 10:29
  • 1
    Try to clean, but this is some separate problem. It has nothing to do with your question. You may wish to consider asking a separate question – Gabriele Mariotti Oct 17 '17 at 10:31
  • 8
    note that I had to move this to the top level `buildscripts.repositories` object block in the file. It did not work when the maven url entry was made under the `allprojects.buildscripts.repositories` object block of the file my allprojects – Tope Mar 12 '18 at 02:54
  • 1
    `Tope`s comment in correct. You should add the repo in `buildscripts.repositories`. – King Julien Dec 29 '18 at 16:54