下面的内容是我的android studio项目中的build.gradle。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
}
apply plugin: 'com.android.application'
dependencies {
//classpath 'com.android.tools.build:gradle:2.4.0'
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.google.android.gms:play-services:10.2.6'
compile 'com.android.support:appcompat-v7:25.2.0'
//compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.google.android.gms:play-services-auth:10.2.6'
compile 'pub.devrel:easypermissions:0.3.0'
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-script:v1-rev79-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.example.quickstart"
minSdkVersion 11
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
// compileOptions {
// sourceCompatibility JavaVersion.VERSION_1_8
// targetCompatibility JavaVersion.VERSION_1_8
// }
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
我要运行项目,它将在下面显示错误。然后我指的是https://github.com/googlesamples/easypermissions
,但我仍然不明白如何解决
Failed to resolve: pub.devrel:easypermissions:0.3.0
错误。/Users/yayaigo/Downloads/SmsSourceCode/BroadcastReveiverNewSms/build.gradle
Error:Error:line (21)Failed to resolve: pub.devrel:easypermissions:0.3.0
<a href="openFile:/Users/yayaigo/Downloads/SmsSourceCode/BroadcastReveiverNewSms/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Error:line (25)Failed to resolve: com.google.apis:google-api-services-script:v1-rev79-1.22.0
<a href="openFile:/Users/yayaigo/Downloads/SmsSourceCode/BroadcastReveiverNewSms/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:Error:line (22)Failed to resolve: com.google.api-client:google-api-client-android:1.22.0
<a href="openFile:/Users/yayaigo/Downloads/SmsSourceCode/BroadcastReveiverNewSms/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
这是我的环境设置如下:
Android Studio version:2.3.2
Gradle:3.3
最佳答案
如下所示在您的build.gradle中添加jcenter():
repositories {
mavenCentral()
jcenter()
}