Io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server

Having following exception. Trying simple application using calculator app. But having following exception:

[Instrumentation] java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} from pid=2337, uid=2337 not allowed because package io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server

[Instrumentation] INSTRUMENTATION_STATUS: Error=Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} from pid=2337, uid=2337 not allowed because package io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server

[Instrumentation] at android.os.Parcel.createException(Parcel.java:2088)

[Instrumentation] at android.os.Parcel.readException(Parcel.java:2056)

[Instrumentation] at android.os.Parcel.readException(Parcel.java:2004)

[Instrumentation] at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:6144)

[Instrumentation] at com.android.commands.am.Instrument.run(Instrument.java:512)

[Instrumentation] at com.android.commands.am.Am.runInstrument(Am.java:196)

[Instrumentation] at com.android.commands.am.Am.onRun(Am.java:80)

[Instrumentation] INSTRUMENTATION_STATUS: id=ActivityManagerService

[Instrumentation] INSTRUMENTATION_STATUS_CODE: -1

[Instrumentation] at com.android.internal.os.BaseCommand.run(BaseCommand.java:56)

[Instrumentation] at com.android.commands.am.Am.main(Am.java:50)

[Instrumentation] at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)

[Instrumentation] at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:339)

[Instrumentation] Caused by: android.os.RemoteException: Remote stack trace:

[Instrumentation] at com.android.server.am.ActivityManagerService.startInstrumentation(ActivityManagerService.java:18151)

[Instrumentation] at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2681)

[Instrumentation] at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3356)

[Instrumentation] at android.os.Binder.execTransactInternal(Binder.java:1021)

[Instrumentation] at android.os.Binder.execTransact(Binder.java:994)

[Instrumentation] The process has exited with code 1

[UiAutomator2] The instrumentation process has been unexpectedly terminated. Retrying UiAutomator2 startup (#1 of 1)

[UiAutomator2] Performing strict cleanup of automation leftovers

[UiAutomator2] No obsolete sessions have been detected (Error: socket hang up)

[ADB] Running ‘C:\Users\prsharma\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 21a92fc11f057ece shell am force-stop io.appium.uiautomator2.server.test’

[ADB] Attempting to kill all uiautomator processes

[ADB] Getting IDs of all ‘uiautomator’ processes

[ADB] Running ‘C:\Users\prsharma\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 21a92fc11f057ece shell pgrep -f uiautomator’

[ADB] No ‘uiautomator’ process has been found

[UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online…

[ADB] Creating ADB subprocess with args: ["-P",5037,"-s",“21a92fc11f057ece”,“shell”,“am”,“instrument”,"-w",“io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner”]

[Instrumentation] INSTRUMENTATION_STATUS: Error=Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} from pid=2489, uid=2489 not allowed because package io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server

[Instrumentation] INSTRUMENTATION_STATUS: id=ActivityManagerService

[Instrumentation] INSTRUMENTATION_STATUS_CODE: -1

[Instrumentation] java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} from pid=2489, uid=2489 not allowed because package io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server

[Instrumentation] at android.os.Parcel.createException(Parcel.java:2088)

[Instrumentation] at android.os.Parcel.readException(Parcel.java:2056)

[Instrumentation] at android.os.Parcel.readException(Parcel.java:2004)

[Instrumentation] at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:6144)

[Instrumentation] at com.android.commands.am.Instrument.run(Instrument.java:512)

[Instrumentation] at com.android.commands.am.Am.runInstrument(Am.java:196)

[Instrumentation] at com.android.commands.am.Am.onRun(Am.java:80)

[Instrumentation] at com.android.internal.os.BaseCommand.run(BaseCommand.java:56)

[Instrumentation] at com.android.commands.am.Am.main(Am.java:50)

[Instrumentation] at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)

[Instrumentation] at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:339)

[Instrumentation] Caused by: android.os.RemoteException: Remote stack trace:

[Instrumentation] at com.android.server.am.ActivityManagerService.startInstrumentation(ActivityManagerService.java:18151)

[Instrumentation] at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2681)

[Instrumentation] at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3356)

[Instrumentation] at android.os.Binder.execTransactInternal(Binder.java:1021)

[Instrumentation] at android.os.Binder.execTransact(Binder.java:994)

[Instrumentation] The process has exited with code 1

