android-studio – 测试运行失败:权限拒绝:启动检测ComponentInfo

前端之家收集整理的这篇文章主要介绍了android-studio – 测试运行失败:权限拒绝:启动检测ComponentInfo前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
测试运行失败:权限拒绝:从pid = 766开始检测ComponentInfo {com.xxx.taskmanager.warehouse.tests / android.test.InstrumentationTestRunner},不允许使用uid = 766因为包com.xxx.taskmanager.warehouse.tests不允许有一个匹配目标com.xxx.taskmanager.warehouse的签名
空的测试套件.
这是我的app.gradle文件
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'

android {
signingConfigs {
    release
    {
        keyAlias 'xxx'
        keyPassword 'xxx'
        storeFile file('../keystore.jks')
        storePassword 'xxx'
    }
}
compileSdkVersion 16
buildToolsVersion "21.1.2"
defaultConfig {
    applicationId "com.xxx.taskmanager.warehouse"
    minSdkVersion 16
    targetSdkVersion 16
    versionCode 3
    versionName "3.0"
    testApplicationId "com.xxx.taskmanager.warehouse.tests"
}
packagingOptions {
    exclude 'Meta-INF/LICENSE.txt'
    exclude 'Meta-INF/LICENSE'
    exclude 'LICENSE'
    exclude 'NOTICE'
    exclude 'Meta-INF/NOTICE'
    exclude 'Meta-INF/NOTICE.txt'
    exclude 'Meta-INF/ASL2.0'
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        signingConfig signingConfigs.release
    }
}
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.outputFile = new File(
                output.outputFile.parent,"FLO_HANDHELD_V${variant.versionName}.apk"
        )
    }
}

variantFilter { variant ->
    if(variant.buildType.name.equals('debug')) {
        variant.setIgnore(true);
    }
}
productFlavors {
    production_b2b {
        applicationId "com.xxx.taskmanager.warehouse"
        minSdkVersion 16
        targetSdkVersion 16
        versionCode 3
        versionName "3.1-Prod-B2B"
    }
    stage_b2b {
        applicationId "com.xxx.taskmanager.warehouse"
        minSdkVersion 16
        targetSdkVersion 16
        versionCode 3
        versionName "3.1-Stage-B2B"
    }
    production_b2c {
        applicationId "com.xxx.taskmanager.warehouse"
        minSdkVersion 16
        targetSdkVersion 16
        versionCode 3
        versionName "3.1-Prod-B2C"
    }
    stage_b2c {
        applicationId "com.xxx.taskmanager.warehouse"
        minSdkVersion 16
        targetSdkVersion 16
        versionCode 3
        versionName "3.1-Stage-B2C"
    }
}
}

dependencies {
compile fileTree(dir: 'libs',include: ['*.jar'])
compile files ('libs/android-support-v7-appcompat.jar')
compile files('libs/android-support-v4.jar')
compile project(':taskmanagerlib')
compile files('libs/DataCollection.jar')
androidTestCompile fileTree(dir: 'libs',include: 'robotium-solo-5.3.0.jar')
}
task copyTask(type: Copy) {
from 'build/outputs/apk'
into 'apks'
exclude '**/*-unaligned.apk'
}
task deleteApk(type: org.gradle.api.tasks.Delete){
//    delete 'apks'
}
task appBuild(dependsOn: ['deleteApk','clean','assembleRelease','copyTask']){
assembleRelease.mustRunAfter deleteApk
clean.mustRunAfter deleteApk
copyTask.mustRunAfter assembleRelease

}

我认为这个错误正在发生,因为我没有为测试包声明signedConfigs.如果是这样,我该如何申报. ?
请帮忙. !

解决方法

我已经解决了这个问题.回答它,以便它对其他人有用. 解决方案适用于Android Studio: 要运行测试,构建变量应该是debug. Build Variants窗口出现在android studio的左侧,如果没有激活,则点击android studio左侧的Build variants选项卡激活它.

猜你在找的Android相关文章