我正在尝试构建旧代码,但是gradle
同步失败,出现错误:
无法解决:com.android.support。
我已经研究了这个问题,并尝试在我的代码中实现它们,但是任何一个都不起作用。我的gradle
如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.tex"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':slideMenuLibrary')
implementation('com.github.nkzawa:socket.io-client:0.3.0') {
exclude group: 'org.json', module: 'json'
}
implementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support.constraint: constraint-layout: 1.0.2'
implementation 'com.google.android.gms:play-services-maps:10.2.1'
implementation 'com.google.android.gms:play-services-analytics:10.2.1'
implementation 'com.google.android.gms:play-services-gcm:10.2.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.koushikdutta.ion:ion:2.+'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.victor:lib:1.0.4'
implementation 'com.afollestad.material-dialogs:core:0.8.6.2'
implementation 'com.github.lzyzsd:circleprogress:1.1.0@aar'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.wdullaer:materialdatetimepicker:2.4.0'
implementation 'org.apache.commons:commons-lang3:3.3.2'
androidTestImplementation 'junit:junit:4.12'
}
我的项目build.gradle文件如下:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
该库的gradle文件如下:
buildscript {
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
apply plugin: 'com.android.library'
dependencies {
implementation 'com.android.support:support-v4:27.1.1'
}
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
}
sourceSets {
main {
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
manifest.srcFile 'AndroidManifest.xml'
}
}
}
答案 0 :(得分:0)
在以下所有项目的根build.gradle文件中添加以下内容:
repositories {
mavenLocal()
mavenCentral()
maven { // <-- Add this
url 'https://maven.google.com/'
name 'Google'
}
}
如果您将Android Plugin用于Gradle 3.0.0或更高版本
repositories {
mavenLocal()
mavenCentral()
google() //---> Add this
}
并以这种方式注入依赖项:
implementation 'com.android.support:appcompat-v7:27.1.1'