错误:“Java的插件已经被应用,但它不是与Android兼容的插件 [英] Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins

查看:6177
本文介绍了错误:“Java的插件已经被应用,但它不是与Android兼容的插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在Android的一个库项目。我想我的图书馆上传到JCenter。我创建bintray帐户等&放大器;其次这是中提到的所有步骤<一个href=\"http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en\"相对=nofollow>这里。

我做了我的应用模块和放大器的变化如下;库模块。

应用模块的build.gradle

 应用插件:'com.android.application安卓{
    compileSdkVersion 22
    buildToolsVersion22.0.1
    defaultConfig {
        的applicationIDcom.app.testapp
        8的minSdkVersion
        targetSdkVersion 22
        版本code 1
        的versionName1.0
    }
    buildTypes {
        发布 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
        }
    }
    packagingOptions {
        排除META-INF / LICENSE.TXT
    }
}依赖{
    编译文件树(包括:['的* .jar'],DIR:库)
    编译com.android.support:appcompat-v7:22.2.0
    编制项目(':TESTLIB')
}

库模块的build.gradle

 应用插件:'com.android.library转{
    bintrayRepo ='行家'
    bintrayName ='测试-SDK    publishedGroupId ='in.test.sdk
    库名称='TESTLIB
    神器='测试-SDK    libraryDescription ='A为Facebook原生Like按钮(LikeView)在Android包装'    SITEURL ='https://github.com/xyz/testsdk
    gitUrl ='https://github.com/xyz/testsdk.git    libraryVersion =1.0.0    developerId ='某某'
    developerName ='某某'
    developerEmail ='xyz@xyz.xyz    licenseName ='Apache软件许可证,版本2.0
    licenseUrl ='http://www.apache.org/licenses/LICENSE-2.0.txt
    allLicenses = [Apache的2.0]
}版本=1.0.0
安卓{
    compileSdkVersion 22
    buildToolsVersion22.0.1    defaultConfig {
        8的minSdkVersion
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }    buildTypes {
        发布 {
            minifyEnabled假            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
           // proguardFilesProGuard的-project.txt
        }
        packagingOptions {
            排除META-INF / LICENSE.TXT
        }
    }
}依赖{
    编译com.android.support:support-v4:22.2.0
    编译文件(库/ GSON-2.3.1.jar')
    编译文件(库/ Android的查询full.0.26.8.jar')
    编译文件(库/ httpmime-4.1.1.jar')
    编译文件(库/杰克逊的注解-2.5.0.jar')
    编译文件(库/ javax.annotation.jar')
    编译文件(库/ libGoogleAnalyticsServices.jar')
    编译文件(库/ okhttp-2.3.0.jar')
    编译文件(库/奥基奥-1.3.0.jar')
    编译文件(库/改造-1.9.0.jar')
}

最新项目根的build.gradle

  //顶级构建文件,您可以添加常用的配置选项,所有分项目/模块。    buildscript {
        库{
            jcenter()
        }
     依赖{
        类路径'com.android.tools.build:gradle:1.1.3
        类路径'com.jfrog.bintray.gradle:gradle这个-bintray-插件:1.3.1
        类路径'com.github.dcendents:Android的Maven的插件:1.2        //注意:不要在这里把你的应用程序依赖关系;他们属于
        //在单个模块的build.gradle文件
    }    }    插件{
        IDcom.jfrog.bintray版本1.2
    }    allprojects {        库{
            jcenter()
        }        应用插件:'行家'
        应用插件:'Maven的发布
        应用插件:Java的
    }
    出版{
        出版物{
            MyPublication(MavenPublication){
                从components.java
                的groupId'in.freeb.sdk
                artifactId的freeb-SDK
                版本'1.0'
            }
        }
    }    bintray {
        用户='阿贾伊香料
        关键='31317855920db8f7bc27f97730a8e9f99b6f707e
        出版物= ['MyPublication']
        PKG {
            回购='行家'
            NAME ='freeb-SDK
            userOrg ='阿贾伊香料
            许可证= ['Apache的2.0']
            vcsUrl ='https://github.com/ajay-spice/freebsdk.git
            标签= ['齿轮','血腥','大猩猩']
            publicDownloadNumbers =真
            属性= ['一':'AY1','AY2'],'B':'蜜蜂'],C:CEE'] //可选包级属性
            版本{
                名称= 1.0,最终
                DESC ='FreeB 1.0最终
                vcsTag =1.0.0
                属性= ['freeb-SDK':'in.freeb.sdk']
            }
        }
    }    任务包装(类型:包装){
        gradleVersion ='2.4'
    }

当我建立那么我得到这个错误
我花了两天相同,但无法得到它的妥善解决。请建议如何解决它。

错误

 错误:Java的插件已经被应用,但它不是与Android兼容的插件。
摇篮FreeBApp项目刷新失败


解决方案

添加根的build.gradle

 应用插件:'com.jfrog.bintray

和看看这个漂亮的入门 https://github.com/bintray/gradle-bintray -plugin

I am working on one library project in android. I want to upload my library to the JCenter. I have created bintray account etc & followed all steps which are mentioned here.

I did below changes in my application module & library module.

Application Module 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')
}

Library Module 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')
}

Latest Project root 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'
    }

When I am building then I am getting this error I spent two days on same but could not get proper solution of it. Please suggest how to resolve it.

Error

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

解决方案

Add in root build.gradle

apply plugin: 'com.jfrog.bintray'

And look at this nice Getting Started https://github.com/bintray/gradle-bintray-plugin

这篇关于错误:“Java的插件已经被应用,但它不是与Android兼容的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