【问题标题】:Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins错误:“java”插件已应用,但与 Android 插件不兼容
【发布时间】:2015-11-25 03:12:07
【问题描述】:

我正在开发一个 android 库项目。我想将我的库上传到 JCenter。我已经创建了 bintray 帐户等,并遵循了here 中提到的所有步骤。

我在我的应用程序模块和库模块中做了以下更改。

应用模块 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"


    defaultConfig {
        applicationId "com.app.testapp"
        minSdkVersion 8
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }


}

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

库模块 build.gradle

apply plugin: 'com.android.library'

ext {
    bintrayRepo = 'maven'
    bintrayName = 'test-sdk'

    publishedGroupId = 'in.test.sdk'
    libraryName = 'testlib'
    artifact = 'test-sdk'

    libraryDescription = 'A wrapper for Facebook Native Like Button (LikeView) on Android'

    siteUrl = 'https://github.com/xyz/testsdk'
    gitUrl = 'https://github.com/xyz/testsdk.git'

    libraryVersion = '1.0.0'

    developerId = 'xyz'
    developerName = 'xyz'
    developerEmail = 'xyz@xyz.xyz'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}

version = "1.0.0"
android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
           // proguardFiles 'proguard-project.txt'
        }
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
        }
    }


}

dependencies {
    compile 'com.android.support:support-v4:22.2.0'
    compile files('libs/gson-2.3.1.jar')
    compile files('libs/android-query-full.0.26.8.jar')
    compile files('libs/httpmime-4.1.1.jar')
    compile files('libs/jackson-annotations-2.5.0.jar')
    compile files('libs/javax.annotation.jar')
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile files('libs/okhttp-2.3.0.jar')
    compile files('libs/okio-1.3.0.jar')
    compile files('libs/retrofit-1.9.0.jar')
}

最新项目根 build.gradle

  // 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:1.1.3'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3.1'
        classpath 'com.github.dcendents:android-maven-plugin:1.2'

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

    }

    plugins {
        id "com.jfrog.bintray" version "1.2"
    }

    allprojects {

        repositories {
            jcenter()
        }

        apply plugin: 'maven'
        apply plugin: 'maven-publish'
        apply plugin: 'java'
    }
    publishing {
        publications {
            MyPublication(MavenPublication) {
                from components.java
                groupId 'in.freeb.sdk'
                artifactId 'freeb-sdk'
                version '1.0'
            }
        }
    }

    bintray {
        user = 'ajay-spice'
        key = '31317855920db8f7bc27f97730a8e9f99b6f707e'
        publications = ['MyPublication']
        pkg {
            repo = 'maven'
            name = 'freeb-sdk'
            userOrg = 'ajay-spice'
            licenses = ['Apache-2.0']
            vcsUrl = 'https://github.com/ajay-spice/freebsdk.git'
            labels = ['gear', 'gore', 'gorilla']
            publicDownloadNumbers = true
            attributes= ['a': ['ay1', 'ay2'], 'b': ['bee'], c: 'cee'] //Optional package-level attributes
            version {
                name = '1.0-Final'
                desc = 'FreeB 1.0 final'
                vcsTag = '1.0.0'
                attributes = ['freeb-sdk': 'in.freeb.sdk']
            }
        }
    }

    task wrapper(type: Wrapper) {
        gradleVersion = '2.4'
    }

当我在构建时,我收到了这个错误 我花了两天时间,但无法得到正确的解决方案。请提出解决方法。

错误

Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins.
Gradle 'FreeBApp' project refresh failed

【问题讨论】:

    标签: maven android-studio android-gradle-plugin build.gradle jcenter


    【解决方案1】:

    添加root build.gradle

    apply plugin: 'com.jfrog.bintray'
    

    看看这个不错的入门@9​​87654321@

    【讨论】:

    • 嗨 Pengrad,我正在按照您在上面评论中提到的教程进行操作。我再次陷入了困境:GOT ERROR :- Error:(1, 0) Plugin with id 'com.android.application' not found.
    • 嗨 pengrad,我已经发布了最新的 Build.gradle。请检查!
    • 'com.android.application' not found - 如果我放置依赖项标记 ========= dependencies { classpath 'com.android.tools.build:gradle,此错误已解决:1.1.3' } But Again Got Error :- Error: The 'java' plugin has been applied, but it is not compatible with the Android plugins.
    • 嘿 Pengrad,我有一个新问题,需要你的帮助,请检查下面的链接:[Link] (stackoverflow.com/questions/32377000/…)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-07
    • 2017-05-29
    • 2020-01-26
    • 1970-01-01
    • 2018-08-07
    相关资源
    最近更新 更多