maven - 错误:The 'java' plugin has been applied,但与Android插件不兼容

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

我正在开发一个 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 = '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="087071724870717226707172" rel="noreferrer noopener nofollow">[email protected]</a>'

    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

最佳答案

在根build.gradle中添加

apply plugin: 'com.jfrog.bintray'

看看这个不错的入门 https://github.com/bintray/gradle-bintray-plugin

关于maven - 错误:The 'java' plugin has been applied,但与Android插件不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32305239/

相关文章:

java - 如何使用ember部署的jar

maven - java.lang.IllegalArgumentException:实例化 'org.apache.spark.sql.hive.HiveSessionState'时出错:使用spark session 读取csv文件时

Android Studio 2.2 不显示任何带有 java.lang.NullPointerException 的项目

android-studio - 尝试使用 Adob​​e Creative SDK 图像编辑制作 Android Studio 应用程序,无法在 gradle 中编译库

gradle - 将所有依赖项从一个 Gradle 模块导入到另一个

android - 使用不同的 VersionCode 进行调试/发布 android gradle build

java - 如何在maven项目中构建包含jar包的war

android - 如何在Android studio中打开来自GitHub的项目? Maven 和 android 支持库的问题。

android - 如何运行 Android Wear 签名的 apk?

Android gradle 构建失败,出现 Nullpointer 异常