0

错误:(1, 0) 未找到 ID 为 'com.android.application' 的插件 我用谷歌搜索并搜索了 3 天,但没有得到解决方案.....完全卡住了 ** 我 gradle 版本:2.5 .. **build .gradle(projetc:android)

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {

        classpath "com.android.tools.build:gradle-experimental:0.2.1"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

build.gradle(模块:应用程序)

    apply plugin: "com.android.model.application"

model {
    android {
        compileSdkVersion = 22
        buildToolsVersion = "22.0.1"

        defaultConfig.with {

            applicationId =  "com.example.altaf.Android"
            minSdkVersion.apiLevel = 15
            targetSdkVersion.apiLevel = 22
            versionCode = 1
            versionName = "1.0"


            buildConfigFields.with {
                create() {
                    type = "int"
                    name = "VALUE"
                    value = "1"
                }
            }

        }

    }

    android.buildTypes {
        release {
            minifyEnabled = false
            proguardFiles.add(file("proguard-rules.pro"))

        }
    }

    android.productFlavors {
        create("flavor1") {

            applicationId = "com.app"
        }
    }



    // Configures source set directory.

    android.sources {

        main {

            java {

                source {

                    srcDir "src"

                }

            }

        }

    }

}

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:22.2.0"
}

build.gradle(模块:opencvlibrary310)

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}
4

2 回答 2

1

像这样修改你的build.gradle(module:opencvlibrary310)

apply plugin: "com.android.model.application"

model {
    android {
        compileSdkVersion = 22
        buildToolsVersion = "22.0.1"

        defaultConfig.with {

            minSdkVersion.apiLevel = 15
            targetSdkVersion.apiLevel = 22

        }

    }
}

我正在使用以下版本的实验性 gradle 插件:

classpath 'com.android.tools.build:gradle-experimental:0.4.0'

更新:app文件中删除以下行:

 android.sources {

        main {

            java {

                source {

                    srcDir "src"

                }

            }

        }

    }

我希望它有所帮助。

于 2015-12-28T09:47:09.317 回答
0

在build.gradle(module:app)中更改应用插件:“com.android.application”而不是应用插件:“com.android.model.application”

于 2015-12-28T09:12:38.207 回答