2

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

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

应用程序模块 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
4

1 回答 1

2

添加根 build.gradle

apply plugin: 'com.jfrog.bintray'

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

于 2015-08-31T11:37:07.743 回答