将AAR发布到maven

时间:2015-03-17 15:05:25

标签: android maven gradle android-library aar

我正在向maven发布aar文件。我已经成功上传了所有内容,但是当我将我的库的依赖项添加到示例项目时,它没有来自我的项目的源文件。

这是我的库的build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    // Volley
    compile 'com.mcxiaoke.volley:library:1.0.14'
    // Gson
    compile 'com.google.code.gson:gson:2.3.1'
}

这是我的项目的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.android.library'

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.2'

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

allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    sourceSets {
        main {
            manifest.srcFile 'app/src/main/AndroidManifest.xml'
            java.srcDirs = ['app/src/main/java/com/ebrick/TestSpot']
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    // Volley
    compile 'com.mcxiaoke.volley:library:1.0.14'
    // Gson
    compile 'com.google.code.gson:gson:2.3.1'
}

apply from: 'maven_push.gradle'

如果我从项目build.gradle中删除了sourceSet,它会给我发错误AndroidManifest.xml。

1 个答案:

答案 0 :(得分:1)

更改版本号解决了我的问题。