【问题标题】:Don't working the library from GitHub in Android Studio不要在 Android Studio 中使用来自 GitHub 的库
【发布时间】:2016-01-18 14:32:19
【问题描述】:

不要在 Android Studio 中使用来自 GitHub 的 library 我的 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
  }
}

还有我的 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
}

显示此错误:

错误:(26, 13) 无法解决: com.afollestad.material-dialogs:core:0.8.4.2 显示在 File(openFile:.../app/build.gradle)
在项目结构中显示 对话框(open.dependency.in.project.structure)

【问题讨论】:

  • 我认为你做错了,你在 (:project) Gradle 文件中添加了应该在 (Module : app) Gradle 文件中的依赖项。

标签: android android-studio github gradle


【解决方案1】:

执行以下步骤:

1.在你的 build.gradle(:project) 依赖项之前添加以下内容

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.在你的 build.gradle(:app) 中:替换

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

3.同步项目

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-04
    • 1970-01-01
    • 2017-11-08
    • 1970-01-01
    • 2021-06-08
    • 2015-02-04
    • 2013-05-11
    相关资源
    最近更新 更多