android - 任务 'install' 在根项目 'TestApp' 中不明确。候选为: 'installDebug' , 'installDebugAndroidTest'

标签 android maven android-studio gradle jcenter

我正在 android 中开发一个库项目。我想将我的库上传到 JCenter。我已经创建了 bintray 帐户等并遵循了此处提到的所有步骤 http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en

我在我的应用程序模块和库模块中做了以下更改。

应用模块build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"


    defaultConfig {
        applicationId "com.app.testapp"
        minSdkVersion 8
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }


}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile project(':testlib')
}

库模块build.gradle

apply plugin: 'com.android.library'

ext {
    bintrayRepo = 'maven'
    bintrayName = 'test-sdk'

    publishedGroupId = 'in.test.sdk'
    libraryName = 'testlib'
    artifact = 'test-sdk'

    libraryDescription = 'A wrapper for Facebook Native Like Button (LikeView) on Android'

    siteUrl = 'https://github.com/xyz/testsdk'
    gitUrl = 'https://github.com/xyz/testsdk.git'

    libraryVersion = '1.0.0'

    developerId = 'xyz'
    developerName = 'xyz'
    developerEmail = 'xyz@xyz.xyz'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}

version = "1.0.0"
android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
           // proguardFiles 'proguard-project.txt'
        }
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
        }
    }


}

dependencies {
    compile 'com.android.support:support-v4:22.2.0'
    compile files('libs/gson-2.3.1.jar')
    compile files('libs/android-query-full.0.26.8.jar')
    compile files('libs/httpmime-4.1.1.jar')
    compile files('libs/jackson-annotations-2.5.0.jar')
    compile files('libs/javax.annotation.jar')
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile files('libs/okhttp-2.3.0.jar')
    compile files('libs/okio-1.3.0.jar')
    compile files('libs/retrofit-1.9.0.jar')
}

项目根目录build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
        classpath 'com.github.dcendents:android-maven-plugin:1.2'

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


}

allprojects {

    repositories {
        jcenter()
    }
}

当我执行此操作时 gradlew install 然后我收到此错误

FAILURE: Build failed with an exception.

* What went wrong:          
Task 'install' is ambiguous in root project 'TestApp'. Candidates are: 'installDebug', 'installDebugAndroidTest'.

* Try:                      
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED                

Total time: 11.685 secs   

我在同一个问题上花了三天时间,但无法得到正确的解决方案。请建议如何解决它。

最佳答案

也许您忘记将这些行添加到库模块 build.gradle 的末尾:

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

关于android - 任务 'install' 在根项目 'TestApp' 中不明确。候选为: 'installDebug' , 'installDebugAndroidTest',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32243402/

相关文章:

android - Android 应用程序中 shell 命令的语法

java - Maven 尝试再次下载 ojdbc14.jar - jar 已经存在于本地存储库中

maven - 为什么在尝试使用 Grails Release 插件中的 publish-plugin 时得到 400

java - 不支持的类版本错误 : org/apache/maven/plugin/compiler/TestCompilerMojo

java - 在一定时间后更改变量

java - 从 EditTexts 添加新项目到 SQLite 数据库时出错

Android Studio 2.1.2 渲染问题。 VectorDrawable_Delegate.nDraw

Android 主屏幕小部件大小(以像素为单位)

ART中的Android自修改代码

android - 来自 Android camera2 API 的图像数据在 Galaxy S5 上翻转和挤压