Android 错误:原因:安装插件后未指定CompileSDK版本

Android 错误:原因:安装插件后未指定CompileSDK版本,android,android-studio,android-gradle-plugin,build.gradle,gradle-plugin,Android,Android Studio,Android Gradle Plugin,Build.gradle,Gradle Plugin,我试着安装这个。首先,我得到了 无法添加任务“clean”,因为具有该名称的任务已存在。 然后我用这行注释了它 // //task clean(type: Delete) { // delete rootProject.buildDir //} 在build.gradle中(项目:XXX) 然后我犯了个错误 原因:未指定compileSdkVersion。 即使它已经在build.gradle文件中指定了 build.gradle apply plugin: 'com.android.a

我试着安装这个。首先,我得到了

无法添加任务“clean”,因为具有该名称的任务已存在。


然后我用这行注释了它

//
//task clean(type: Delete) {
//    delete rootProject.buildDir
//}
在build.gradle中(项目:XXX)

然后我犯了个错误

原因:未指定compileSdkVersion。
即使它已经在build.gradle文件中指定了

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "www.pro_cs_is.com"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    implementation 'com.android.support:exifinterface:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.2',{
    exclude group: 'com.google.code.findbugs'})
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    implementation 'org.jsoup:jsoup:1.11.3'
    implementation 'com.google.apis:google-api-services-blogger:v3-rev57-1.23.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.j256.ormlite:ormlite-android:5.1'
    implementation 'com.j256.ormlite:ormlite-core:5.1'
}


  • 在中应用插件
  • 仅适用于build.gradle(模块:应用程序)
  • 如下

    apply plugin: 'com.android.application'
    apply plugin: 'ormgap'
    
    android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
    applicationId "www.pro_cs_is.com"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-   rules.pro'
       }
       }
       }
    
      dependencies {
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      implementation 'com.android.support:appcompat-v7:27.1.1'
      implementation 'com.android.support:animated-vector-drawable:27.1.1'
      implementation 'com.android.support:exifinterface:27.1.1'
      implementation 'com.android.support:design:27.1.1'
      implementation 'com.android.support.constraint:constraint-layout:1.1.1'
      implementation 'com.android.support:cardview-v7:27.1.1'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.2',{
      exclude group: 'com.google.code.findbugs'})
      implementation 'com.squareup.retrofit2:retrofit:2.4.0'
      implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
      implementation 'com.github.bumptech.glide:glide:4.7.1'
      implementation 'org.jsoup:jsoup:1.11.3'
      implementation 'com.google.apis:google-api-services-blogger:v3-rev57-1.23.0'
      implementation 'com.squareup.picasso:picasso:2.71828'
      implementation 'com.j256.ormlite:ormlite-android:5.1'
      implementation 'com.j256.ormlite:ormlite-core:5.1'
     }
    
  • 并将其从build.gradle(项目:XXX)中删除

  • 我希望这会有所帮助

不要在根项目的
build.gradle中应用插件。。。
apply plugin: 'com.android.application'
apply plugin: 'ormgap'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "www.pro_cs_is.com"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-   rules.pro'
   }
   }
   }

  dependencies {
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation 'com.android.support:appcompat-v7:27.1.1'
  implementation 'com.android.support:animated-vector-drawable:27.1.1'
  implementation 'com.android.support:exifinterface:27.1.1'
  implementation 'com.android.support:design:27.1.1'
  implementation 'com.android.support.constraint:constraint-layout:1.1.1'
  implementation 'com.android.support:cardview-v7:27.1.1'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.2'
  androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.2',{
  exclude group: 'com.google.code.findbugs'})
  implementation 'com.squareup.retrofit2:retrofit:2.4.0'
  implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
  implementation 'com.github.bumptech.glide:glide:4.7.1'
  implementation 'org.jsoup:jsoup:1.11.3'
  implementation 'com.google.apis:google-api-services-blogger:v3-rev57-1.23.0'
  implementation 'com.squareup.picasso:picasso:2.71828'
  implementation 'com.j256.ormlite:ormlite-android:5.1'
  implementation 'com.j256.ormlite:ormlite-core:5.1'
 }