无法获得未知财产' outputFile' for task':app:packageDebug'

时间:2017-07-19 09:26:11

标签: android gradle build output testfairy

我尝试从终端执行命令:./ gradlew testfairyDebug。 这会返回下一个错误:

  

失败:构建因异常而失败。

     

出了什么问题:   任务':app:testfairyDebug'执行失败。    无法获得未知财产' outputFile' for task':app:packageDebug' com.android.build.gradle.tasks.PackageApplication类型。

你有任何想法解决这个问题。 有关信息,我在Android Studio 3上工作,我的gradle版本是' com.android.tools.build:gradle:3.0.0-alpha6'

我的build.gradle:


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

    buildscript {
        ext.kotlin_version = '1.1.2-4'
        repositories {
            maven { url 'https://maven.google.com' }
            maven { url 'https://www.testfairy.com/maven' }
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.0-alpha6'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.testfairy.plugins.gradle:testfairy:1.+'

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


    allprojects {
        repositories {
            jcenter()
            maven { url 'https://maven.google.com' }
            mavenCentral()
        }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    } 

和我的app.build.gradle:


    apply plugin: 'com.android.application'

    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'

    apply plugin: 'testfairy'

    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.2"
        defaultConfig {
            applicationId "com.name.application"
            minSdkVersion 15
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }

        testfairyConfig {
            apiKey "xxxxxxxxxxxxxxxxxxxxxxxx"
        }
    }

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
        //noinspection GradleCompatible
        compile 'com.android.support:appcompat-v7:25.3.1'
        testCompile 'junit:junit:4.12'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.android.support:design:25.3.1'
        compile 'org.greenrobot:eventbus:3.0.0'
        compile 'com.squareup.retrofit2:retrofit:2.1.0'
        compile 'com.squareup.retrofit2:converter-gson:2.1.0'
        compile 'com.lorentzos.swipecards:library:1.0.9'
        compile 'com.github.rey5137:material:1.2.2'
        compile 'com.squareup.picasso:picasso:2.5.2'
        // Android SDK
        compile 'com.facebook.android:facebook-android-sdk`enter code here`:4.+'
        compile 'org.greenrobot:eventbus:3.0.0'
        compile 'com.android.support:recyclerview-v7:25.1.1'
        compile 'testfairy:testfairy-android-sdk:1.+@aar'

    }

非常感谢。

2 个答案:

答案 0 :(得分:4)

错误表示您正在尝试访问" outputFile'来自PackageApplication。但是我没有在你的gradle文件中看到它。也许它是由你的一个模块引起的?如果是这种情况,则使用Gradle插件3.0打破用于操纵变体输出的Variant API。只有简单的任务才有效查看此页面:https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#variant_api

答案 1 :(得分:1)

是否可以将TestFairy gradle插件更新为版本2.+

将类路径com.testfairy.plugins.gradle:testfairy:1.+更改为com.testfairy.plugins.gradle:testfairy:2.+ 在build.gradle文件的dependencies部分中。