Don't working the library from GitHub in Andro

2019-08-30 19:09发布

问题:

Don't working this library from GitHub in Android Studio My build.gradle(:project):

apply plugin: 'com.android.application'
android {
     compileSdkVersion 23
     buildToolsVersion "23.0.1"

   defaultConfig {
      applicationId "com.example.mymaterialdialogs"
      minSdkVersion 15
      targetSdkVersion 23
      versionCode 1
      versionName "1.0"
    }
    buildTypes {
         release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
    }
}
dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:23.0.1'

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

And My build.gradle(:app):

buildscript {
   repositories {
      maven { url "https://jitpack.io" }
   }
   dependencies {
      classpath 'com.android.tools.build:gradle:1.3.0'
   }
}
allprojects {
   repositories {
       jcenter()
   }
}
task clean(type: Delete) {
   delete rootProject.buildDir
}

Show this Error:

Error:(26, 13) Failed to resolve: com.afollestad.material-dialogs:core:0.8.4.2 Show in File(openFile:.../app/build.gradle)
Show in Project Structure dialog(open.dependency.in.project.structure)

回答1:

Do the following steps:

1.In your build.gradle(:project) Add the following before dependencies

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

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'

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

2.In your build.gradle(:app): replace

 maven { url "https://jitpack.io" } with jcenter()

3.Sync project

Hope this helps.