В этом руководстве мы покажем вам, как исправить ошибку «Операция не разрешена: java.lang.SecurityException» при выполнении команды ADB Shell. Возможности безграничны, когда дело доходит до входа в домены ADB и Fastboot. В то время как команды Fastboot в основном пригодятся, когда загрузчик вашего устройства разблокирован или имеет root-права, это не относится к ADB, поскольку вы также можете извлечь максимальный потенциал этих команд в стандартной среде.
Более того, с добавлением команд оболочки adb вы даже можете выполнять некоторые задачи административного уровня на своем устройстве без рута. Однако в последнее время использование этих команд оказалось крепким орешком. Многие пользователи выразили обеспокоенность тем, что всякий раз, когда они выполняют команду оболочки ADB, вместо этого они получают сообщение «Операция не разрешена: ошибка java.lang.SecurityException».
Интересно отметить тот факт, что ПК может идентифицировать устройство в режиме ADB, так как при выполнении команды adb devices CMD перечисляет серийный номер устройства. Более того, даже команда оболочки adb работает хорошо и хорошо, так как она выводит кодовое имя устройства. Однако любая команда, которую вы выполните после этого, приведет к вышеупомянутой ошибке. С учетом сказанного существует несколько отличных обходных путей, которые помогут вам устранить эту ошибку. Итак, без лишних слов, давайте проверим их.
Прежде чем приступить к исправлениям, мы рекомендуем вам сначала отметить следующие предварительные условия. [if not done already]:
Предпосылки
Если ваше устройство соответствует всем этим требованиям, выполните следующие действия, чтобы исправить ошибку «Операция ADB Shell не разрешена: ошибка java.lang.SecurityException».
Исправление для устройств Xiaomi
- Перейдите в «Настройки»> «Дополнительные настройки»> «Параметры разработчика».
- Затем включите переключатель рядом со следующими тремя параметрами: Отладка по USB Отладка по USB (параметры безопасности) Установить через USB
- Теперь повторите попытку выполнения команды оболочки adb, вы больше не получите никаких ошибок.
Исправление для OnePlus, Oppo, Realme
- Перейдите в «Настройки»> «Системные настройки»> «Параметры разработчика».
- Затем отключите отладку по USB. После этого включите переключатель рядом с «Отключить мониторинг разрешений».
- Теперь снова включите отладку по USB и выполните команду оболочки adb, ошибок быть не должно.
Вот и все. Это были шаги по исправлению операции, которая не разрешена: ошибка java.lang.SecurityException при выполнении команды ADB Shell. Если у вас есть какие-либо вопросы относительно вышеупомянутых шагов, сообщите нам об этом в комментариях. Мы вернемся к вам с решением в ближайшее время.
I have a library (jar) on build path of my project. The project accesses the MainActivity in the jar, using the following intent:
final Intent it = new Intent();
it.setClassName("com.example.lib", "com.example.lib.MainActivity");
startActivity(it);
It used to work for sometime, but suddenly started getting ‘ActivityNotFoundException: No Activity found to handle Intent’ which I was able to resolve. But now I am stuck with a ‘java.lang.SecurityException: Permission Denial: starting Intent’.
I have tried all suggestions made on stackoverflow (check for duplicates in manifest file; add android:exported=»true» to lib manifest; Eclipse> Project> Clean; adding/ modifying ‘intent-filter’ tags; etc.). I even tried re-writing the manifest of the project but not going anywhere with it.
Here’s the logcat output:
11-07 06:20:52.176: E/AndroidRuntime(4626): FATAL EXCEPTION: main
11-07 06:20:52.176: E/AndroidRuntime(4626): java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.example.lib/.MainActivity } from ProcessRecord{40dd3778 4626:com.example.project/u0a10046} (pid=4626, uid=10046) not exported from uid 10047
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.os.Parcel.readException(Parcel.java:1425)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.os.Parcel.readException(Parcel.java:1379)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1885)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1412)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Activity.startActivityForResult(Activity.java:3370)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Activity.startActivityForResult(Activity.java:3331)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:824)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Activity.startActivity(Activity.java:3566)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Activity.startActivity(Activity.java:3534)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.example.project.MainActivity.onOptionsItemSelected(MainActivity.java:93)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.Activity.onMenuItemSelected(Activity.java:2548)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:366)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:980)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:547)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:115)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.view.View.performClick(View.java:4204)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.view.View$PerformClick.run(View.java:17355)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.os.Handler.handleCallback(Handler.java:725)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.os.Handler.dispatchMessage(Handler.java:92)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.os.Looper.loop(Looper.java:137)
11-07 06:20:52.176: E/AndroidRuntime(4626): at android.app.ActivityThread.main(ActivityThread.java:5041)
11-07 06:20:52.176: E/AndroidRuntime(4626): at java.lang.reflect.Method.invokeNative(Native Method)
11-07 06:20:52.176: E/AndroidRuntime(4626): at java.lang.reflect.Method.invoke(Method.java:511)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-07 06:20:52.176: E/AndroidRuntime(4626): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-07 06:20:52.176: E/AndroidRuntime(4626): at dalvik.system.NativeStart.main(Native Method)
Manifest XML of Project:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.project"
android:versionCode="4"
android:versionName="4.0" >
<!-- Permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens android:anyDensity="true" />
<!-- SDK Settings -->
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<!-- APP Start -->
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- App Activity -->
<activity
android:name="com.example.project.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Library Activity -->
<activity android:name="com.example.lib.MainActivity" android:label="LibMain">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>
</application>
<!-- END - APP -->
</manifest>
What am I overlooking? Any suggestions?
EDIT
I updated the manifest.xml with all other activities & somehow, that resolved the problem. The intent activity starts up without any errors. BUT, this is only on AVD. On actual device, it is still throwing same error. I have uninstalled the app from device completely and reinstalled, yet the same error.
The SecurityException
is a runtime exception in Java that is thrown by the security manager to indicate a security violation. The SecurityException
is an unchecked exception and does not need to be declared in the throws
clause of a method or constructor.
What Causes SecurityException
The SecurityException
indicates that a security violation occurred during the execution of an application. Therefore, execution cannot be further continued and has to be terminated. An example scenario of a SecurityException
is using a package name for a class in code that is already defined in a signed JAR on the classpath.
SecurityException Example
Here is an example of a SecurityException
thrown when using a package name that overlaps with the package name of a signed JAR file present in the classpath:
package com.rollbar.test;
public class SecurityExceptionExample {
public static void main(String args[]) {
System.out.println("Hello World");
MyObject obj = new MyObject();
}
}
In this example, the package com.rollbar.test
is used for the SecurityExceptionExample
class. However, this package name is already present in a signed JAR (which contains the MyObject
class) in the application classpath. This causes the JVM to throw a SecurityException
when the above code is executed:
Hello World
Exception in thread "main" java.lang.SecurityException: class "com.rollbar.test.MyObject"'s signer information does not match signer information of other classes in the same package
at java.base/java.lang.ClassLoader.checkCerts(ClassLoader.java:1151)
at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:906)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1015)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at com.rollbar.test.SecurityExceptionExample.main(SecurityExceptionExample.java:7)
How to Handle SecurityException
- In cases like the example above, the package name of the application can be changed to resolve the
SecurityException
. - It should also be ensured that all JAR files, especially ones that contain classes from the same packages, are signed using the same certificate. Or the signatures from the manifest of the JAR files with overlapping packages should be removed.
- A
SecurityException
can also be thrown when executing a JAR file. In such cases, it should be verified that the JAR file is properly signed.
Sometimes applications running with a security manager can also throw a SecurityException
. This usually occurs when such applications are trying to access a system resource without the corresponding permissions. Relevant permissions must be explicitly granted to the code attempting to access such resources to make sure security violations do not occur.
Track, Analyze and Manage Errors With Rollbar
Managing Java errors and exceptions in your code is challenging. It can make deploying production code an unnerving experience. Being able to track, analyze, and manage errors in real-time can help you to proceed with more confidence. Rollbar automates error monitoring and triaging, making fixing Java errors easier than ever. Sign Up Today!
Вопрос:
Внезапно я начал получать следующее исключение от устройств, работающих под управлением Android 4.3 и выше
java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.content.GooglePhotosImageProvider from ProcessRecord{454ca9d0 5914:com.propertymanager/u0a10231} (pid=5914, uid=10231) requires com.google.android.apps.photos.permission.GOOGLE_PHOTOS or com.google.android.apps.photos.permission.GOOGLE_PHOTOS
at android.os.Parcel.readException(Parcel.java:1431)
at android.os.Parcel.readException(Parcel.java:1385)
at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2896)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:4755)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2480)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1152)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:759)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:665)
at android.content.ContentResolver.openInputStream(ContentResolver.java:500)
at com.myapp.xxxx.determineCorrectScale(SourceFile:148)
My Код, вызывающий его,
public static int determineCorrectScale(Context con, Uri imagUri) {
int scale = 1;
InputStream imageStream = null;
imageStream = con.getContentResolver().openInputStream(imagUri);
.
.
.
}
Любая помощь?
EDIT:
Так я позволяю пользователю выбрать изображение перед вызовом вышеуказанного метода
Intent choosePictureIntent = new Intent(Intent.ACTION_PICK, Images.Media.INTERNAL_CONTENT_URI);
tartActivityForResult(choosePictureIntent, REQUEST_CHOOSE_IMAGE);
Вот он: OnActivityResult:
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case REQUEST_CHOOSE_IMAGE:
Uri selectedImage = intent.getData();
try {
int scale = CommonFunc.determineCorrectScale(this, selectedImage);
Лучший ответ:
вам нужно добавить это разрешение в свой манифест:
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS"/>
надеюсь, что это сработает для вас. пожалуйста, дайте мне обратную связь
Ответ №1
При добавлении разрешений для этого конкретного поставщика контента он не будет работать, если ваши данные будут доставлены другими поставщиками контента (на Android нет гарантии, что вы получите данные определенным поставщиком контента, если вы явно не получите доступ к этому контенту провайдер).
“Окончательное” решение этой проблемы можно найти здесь:
Получение доступа с временными разрешениями
Вы можете получить доступ к данным в поставщике контента, даже если у вас нет правильные разрешения доступа, отправив намерение к приложению, которое имеет разрешения и возвращает результат содержащие разрешения “URI”. Это разрешения для определенного URL-адрес контента, который длится , пока актив, который их получает, не будет закончил.
http://developer.android.com/guide/topics/providers/content-provider-basics.html
Так как версия 4.3 Android проверяет, продолжает ли выполняющая операция приема, и если не выбрасывает SecurityException. Метод определенияCorrectScale является статическим методом, поэтому я предполагаю, что он по крайней мере иногда вызывается вне жизненного цикла Activity.
Чтобы исправить это раз и навсегда, вам необходимо получить данные от поставщика контента во время работы Activity. Я не знаю требований к вашему приложению, но если нет тяжелой работы (например, копирование изображений из поставщика контента), просто сделайте это на нити ui. Если требуется тяжелая работа, используйте AsyncTask, запущенный Activity, но затем вы должны убедиться, что Activity не завершит работу до того, как данные были извлечены (что может быть сложно).
Я не просто добавил этот ответ, потому что считаю его правильным, но потому, что другие разработчики могут не знать об этом изменении, представленном в 4.3/4.4, и могут столкнуться с той же проблемой с другими поставщиками контента.
in exceptions
October 16th, 2014
Views
In this tutorial we will discuss about SecurityException
in Java. This exception is thrown by the security manager, in order to indicate a security violation.
The SecurityException
class extends the RuntimeException
class and thus, belongs to those exceptions that can be thrown during the operation of the Java Virtual Machine (JVM). It is an unchecked
exception and thus, it does not need to be declared in a method’s or a constructor’s throws clause.
Finally the SecurityException
class exists since the 1.0 version of Java.
The Structure of SecurityException
Constructors
SecurityException()
SecurityException(String s)
SecurityException(String message, Throwable cause)
SecurityException(Throwable cause)
Creates an instance of the SecurityException
class, setting null
as its message.
Creates an instance of the SecurityException
class, using the specified string as message. The string argument indicates the name of the class that threw the error.
Creates an instance of the SecurityException
class, using the specified string as message and the specified Throwable
as its cause.
Creates an instance of the SecurityException
class, using the specified Throwable
as its cause.
The SecurityException in Java
The SecurityException
indicates that a security violation has occurred an thus, the application cannot be executed. A simple example is to use a package name that is already defined in Java.
For example, let’s create a simple hierarchy, where the parent directory is called java
and the sub-directory is called util
. Then, we create a sample Java class inside the java/util/
directory, which only prints a message:
Test.java:
package java.util; class Test { public static void main(String[] args) { System.out.println("Hello World!"); } }
We compile and execute our sample code by issuing the following commands:
javac java/util/Test.java java java.util.Test
A sample execution is shown below:
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.util at java.lang.ClassLoader.preDefineClass(ClassLoader.java:659) at java.lang.ClassLoader.defineClass(ClassLoader.java:758) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:367) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
When the Java Virtual Machine (JVM) tries to load our class, it recognizes its package name as invalid and thus, a SecurityException
is thrown.
How to deal with the SecurityException
- In the aforementioned case, it is sufficient to change the package name of your application, in order to be executed by the Java Virtual Machine (JVM). In general, you must avoid using package names that are reserved by Java.
- Sometimes, executing a
.jar
file can result in aSecurityException
be possibly thrown. In such cases, you must verify that the.jar
file is properly signed, otherwise you will not be able to execute it. For more information on how to sign a.jar
please refer to the instructions here. - Finally, running an applet from an external source may also result in a
SecurityException
be thrown. The most frequent reason is that Java applications are blocked by the underlying security settings. For more information on how to change these settings and how to update your Exception Site list, please refer to the instructions here.
@JuanEstrellaM @mykola-mokhnach
I am still facing the same error, with my phone (Realme X), i have follwed the below steps
First Enable Developer Option second step enable USB Debugging
And very important Step:
Step 3. Search for «Disable Permission Monitoring» and Enable it.
eclipse error log:
below error i am recived after follwing above steps:
java.lang.reflect.InvocationTargetException
Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’ exited with code 255′; Stderr: ‘Security exception: adb clearing user data is forbidden.
java.lang.SecurityException: adb clearing user data is forbidden.
at com.android.server.pm.ColorClearDataProtectManager.interceptClearUserDataIfNeeded(ColorClearDataProtectManager.java:88)
at com.android.server.pm.OppoBasePackageManagerService$OppoPackageManagerInternalImpl.interceptClearUserDataIfNeeded(OppoBasePackageManagerService.java:733)
at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4459)
at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1837)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:212)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:23997)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5100)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4795)
at com.android.server.pm.OppoPackageManagerService.onTransact(OppoPackageManagerService.java:83)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)’; Code: ‘255’
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘DESKTOP-K5JIG48’, ip: ‘192.168.1.10’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_261’
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’ exited with code 255′; Stderr: ‘Security exception: adb clearing user data is forbidden.
java.lang.SecurityException: adb clearing user data is forbidden.
at com.android.server.pm.ColorClearDataProtectManager.interceptClearUserDataIfNeeded(ColorClearDataProtectManager.java:88)
at com.android.server.pm.OppoBasePackageManagerService$OppoPackageManagerInternalImpl.interceptClearUserDataIfNeeded(OppoBasePackageManagerService.java:733)
at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4459)
at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1837)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:212)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:23997)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5100)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4795)
at com.android.server.pm.OppoPackageManagerService.onTransact(OppoPackageManagerService.java:83)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)’; Code: ‘255’
at getResponseForW3CError (C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolerrors.js:804:9)
at asyncHandler (C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolprotocol.js:381:37)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘DESKTOP-K5JIG48’, ip: ‘192.168.1.10’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_261’
Driver info: driver.version: AppiumDriver
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’ exited with code 255′; Stderr: ‘Security exception: adb clearing user data is forbidden.
java.lang.SecurityException: adb clearing user data is forbidden.
at com.android.server.pm.ColorClearDataProtectManager.interceptClearUserDataIfNeeded(ColorClearDataProtectManager.java:88)
at com.android.server.pm.OppoBasePackageManagerService$OppoPackageManagerInternalImpl.interceptClearUserDataIfNeeded(OppoBasePackageManagerService.java:733)
at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4459)
at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1837)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:212)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:23997)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5100)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4795)
at com.android.server.pm.OppoPackageManagerService.onTransact(OppoPackageManagerService.java:83)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)’; Code: ‘255’
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘DESKTOP-K5JIG48’, ip: ‘192.168.1.10’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_261’
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’ exited with code 255′; Stderr: ‘Security exception: adb clearing user data is forbidden.
java.lang.SecurityException: adb clearing user data is forbidden.
at com.android.server.pm.ColorClearDataProtectManager.interceptClearUserDataIfNeeded(ColorClearDataProtectManager.java:88)
at com.android.server.pm.OppoBasePackageManagerService$OppoPackageManagerInternalImpl.interceptClearUserDataIfNeeded(OppoBasePackageManagerService.java:733)
at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4459)
at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1837)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:212)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:23997)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5100)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4795)
at com.android.server.pm.OppoPackageManagerService.onTransact(OppoPackageManagerService.java:83)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)’; Code: ‘255’
at getResponseForW3CError (C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolerrors.js:804:9)
at asyncHandler (C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolprotocol.js:381:37)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘DESKTOP-K5JIG48’, ip: ‘192.168.1.10’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_261’
Driver info: driver.version: AppiumDriver
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94)
at Calculatortest.CalculatorTest.openCalculator(CalculatorTest.java:44)
at Calculatortest.CalculatorTest.main(CalculatorTest.java:16)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:186)
… 12 more
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’ exited with code 255′; Stderr: ‘Security exception: adb clearing user data is forbidden.
java.lang.SecurityException: adb clearing user data is forbidden.
at com.android.server.pm.ColorClearDataProtectManager.interceptClearUserDataIfNeeded(ColorClearDataProtectManager.java:88)
at com.android.server.pm.OppoBasePackageManagerService$OppoPackageManagerInternalImpl.interceptClearUserDataIfNeeded(OppoBasePackageManagerService.java:733)
at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4459)
at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1837)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:212)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:23997)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5100)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4795)
at com.android.server.pm.OppoPackageManagerService.onTransact(OppoPackageManagerService.java:83)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)’; Code: ‘255’
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘DESKTOP-K5JIG48’, ip: ‘192.168.1.10’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_261’
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’ exited with code 255′; Stderr: ‘Security exception: adb clearing user data is forbidden.
java.lang.SecurityException: adb clearing user data is forbidden.
at com.android.server.pm.ColorClearDataProtectManager.interceptClearUserDataIfNeeded(ColorClearDataProtectManager.java:88)
at com.android.server.pm.OppoBasePackageManagerService$OppoPackageManagerInternalImpl.interceptClearUserDataIfNeeded(OppoBasePackageManagerService.java:733)
at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4459)
at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1837)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:212)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:23997)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5100)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4795)
at com.android.server.pm.OppoPackageManagerService.onTransact(OppoPackageManagerService.java:83)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)’; Code: ‘255’
at getResponseForW3CError (C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolerrors.js:804:9)
at asyncHandler (C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolprotocol.js:381:37)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
… 17 more
CMD run log:
[HTTP] —> POST /wd/hub/session
[HTTP] {«desiredCapabilities»:{«appActivity»:»com.android.calculator2.Calculator»,»appPackage»:»com.coloros.calculator»,»platformVersion»:»10″,»platformName»:»Android»,»udid»:»2af3ce9b»,»deviceName»:»Realme X»},»capabilities»:{«firstMatch»:[{«appium:appActivity»:»com.android.calculator2.Calculator»,»appium:appPackage»:»com.coloros.calculator»,»appium:deviceName»:»Realme X»,»platformName»:»android»,»appium:platformVersion»:»10″,»appium:udid»:»2af3ce9b»}]}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{«appActivity»:»com.android.calculator2.Calculator»,»appPackage»:»com.coloros.calculator»,»platformVersion»:»10″,»platformName»:»Android»,»udid»:»2af3ce9b»,»deviceName»:»Realme X»},null,{«firstMatch»:[{«appium:appActivity»:»com.android.calculator2.Calculator»,»appium:appPackage»:»com.coloros.calculator»,»appium:deviceName»:»Realme X»,»platformName»:»android»,»appium:platformVersion»:»10″,»appium:udid»:»2af3ce9b»}]}]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1601963419149 (11:20:19 GMT+0530 (India Standard Time))
[Appium]
[Appium] ======================================================================
[Appium] DEPRECATION WARNING:
[Appium]
[Appium] The ‘automationName’ capability was not provided in the desired
[Appium] capabilities for this Android session
[Appium]
[Appium] Setting ‘automationName=UiAutomator2’ by default and using the
[Appium] UiAutomator2 Driver
[Appium]
[Appium] The next major version of Appium (2.x) will require the
[Appium] ‘automationName’ capability to be set for all sessions on all
[Appium] platforms
[Appium]
[Appium] In previous versions (Appium <= 1.13.x), the default was
[Appium] ‘automationName=UiAutomator1’
[Appium]
[Appium] If you wish to use that automation instead of UiAutomator2, please
[Appium] add ‘automationName=UiAutomator1’ to your desired capabilities
[Appium]
[Appium] For more information about drivers, please visit
[Appium] http://appium.io/docs/en/about-appium/intro/ and explore the
[Appium] ‘Drivers’ menu
[Appium]
[Appium] ======================================================================
[Appium]
[Appium] Appium v1.18.2 creating new AndroidUiautomator2Driver (v1.56.1) session
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver] «alwaysMatch»: {
[debug] [BaseDriver] «platformName»: «android»,
[debug] [BaseDriver] «appium:appActivity»: «com.android.calculator2.Calculator»,
[debug] [BaseDriver] «appium:appPackage»: «com.coloros.calculator»,
[debug] [BaseDriver] «appium:deviceName»: «Realme X»,
[debug] [BaseDriver] «appium:platformVersion»: «10»,
[debug] [BaseDriver] «appium:udid»: «2af3ce9b»
[debug] [BaseDriver] },
[debug] [BaseDriver] «firstMatch»: [
[debug] [BaseDriver] {}
[debug] [BaseDriver] ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 0afbbf37-94f4-4147-996b-980ac0d2ff53
[UiAutomator2] Starting ‘com.coloros.calculator’ directly on the device
[ADB] Found 1 ‘build-tools’ folders under ‘C:UserspriyaAppDataLocalAndroidSdk’ (newest first):
[ADB] C:/Users/priya/AppData/Local/Android/Sdk/build-tools/30.0.2
[ADB] Using ‘adb.exe’ from ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe’
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 start-server’
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices
[debug] [ADB] Connected devices: [{«udid»:»2af3ce9b»,»state»:»device»}]
[AndroidDriver] Using device: 2af3ce9b
[ADB] Using ‘adb.exe’ from ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe’
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 start-server’
[debug] [ADB] Setting device id to 2af3ce9b
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell getprop ro.build.version.sdk’
[debug] [ADB] Current device property ‘ro.build.version.sdk’: 29
[ADB] Getting device platform version
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell getprop ro.build.version.release’
[debug] [ADB] Current device property ‘ro.build.version.release’: 10
[debug] [ADB] Device API level: 29
[UiAutomator2] Relaxing hidden api policy
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell ‘settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1»
[AndroidDriver] No app sent in, not parsing package/activity
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b wait-for-device’
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell echo ping’
[debug] [AndroidDriver] Pushing settings apk to device…
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell dumpsys package io.appium.settings’
[debug] [ADB] ‘io.appium.settings’ is installed
[debug] [ADB] Getting package info for ‘io.appium.settings’
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell dumpsys package io.appium.settings’
[debug] [ADB] The version name of the installed ‘io.appium.settings’ is greater or equal to the application version name (‘3.2.0’ >= ‘3.2.0’)
[debug] [ADB] There is no need to install/upgrade ‘C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesio.appium.settingsapkssettings_apk-debug.apk’
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell ‘pgrep —help; echo $?»
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pgrep -f io.appium.settings’
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pgrep -f io.appium.settings’
[debug] [ADB] Starting Appium Settings app
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell am start -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER’
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pgrep -f io.appium.settings’
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell appops set io.appium.settings android:mock_location allow’
[debug] [Logcat] Starting logs capture with command: C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b logcat -v threadtime
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b forward tcp:8200 tcp:6790’
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell dumpsys package io.appium.uiautomator2.server’
[debug] [ADB] ‘io.appium.uiautomator2.server’ is installed
[debug] [ADB] Getting package info for ‘io.appium.uiautomator2.server’
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell dumpsys package io.appium.uiautomator2.server’
[debug] [ADB] The version name of the installed ‘io.appium.uiautomator2.server’ is greater or equal to the application version name (‘4.12.2’ >= ‘4.12.2’)
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[debug] [ADB] Checking app cert for C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.12.2.apk
[ADB] Using ‘apksigner.jar’ from ‘C:UserspriyaAppDataLocalAndroidSdkbuild-tools30.0.2libapksigner.jar’
[debug] [ADB] Starting apksigner: ‘C:Program FilesJavajdk1.8.0_261binjava.exe’ -Xmx1024M -Xss1m -jar C:UserspriyaAppDataLocalAndroidSdkbuild-tools30.0.2libapksigner.jar verify —print-certs C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.12.2.apk
[debug] [ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[debug] [ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[debug] [ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[debug] [ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[debug] [ADB]
[debug] [ADB] ‘C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.12.2.apk’ is signed with the default certificate
[debug] [ADB] Getting install status for io.appium.uiautomator2.server.test
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell dumpsys package io.appium.uiautomator2.server.test’
[debug] [ADB] ‘io.appium.uiautomator2.server.test’ is installed
[debug] [ADB] Checking app cert for C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-debug-androidTest.apk
[debug] [ADB] Starting apksigner: ‘C:Program FilesJavajdk1.8.0_261binjava.exe’ -Xmx1024M -Xss1m -jar C:UserspriyaAppDataLocalAndroidSdkbuild-tools30.0.2libapksigner.jar verify —print-certs C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-debug-androidTest.apk
[debug] [ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[debug] [ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[debug] [ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[debug] [ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[debug] [ADB]
[debug] [ADB] ‘C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-debug-androidTest.apk’ is signed with the default certificate
[UiAutomator2] Server packages are not going to be (re)installed
[debug] [UiAutomator2] Waiting up to 30000ms for services to be available
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm list instrumentation’
[debug] [UiAutomator2] Instrumentation target ‘io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner’ is available
[debug] [UiAutomator2] No app capability. Assuming it is already on the device
[debug] [ADB] Getting install status for com.coloros.calculator
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell dumpsys package com.coloros.calculator’
[debug] [ADB] ‘com.coloros.calculator’ is installed
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell am force-stop com.coloros.calculator’
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [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
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell am force-stop com.coloros.calculator’
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b forward —remove tcp:8200’
[UiAutomator2] Restoring hidden api policy to the device default configuration
[debug] [ADB] Running ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell ‘settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy»
[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1601963425198 (11:20:25 GMT+0530 (India Standard Time))
[debug] [W3C] Encountered internal error running command: Error executing adbExec. Original error: ‘Command ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’ exited with code 255′; Stderr: ‘Security exception: adb clearing user data is forbidden.
[debug] [W3C]
[debug] [W3C] java.lang.SecurityException: adb clearing user data is forbidden.
[debug] [W3C] at com.android.server.pm.ColorClearDataProtectManager.interceptClearUserDataIfNeeded(ColorClearDataProtectManager.java:88)
[debug] [W3C] at com.android.server.pm.OppoBasePackageManagerService$OppoPackageManagerInternalImpl.interceptClearUserDataIfNeeded(OppoBasePackageManagerService.java:733)
[debug] [W3C] at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4459)
[debug] [W3C] at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1837)
[debug] [W3C] at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:212)
[debug] [W3C] at android.os.ShellCommand.exec(ShellCommand.java:104)
[debug] [W3C] at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:23997)
[debug] [W3C] at android.os.Binder.shellCommand(Binder.java:881)
[debug] [W3C] at android.os.Binder.onTransact(Binder.java:765)
[debug] [W3C] at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5100)
[debug] [W3C] at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4795)
[debug] [W3C] at com.android.server.pm.OppoPackageManagerService.onTransact(OppoPackageManagerService.java:83)
[debug] [W3C] at android.os.Binder.execTransactInternal(Binder.java:1021)
[debug] [W3C] at android.os.Binder.execTransact(Binder.java:994)’; Code: ‘255’
[debug] [W3C] Error: Command ‘C:UserspriyaAppDataLocalAndroidSdkplatform-toolsadb.exe -P 5037 -s 2af3ce9b shell pm clear com.coloros.calculator’ exited with code 255
[debug] [W3C] at ChildProcess. (C:UserspriyaAppDataRoamingnpmnode_modulesappiumnode_modulesteen_processlibexec.js:113:19)
[debug] [W3C] at ChildProcess.emit (events.js:315:20)
[debug] [W3C] at maybeClose (internal/child_process.js:1021:16)
[debug] [W3C] at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
[debug] [W3C] Destroying socket connection
[HTTP] <— POST /wd/hub/session 500 6237 ms — 3879
[HTTP]
Program Code:
package Calculatortest;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
public class CalculatorTest {
static AppiumDriver <MobileElement> driver;
public static void main(String[] args) {
try {
openCalculator();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(e.getCause());
System.out.println(e.getMessage());
e.printStackTrace();
}
}
// TODO Auto-generated method stub
public static void openCalculator() throws Exception
{
DesiredCapabilities cap= new DesiredCapabilities();
//cap.setCapability("deviceName", "OPPO F1s X");
cap.setCapability("deviceName", "Realme X");
//cap.setCapability("udid", "JR55OVOV99999999");
cap.setCapability("udid", "2af3ce9b");
cap.setCapability("platformName", "Android");
cap.setCapability("platformVersion", "10");
cap.setCapability("appPackage", "com.coloros.calculator");
cap.setCapability("appActivity", "com.android.calculator2.Calculator");
//cap.setCapability("appPackage", "com.qaddoo");
//cap.setCapability("appActivity", "com.Qaddoo.mvvm.ui.activities.MainActivity");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
driver =new AppiumDriver<MobileElement>(url, cap);
System.out.println(«Application started»);
}
}
Kinldly help