本文介绍了Gradle Maven 插件“安装"任务不适用于 Android 库项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 android 库项目安装到本地 maven 存储库.这是build.gradle:

I want to install android library project to local maven repository.Here is build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android-library'
apply plugin: 'maven'

version = "1.0.0-SNAPSHOT"
group = "com.example"

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 18
    }
}

当我跑步时:

gradle install -i

它卡在这里:

Executing task ':project:installTest' due to:
  Task has not declared any outputs.
Starting process 'command 'd:android-sdk-windowsplatform-toolsadb.exe''. Working directory: D:Projectsjava....... Command: d:android-sdk-windowsplatform-toolsadb.exe install -r D:Projectsjava.......uildapkproject.apk
An attempt to initialize for well behaving parent process finished.
Successfully started process 'command 'd:android-sdk-windowsplatform-toolsadb.exe''
> Building > :project:installTest

所以我注意到的第一件事是它出于某种奇怪的原因试图将其作为 APK 部署在设备上.

So first thing I noticed is that it's trying for some odd reason to deploy it on a device as APK.

我做错了什么还是只是android-library插件与maven插件不兼容?

Am I doing something wrong or is it just android-library plugin not compatible with maven plugin?

推荐答案

请参考github页面(https://github.com/dcendents/android-maven-gradle-plugin) 以获取最新说明并找到要使用的正确版本.原始说明不再适用于最新的 gradle 版本.

Please refer to the github page (https://github.com/dcendents/android-maven-gradle-plugin) for the latest instructions and find the correct version to use. The original instructions are not suitable anymore with the latest gradle release.

原帖:

我已经修改了 maven 插件以与 android 库项目兼容.项目见github:https://github.com/dcendents/android-maven-gradle-插件

I've modified the maven plugin to be compatible with android library projects. See the project on github: https://github.com/dcendents/android-maven-gradle-plugin

配置您的 android 库项目以使用它:

Configure your android library projects to use it:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.github.dcendents:android-maven-plugin:1.0'
    }
}

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

然后您应该可以使用安装任务将 aar 安装到您的本地 Maven 存储库中.

Then you should be able to install aar into your local maven repository using the install task.

希望这会有所帮助,如果您发现插件有问题,请在 github 上告诉我,我会修复它.

Hope this helps, if you find issues with the plugin please let me know on github and I'll fix it.

这篇关于Gradle Maven 插件“安装"任务不适用于 Android 库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 20:49