[UiAutomator2] Error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.

[UiAutomator2] at Object.wrappedLogger.errorAndThrow (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:79:13)

[UiAutomator2] at UiAutomator2Server.errorAndThrow [as startSession] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\uiautomator2.js:227:13)

[UiAutomator2] Deleting UiAutomator2 session

[UiAutomator2] Deleting UiAutomator2 server session

[WD Proxy] Matched ‘/’ to command name ‘deleteSession’

[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id

[ADB] Running ‘C:\Users\prsharma\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 21a92fc11f057ece shell am force-stop com.android.calculator2’

[Logcat] Stopping logcat capture

[ADB] Removing forwarded port socket connection: 8200

[ADB] Running ‘C:\Users\prsharma\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 21a92fc11f057ece forward --remove tcp:8200’

[UiAutomator2] Restoring hidden api policy to the device default configuration

[ADB] Running ‘C:\Users\prsharma\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 21a92fc11f057ece shell settings delete global hidden_api_policy_pre_p_apps’

[ADB] Running ‘C:\Users\prsharma\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 21a92fc11f057ece shell settings delete global hidden_api_policy_p_apps’

[ADB] Running ‘C:\Users\prsharma\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 21a92fc11f057ece shell settings delete global hidden_api_policy’

[BaseDriver] Event ‘newSessionStarted’ logged at 1584255535613 (12:28:55 GMT+0530 (India Standard Time))

[W3C] Encountered internal error running command: Error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.

[W3C] at Object.wrappedLogger.errorAndThrow (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:79:13)

[W3C] at UiAutomator2Server.errorAndThrow [as startSession] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\uiautomator2.js:227:13)

[HTTP] <-- POST /wd/hub/session 500 37590 ms - 906

[HTTP]

This is my code:

package WhatAppPayment.TestAutomation;

import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

public class AppTest {

AndroidDriver<WebElement> driver ;

@Test
public void testCaseWhatApp() throws MalformedURLException, InterruptedException {		
	
	DesiredCapabilities capabilities = new DesiredCapabilities();
	
	capabilities.setCapability("deviceName", "Galaxy S9");

	capabilities.setCapability("platformName","Android");
	capabilities.setCapability("platformVersion", "10");
	
	/*capabilities.setCapability("appPackage", "com.whatsapp");
	capabilities.setCapability("appActivity", "com.whatsapp.HomeActivity");*/
	
	capabilities.setCapability("appPackage", "com.android.calculator2");
	capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
	
	capabilities.setCapability("autoGrantPermissions", "true");
	
	File file = new File("C:\\Users\\prsharma\\Appium\\TestAutomation\\APK_File\\Calculator_v7.8 (271241277)_apkpure.com.apk");
	capabilities.setCapability("app", file.getAbsolutePath());
	
	URL url = new URL("http://127.0.0.1:4723/wd/hub");		
	driver = new AndroidDriver<WebElement>(url, capabilities);
	Thread.sleep(5000);
	// locate the Text on the calculator by using By.name()
    WebElement seven = driver.findElementById("com.android.calculator2:id/digit_7");
    seven.click();
    WebElement plus = driver.findElementById("com.android.calculator2:id/op_add");
    plus.click();
    WebElement three = driver.findElementById("com.android.calculator2:id/digit_3");
    three.click();
    WebElement equalTo = driver.findElementById("com.android.calculator2:id/eq");
    equalTo.click();

    // locate the edit box
    WebElement results = driver.findElementById("com.android.calculator2:id/formula");

    if(results.getText().equals("10"))
    {
        System.out.println("Test Passed...");
    }
    else
    {
        System.out.println("Test Failed...");
    }
}

	 
}

I am not getting whats the final solution??

Updating the appium to new version fixed the issue

1 Like

@prsharma Thank you, just updating to latest Appium version resolved the issue for me too…

1 Like

If I add the below line to the above code I can repro this issue on the latest release of Appium version 1.15.0 and on 1.13.0.
The problem goes away with the pre-release build 1.17.0

capabilities.setCapability(“automationName”, “UiAutomator2”);

I have the same issue, on version 1.15.1. Happens regardless of whether or not I explicitly specify UiAutomator2 for the automationName.

Switching to 1.17.0 (prerelease) causes this problem to go away.