30 November 2024 Leave a comment Tech-Help
When attempting to install an APK using the adb install
command, users may encounter the INSTALL_FAILED_TEST_ONLY
error. This issue typically arises when the APK is flagged as a test-only package, which requires specific installation permissions. Below, we explore several effective solutions to address this problem.
Understanding the Error
The INSTALL_FAILED_TEST_ONLY
error occurs when an APK is marked as test-only in its manifest file. This attribute is often set during development to ensure the APK is not published or distributed inadvertently. To resolve this issue, you can either modify the APK or adjust your installation approach.
Solution 1: Modify the AndroidManifest.xml
The most direct solution is to modify the AndroidManifest.xml
file of your APK:
- Open the
AndroidManifest.xml
file. - Locate the attribute
android:testOnly="true"
. - Change it to
android:testOnly="false"
or remove the attribute entirely.
After making these changes, rebuild your APK and attempt the installation again.
Solution 2: Use the -t
Flag
If you prefer not to modify the APK itself, you can use the -t
flag with the adb install
command to allow the installation of test-only packages:
$ adb install -t your_app.apk
This command enables the installation of the APK without making changes to the manifest file.
Solution 3: Adjust Build Configuration
For those using Android Studio, the test-only attribute is automatically added when using the Run button. To generate an installable APK, follow these steps:
- Navigate to
Build > Build APK(s)
in Android Studio. - This process generates an APK that is not flagged as test-only, allowing for installation via standard methods.
Solution 4: Update gradle.properties
Another approach involves modifying the gradle.properties
file:
android.injected.testOnly=false
Add this line to your gradle.properties
file to override the test-only flag during build.
Enhancing Your Testing Workflow with Repeato
While the above solutions address the INSTALL_FAILED_TEST_ONLY
error, optimizing your testing workflow can further streamline app development. Repeato, our no-code test automation tool, offers a seamless testing experience for iOS and Android applications. With its ability to execute ADB commands through script steps, Repeato ensures precise test execution and timing, enhancing the reliability of your test outcomes. For more information on how Repeato can support your testing needs, explore our Android Testing Tool documentation.