Test running failed: Permission Denial: starting instrumentation ComponentInfo

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Test running failed: Permission Denial: starting instrumentation ComponentInfo



Test running failed: Permission Denial: starting instrumentation ComponentInfocom.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. Commenting it so that it can be useful for someone else.
– Rizwan_Khan
Feb 24 '15 at 5:13




4 Answers
4



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.



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:


debug


testBuildType


android


build.gradle


android
...
testBuildType "release"



Clean Your Project.



Uninstall app if already install.



Now Run your project.



It's Completely Working for me.



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.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS