android - 错误: Cause: compileSdkVersion is not specified after install plugin

标签 android android-studio android-gradle-plugin build.gradle gradle-plugin

我尝试安装这个plugin 。首先我得到了

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


然后我通过注释此行来修复它

//
//task clean(type: Delete) {
//    delete rootProject.buildDir
//}

build.gradle(项目:XXX)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.github.stephanenicolas.ormgap:ormgap-plugin:1.0.13'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

apply plugin: 'com.android.application'
apply plugin: 'ormgap'

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}
//
//task clean(type: Delete) {
//    delete rootProject.buildDir
//}



然后我得到了错误

原因:未指定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(module:app)
  • 如下

    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(project:XXX) 中删除

  • 希望这会有所帮助

关于android - 错误: Cause: compileSdkVersion is not specified after install plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54468960/

相关文章:

android - 问题 78326 : AAPT prints sRGB profile warnings messages

android-studio - 在Android Studio中构建Gradle期间编辑代码

android-studio - 堆栈溢出错误 : null in Android Studio on Project Structure

android - 在没有来自 Android 的对话的情况下发送 facebook 用户到用户的私有(private)消息

java - 如何在Android中向谷歌地图添加固定 float 覆盖图像

java - 如何使用序列化程序编写流式 xml 文件

android - 如何更改android studio中的默认主题?

android - 将 Android studio 更新到 3.1.2 后,我得到 "Failed to load AppCompat ActionBar with unknown error. "

java - 安装拆分 apk 时出错 : com. android.ddmlib.InstallException:无法完成 session :INSTALL_FAILED_INVALID_APK

android - 在 Android 上使用 OpenCV 将 Mat 元素缩放到 [0..255] 范围