我尝试将此应用程序从版本22迁移到版本27,但是我遇到了一些问题,即使我有类似的问题,也无法在任何地方找到答案。
当我尝试同步build.gradle时,显示以下错误在类型org.gradle.api.internal.artifacts.dsl的对象上找不到参数[目录'libs']的方法Implementation() .dependencies.DefaultDependencyHandler。
那是旧的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.android.support:design:22.2.1'
compile 'agency.tango.android:material-intro-screen:0.0.3'
compile 'com.github.GrenderG:Prefs:1.1'
}
和我的 new build.gradle 是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.myapplication"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.android.gms:play-services-ads:15.0.0'
implementation 'com.android.support:design:27.1.1'
implementation 'agency.tango.android:material-intro-screen:0.0.5'
implementation 'com.github.GrenderG:Prefs:1.2.5'
}