Manu Manu - 6 months ago 106
Android Question

Gradle Fails to resolve material-dialogs dependency in Android Studio

I am trying to build my Android App I imported from a Git repository. This same app builds correctly in another environment, but in my environment I get the following error:

Error:(41, 13) Failed to resolve: com.afollestad:material-dialogs:0.7.7.0


My build.gradle:

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}


android {
compileSdkVersion 22
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "my.app.id"
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.afollestad:material-dialogs:0.7.7.0'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.github.navasmdc:MaterialDesign:1.2'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'joda-time:joda-time:2.3'
compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
compile 'com.andreabaccega:android-form-edittext:1.2.1@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
}


I also tried different versions (0.7.7.0, 0.7.6.0, 0.7.5.5), but nothing changes. How can I address my issue?

Answer

On jCenter there are only two version available 0.7.9.0 and 0.7.9.1. These versions are not available in Maven Central, so check in your project build.gradle that you are using jcenter().

BTW these versions are not updated, the last version released in GitHub is 0.8.5.1.

To use the last version in your project use the following instructions:

Repository

First, add the following to your app's build.gradle file:

repositories {
  maven { url "https://jitpack.io" }  
}      

Core

The core module contains all the major classes of this library, including MaterialDialog and AlertDialogWrapper. You can create basic, list, single/multi choice, progress, input, etc. dialogs with core.

dependencies {

  // ... other dependencies here

  compile('com.github.afollestad.material-dialogs:core:0.8.5.1@aar') {
      transitive = true
  }   
}