Appium - runAppInBackground throws WebDriverException - android

I'm using Appium to automate the tests of an Android app. Recently I stuck on an error while trying to test the behavior of the app when it gets pushed to background and relaunched again. I was lucky, that I found the method appiumDriver.runAppInBackground(Duration duration).
...But when I'm executing appiumDriver.runAppInBackground(Duration.ofSeconds(1)); I receive an exception.
I run the tests on an android Emulator (PIXEL_API_25) and I use Appium 1.7.2 with java_client 5.0.4, but in future, they should also run on iOS.
The appiumDriver variable is static (not sure if this could make a difference...).
Thank you for any help!

Meanwhile I've found a solution which works for me.
With updating Appium from 1.7.2 to 1.8.1 the issue is resolved.

Its pretty clear what went wrong in stacktrace:
Original error: 'Command ''C:\\Users\\User\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' -P 5037 -s emulator-5554 shell am start -W -n de.abc.myApp/.BookingOverviewActivity' exited with code 1'; Stderr: 'java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=de.abc.myApp/.BookingOverviewActivity } from null (pid=7759, uid=2000) not exported from uid 10224
Appium failed to launch your app back from background because of permission restriction. Try with 5 seconds and different device.
If still reproduced: to fix it, you need to update you application source code with android:exported="true" in manifest file for BookingOverviewActivity activity.

Related

adb: failed to open app.apk: Operation not permitted with flutter

I am facing this issue when trying to run any flutter app on android emulator or physical device. It fails while executing adb command for installing the application.
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to open /Users/mohitsingh/Desktop/testapp/testapp/build/app/outputs/flutter-apk/app.apk: Operation not permitted
Warning: Failed to install APK.
However if I run the same command manually, It fails with the same error for the first time after app is built with flutter build apk command but it is successfully installed on subsequent trials with
adb -s emulator-5554 install build/app/outputs/flutter-apk/app.apk
All other commands of adb seem to work fine. It was working fine till last week but this error started coming up suddenly with adb.
Error: ADB exited with exit code 1 is a common error
Here are the following solutions for that
Solution 1
add android:exported="true in your AndroidManifest.xml file
<activity android:name=".MainActivity"
android:exported="true"
Solution 2
Turn on Install via USB in developer mode.
run the following Command
flutter clean
flutter pub
flutter run

Android Studio how to boot on quick mode after this error?

Here is my first issue with Android Studio. I'm starting to learn Kotlin, I was following a tutorial, but then I decided to start again with a template, so after start a template I got this error when I tried to launch the emulator. I have no idea why is happening that.
10/17 23:24:34: Launching 'app' on Nexus 6P API 27.
Installation did not succeed.
The application could not be installed.
Installation failed due to: ''cmd package install-create -r -t -S 2918030' returns error 'Unknown failure: cmd: Can't find service: package''
Retry
If I start the emulation in the cold boot option, there is no issue. I would like to start it in the quick boot mode.

React Native - Error calling AppRegistry.runApplication

When I run a simple "AwesomeProject" app as stated in React Native Getting started page, the app runs on Nexus6 API 23 but error is shown. I also tried the following methods to solve the error:
adb reverse tcp:8081 tcp:8081, but doesn't work.
"react-native start" in command line before running the app but it does not show anything after "Loading Dependency Graph, done."
Running it on Nexus5X API 25 but still error occurs.
How do I solve it?
I found out that by typing:
react-native start --port 8081
in the command line, and running app by opening another cmd shell, I was able to run the app successfully. Thanks.

Cannot start application in android studio emulator since 2.0 update

