22 April 2024 Leave a comment Tech-Help
Developers and testers often need to identify the launchable activity of an Android application package. This is especially useful when setting up automated UI tests or when you want to launch an app through the ADB shell. In this guide, we’ll explore a method to obtain the launchable activity name for an application package using the Android Debug Bridge (ADB).
Prerequisites
- ADB installed on your system
- Android device connected to your computer via USB debugging
- Application package name (e.g., com.example.app)
Steps to Find the Launchable Activity
Follow these steps to find the launchable activity of an Android app:
-
Identify the APK file path:
Use the following ADB command to list all packages and their corresponding APK file paths:
adb shell pm list packages -f
-
Pull the APK file:
With the APK path obtained from the previous command, pull the APK file to your local machine using:
adb pull <APK path>
-
Analyze the APK using aapt:
Once you have the APK file on your local system, use the Android Asset Packaging Tool (aapt) to dump the app’s badging information:
aapt dump badging <pulledfile.apk>
Look for the “launchable-activity” attribute in the output, which will give you the activity name.
Alternative Method for Android 7.0 and Above
If you’re working with Android 7.0 (Nougat) or above, there’s a more straightforward command:
adb shell "cmd package resolve-activity --brief com.example.app | tail -n 1"
Replace com.example.app
with the actual package name of the application. The output will display the full activity name you’re looking for.
Integrating with Repeato
Once you have the launchable activity name, you might want to start automating your UI tests. Repeato is a No-code test automation tool for iOS and Android, which can significantly simplify this process. With Repeato, you can:
- Create and run automated tests for your apps with ease, thanks to its No-code approach.
- Utilize computer vision and AI to interact with your app as a user would.
- Work with any app framework, including React Native, Flutter, Unity, and more.
- Execute ADB commands via script steps, offering a seamless integration with tools like ADB.
Repeato’s user-friendly interface and fast test execution make it an excellent choice for teams looking to streamline their testing process without diving deep into code.
Conclusion
Retrieving the launchable activity name of an Android package can be accomplished with a few ADB commands. For developers and testers looking to automate their UI testing, integrating these steps with tools like Repeato can enhance efficiency and accuracy. With Repeato, you can build robust automated tests for a wide range of applications, ensuring your app performs well across different devices and frameworks.