导入项目报错:Plugin with id 'com.android.library' not found.
解决办法:
-
在build.gradle中加入
apply plugin: 'com.android.library'
buildscript{
repositories{
jcenter()
google()
}
dependencies{
classpath "com.android.tools.build:gradle:2.3.3"
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 2
versionName "1.3.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
google()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:26.0.1'
compile 'com.github.Othershe:NiceDialog:1.1.4'
}
再次编译会发现仍然报错:Could not find method google() for arguments [] on repository container.
2.将gradle-wrapper.properties末尾的
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
改为
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
再次编译即可。