I recently (2 days ago) updated my Android Studio to version 2.0.
After having troubles with my previously working application on a real device, I had to activate MultiDex to remove errors in the logcat...
All is working fine now, as it was before the update.
But when I try to launch my application in the emulator from Android Studio (which was working before the update) I face a strange error without any explanation (this is from the Android Studio "4: Run" tab):
04/13 13:20:40: Launching app
No apk changes detected since last installation, skipping installation of /.../app/build/outputs/apk/app-debug.apk
$ adb shell am force-stop com.android.test
$ adb shell am start -n "com.android.test/com.android.test.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Unexpected error while executing: am start -n "com.android.test/com.android.test.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while Launching activity
(I replaced the entire location by /.../ in the above lines as this is not relevant to the problem...)
The strange fact is the application works perfectly well on the AVD if launched manually (by clicking on the application icon on the virtual device)!
Now if you guys have an idea of what is happening and how to get rid of it, it would be nice.
PS: I tried removing the MultiDex, nothing changed, facing same issue...
The new "instant run" feature is a bit buggy still, delete the app manually on your virtual device and run the code again.
Sorry for write on outdated post , but i had same problem. I was using AVD with arm processor image and received this same message.
The only way for me to make Android Studio 2.1.2 runs the app with instant run was change to a X86 processor image.

Unable to debug in android studio (Error running app: java.lang.Error : no Connectors loaded. Check your JDK installation.)

I am using Android studio 1.02 on Linux Mint. I was able to successfully debug my code on android emulators and my device LG G2 till yesterday. Today when I started my workstation I cant 'debug' my code.
It says:
Error running navigationbar: java.lang.Error : no Connectors loaded.
Check your JDK installation.
On my device I can see the message:
Waiting for the Debugger
Application NavigationBar (com.example.test.navigationbar) is
waiting for the debugger to attach.
and following are the console messages
Waiting for device. Target device: lge-lg_My_DEVICE'sID
Uploading file local path:
/path-to-apk/apk/navigationbar-debug.apk
remote path: /data/local/tmp/com.example.test.navigationbar
Installing com.example.test.navigationbar DEVICE SHELL COMMAND: pm
install -r "/data/local/tmp/com.example.test.navigationbar" pkg:
/data/local/tmp/com.example.test.navigationbar Success
Launching application:
com.example.test.navigationbar/com.example.test.navigationbar.NavigationBar.
DEVICE SHELL COMMAND: am start -D -n
"com.example.test.navigationbar/com.example.test.navigationbar.NavigationBar"
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER Starting: Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER]
cmp=com.example.test.navigationbar/.NavigationBar }
Waiting for process: com.example.test.navigationbar Can't start
debugging.
As advices on some older posts. I have already tried :
android:debuggable="true"
Restarting android studio and my PC
Uncheck and then select again 'Enable ADB integration'
Try to debug on emulator(gives the same problem)
Make a new program from the android-studio's templates and try to debug it
On the other hand if I 'run' my application. It gives no such error.
Finally, if I run android.sh form my terminal then I get this message after I choose my device:
java.util.ServiceConfigurationError: com.sun.jdi.connect.Connector:
Provider com.sun.tools.jdi.SunCommandLineLauncher could not be
instantiated java.util.ServiceConfigurationError:
com.sun.jdi.connect.Connector: Provider
com.sun.tools.jdi.RawCommandLineLauncher could not be instantiated
java.util.ServiceConfigurationError: com.sun.jdi.connect.Connector:
Provider com.sun.tools.jdi.SocketAttachingConnector could not be
instantiated java.util.ServiceConfigurationError:
com.sun.jdi.connect.Connector: Provider
com.sun.tools.jdi.SocketListeningConnector could not be instantiated
Kindly advice steps to resolve this issue.
Thanks
Some links I already tried:
Not Able To Debug App In Android Studio
Finally I uninstalled my JDK8 and installed JDK7 this time.
Then if I open Android-Studio. It gave the errors that 'jdk8 not found'.
Upon this I typed :
rm -R -f ~/.AndroidStudio/
To delete all the settings related to Android-Studio.
Now when you run Android studio it will ask you to install/initialize it again.
That worked for me!!
Note: Till now I was working comfortably with JDK8. Only today due to some change I got the error.

Categories

Resources