【问题标题】:Not able to upload the generated .aar file to local maven repository in android studio with gradle build dystem无法使用 gradle build dystem 将生成的 .aar 文件上传到 android studio 中的本地 maven 存储库
【发布时间】:2015-05-12 23:54:58
【问题描述】:

我正在使用带有 Gradle 作为构建系统的 android studio。我有一个库项目和应用程序项目。

图书馆 - 图书馆项目。 应用-应用项目

Gradle 和 android studio 生成 .aar 文件而不是 .jar 文件。 所以我想将生成的 .aar 文件作为依赖项添加到我的应用程序项目中。

由于 android studio 和 gradle wrapper 不支持将 .aar 文件添加为应用程序项目的依赖项,因此我尝试将 .aar 文件上传到本地 maven 存储库。

将 .aar 文件上传到本地 maven 存储库的 build.gradle 代码如下。

apply plugin: 'maven'
apply plugin: 'android-library'


dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
        instrumentTest.setRoot('tests')
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

 repositories {
        mavenLocal()
    }

configurations {
    resultArchives
}

uploadResultArchives {
    repositories {
        mavenDeployer {
            repository(url: 'C:/Users/test/.m2/repository')
        }
    }
}
artifacts{
    resultArchives file: file('build/output/aar/Library-debug.aar')
}

设置信息:Android studio1.1.0 Gradle 包装器:2.2.1

提前感谢您的帮助!!!

【问题讨论】:

    标签: android maven android-studio gradle


    【解决方案1】:

    我不是 gradle pro。但我认为这会奏效:

    group = 'Library-debug'
    
    uploadArchives{
        repositories{
             mavenDeployer{
                 repository(url: uri('C:/Users/test/.m2/repository'))
             }
        }
    }
    

    您的 aar 将在“C:/Users/test/.m2/repository/[your package name]/Local-debug.aar”上可用

    【讨论】:

      猜你喜欢
      • 2021-07-20
      • 1970-01-01
      • 2017-12-26
      • 1970-01-01
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      • 2018-03-11
      • 1970-01-01
      相关资源
      最近更新 更多