Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
120 views
in Technique[技术] by (71.8m points)

java - Gradle Maven plugin "install" task does not work with Android library project

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
    }
}

When I run:

gradle install -i

it gets stuck here:

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

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Edit: 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.

Original Post:

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

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'

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...