发布 AAR 到 maven

Publishing AAR to maven

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

这是我图书馆的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 未找到。

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