Test running failed: Permission Denial: starting instrumentation ComponentInfo

Test running failed: Permission Denial: starting instrumentation ComponentInfo{com.xxx.taskmanager.warehouse.tests/android.test.InstrumentationTestRunner} from pid=766, uid=766 not allowed because package com.xxx.taskmanager.warehouse.tests does not have a signature matching the target com.xxx.taskmanager.warehouse Empty test suite. This is my app.gradle file

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

}

I think this error is happening because I have not declared the signingConfigs for test package. If so , how do I declare it. ? Please help. !!

I have solved the issue. Answering it so that it can be useful for someone else. Solution is for Android Studio : For the tests to run , the build variant should be debug. Build Variants window is present in the left side of the android studio, if not activated then activate it by click on Build variants tab present on the left side of the android studio.

java.lang.SecurityException: Permission Denial:, I assume your test app is defining itself as an instrumentation of your main app. Doing this allows your test app to run in the main app's process,  Sometimes I will zip up both the Android project and the (Robotium) test project, upload them to google docs, and then download that onto a laptop for a little poking around. If you don't rebuild/clean the project being tested, then the test project may not work and you get something like this error:

You either have to change your build variant to debug, or add a testBuildType to your android tag inside your build.gradle file. Like this:

android {
    ...
    testBuildType "release"
}

package com.test does not have a signature matching the target , "Test run failed: Permission Denial: starting instrumentation ComponentInfo{com.​test/android.test.InstrumentationTestRunner} from pid=277  V1.11.1 desktop Unable to run appium after install. zipAlignApk failed - was looking for an apk that does not exist in installation -appium-uiautomator2-server-debug-androidTest.apk #849 Open

  1. Clean Your Project.

  2. Uninstall app if already install.

Now Run your project.

It's Completely Working for me.

Permission denial exception starting instrumentation · Issue #302 , Permission denial exception while starting instrumentation Appium: latest SecurityException: Permission Denial: starting instrumentation ComponentInfo{io​.appium.espressoserver.test/ BaseCommand.run(BaseCommand.java:51) at Can you confirm when noSign is set it fails on session creation? Android Instrumentation Testing - A Permission Denial Issue On a project I am working with, I ran into an issue where the android instrumentation test runner (android.test.InstrumentationTestRunner) was complaining that my test package's signature did not match the signature for the target package.

Had the same problem even with Android Studio 3.x years later. Previous answers did not work for me.

Only cure was to explicitly add the permissions to the test app on the phone.

How to handle Test Run Failed : Permission denial error, Hi, I am first time testing the APK file. I dont have source code for the same APK [2013-01-28 14:27:08 - Test_Project] Test run failed: Permission Denial: starting instrumentation ComponentInfo{PACKAGE.test/android.test. Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Android Error, Android Error - Test run failed: Permission Denial: starting instrumentation ComponentInfo. Sometimes I will zip up both the Android project and  The problem Failure occurred when attempting to start the app if set automationName as uiautomator2. Already try to uninstall io.appium.uiautomator2.server and io.appium.uiautomator2.server.test manually, then rerun, still not work. Environment Appium version (or git revision) that exhibits the issue: v1.10.0 Last Appium version

Appium 1.8.1 trying to get espresso running - Support, SecurityException: Permission Denial: starting instrumentation There is a problem when I try to run Android Screengrab on Bitrise. SecurityException: Permission Denial: starting instrumentation ComponentInfo{com.wpky.test/​android.support.test.runner. Fastlane match fails to import private key into keychain hot 1. Describe the bug Tests fail to run Expected behavior Tests should run Steps to reproduce the behavior: Try to run tests Environment Version of Kiwix Android : master Device : Galaxy S8 OS version : 8.0.1 Logs Can't get log back as can't

Android Instrumentation Testing - A Permission Denial , I have a UI test which starts an installed app (on android & ios simulator) These are run nightly on a MAC MINI. I cannot pin point when exactly this initially failed but lately we have updated Permission Denial: starting instrumentation ComponentInfo{com.myapp.test/sh.calaba.instrumentationbackend. If I run the appium server on my Mac Air and run the exact same client (same repo), it works fine.. But when I run appium server on remote Mac Mini, I get these errors. Only difference in setup is, that the Mac Mini has plenty of Android devices connected to it directly via USB, so I have to use udid capability to choose one.

Comments
  • I have solved the issue. Commenting it so that it can be useful for someone else.