How can i find a current apk version whie using appium? - automation

I want to find a current apk version while executing my automation script.

You can get it via adb: dumpsys package <your app package> | grep version
And here you can find example how to run adb command via appium

Related

fix Android Studio React-Native WSL won't launch emulator with more errors

I'm new to android studio. I downloaded Bumblebee and then followed the react-native quick start installation guide react-native installation
I will open Android studio and within the terminal run npx react-native init MyApp, cd MyApp, npx react-native start, npx react-native run-android. I get the errors:
error Failed to launch emulator. Reason: No emulators found as an output of 'emulator -list-avds'
Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version. Class name for the included build object: org.gradle.composite.internal.DefaultIncludedBuild$IncludedBuildImpl_Decorated.
6 actionable tasks: 4 executed, 2 up-to-date
Note: /mnt/c/Users/RandallTaylor/Mobile/App3/node_modu
* What went wrong:
Could not determine the dependencies of task ":app:compileDebugJavaWithJavac".
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at "/mnt/c/Users/RandallTaylor/Mobile/App3/android/local.properties"
/ note local.properties exists. I attempted with the linux and windows path version as SDK manager points to the Microsoft OS where it exits. and still get this error /
I've spent two days on this reading stack overflow thread with no progress. Any advice would be appreciated.
SetUp and local system info:
Windows 10
Processor AMD Ryzen 7 PRO 5850U
wsl --status
Default Distribution: Ubuntu-20.04
Default Version: 2
Windows Subsystem for Linux was last updated on 4/27/2022
WSL automatic updates are on.
Kernel version: 5.10.102.1
Android Studio Bubblebee
SDK manager -> SDK Platorms -> Android 11.0R with Android SDK Platform 30, Source for Android
30, Intel x86 Aton Sytem Image
SDK Tools -> 30.0.2 installed
Environment Variables -> ANDROID_HOME C:\Users\UserName\AppData\Local\Android\Sdk
ANDROID_ROOT same as ANDROID_HOME
JAVA_HOME C\Users\UserName\Desktop
cmdline-tools\external\com\google\guava\guava\30.1-jre
Inital setup
You need to install on your Windows 10 Android Studio.
Set user variable: ANDROID_HOME=C:\Users<YOUR_USER>\AppData\Local\Android\Sdk
Add to system variable PATH:
%ANDROID_HOME%\emulator
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
Then go to your WSL2 and install:
sudo apt-get install unzip
get android studio Command Line Tools Only and unzip it into /home/Android
install jdk 8 with sudo apt-get install openjdk-8-jdk
add this to your .bashrc/.zshrc:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
export ADB_SERVER_SOCKET=tcp:$WSL_HOST:5037
export ANDROID_HOME=$HOME/Android
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
restart bash and run sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
run adb version && adb.exe version check if versions match
Running on emulator
Start emulator run emulator -avd <YOUR_AVD_NAME> - don't close terminal window!
run adb kill-server and adb -a -P 5037 nodaemon server start - don't close terminal window!
run adb devices and check you device port, e.g. device port is 5554.
form your wsl terminal run socat -d -d TCP-LISTEN:5554,reuseaddr,fork TCP:$(cat /etc/resolv.conf | tail -n1 | cut -d " " -f 2):5554, to install socat sudo apt-get install socat.
you should be all set up now.
run yarn start inside project folder and then click 'a' to run android emulator, it takes me about 4-5 minutes.
EDITED
You can skip steps 3-6 and connect to emulator by inserting expo url manually without waiting minutes.

React native- run android

When placing react-native run-android it marks me this error: error The application could not be installed. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run the CLI with the --verbose flag for more details.
Error: command failed: application gradlew.bat: installDebug -PreactNativeDevServerPort = 8081
the emulator I am using is the Genymotion
As it says follow the steps of setupping environment https://reactnative.dev/docs/environment-setup
Also, I can advise you to check your bash profile if you are using macOS.
Crete bash profile if it is not created by: touch ~/.bash_profile; in the terminal.
And after run in terminal to open open ~/.bash_profile

"Spawn unknown" error while using npm's OpenFin

I installed OpenFin-cli using npm on windows 10. After OpenFin was installed, I tried to test it using the command
openfin -l -u https://apple.com
on cmd. I get the following error:
I have:
Node version 6.11.2
Link to OpenFin documentation that I referred: https://openfin.co/documentation/getting-started/
Can you try deleting the %LOCALAPPDATA%/OpenFin directory & re-running or downloading the OpenFinRVM.exe as suggested in this github issue
You can also try just manually launching the RVM by invoking the .exe with --config=http://yourappjsonurl.json
I believe the asset wasn't fully retrieved

Build react-native run-android on windows

I try build react-native run-android on windows this bug appear
then i do follow the answer on this github issue try Command chmod 755 android/gradlew on root folder but chmod' is not recognized as an internal or external command,
operable program or batch file. i think this answer for linux . Some body help me . Thanks for reading my question
The error states that you neither have any android device connected nor do you have emulator running. Follow this guide for android setup.
If you already have android setup and running emulator, try restarting it and run following commands:
Try running following commands:
cd android && ./gradlew clean
cd .. && react-native run-android
From your question seems like you are not started your emulator or device connected.
Follow this steps:-
1.Open your CMD/Terminal from your system
write this command cd "YOUR PATH TO ANDROID SDK"
for example, mine looks like::-
cd /Users/trainee02/Library/Android/sdk/platform-tools
and then hit enter.
3.after enter in directory write this command
export PATH="/Users/YOUR SYSTEM USER NAME/Library/Android/sdk/platform-tools":$PATH
above command is for running android from MAC pc.
then last command is
4.adb reverse tcp:8081 tcp:8081
hit enter
or you can check reference that given in official site
Running On Device React Native
You must update Tools sdk revision 23.0.1 on Android Studio

How start and install apk to specific android emulator by Gradle?

Gradle 2.14
If I want to install the application to the connected device I use the next command:
gradlew installDebug
OK.
But also I have 4 emulators (not started). I want by one gradle command to START emulator my_emulator_name and install my application to this emulator. Something like this:
gradlew installDebug my_emulator_name
Is this a possible?
I came here looking for the same thing. I also asked ChatGPT but didn't get a working answer. Gradle tasks can be defined with code so you could make your own, or maybe there is a way to do it with the android gradle tasks. I'm not seeing simple options there..
I know this is not the answer but it will achieve the same result. Assemble an apk and install it with adb -s. For example:
$ adb devices
List of devices attached
real-device device
emulator-5554 device
emulator-5556 device
$ ./gradlew my-app:assembleDebug
$ adb -s emulator-5554 install -r my-app/build/outputs/apk/debug/my-app.apk