xerxes720
xerxes720

Reputation: 379

Unable to find instrumentation target package firebase error

I'm writing an instrumentation test for my app in a separated empty project using UIAutomator and AndroidJUnit4 as runner. It runs well on my device. For testing it on Firebase, it needs the application APK which I provided, and the test APK which I took from C:\Users\user\MyApplication\app\build\outputs\apk\androidTest\debug and when I run the test it fails with this error:"Unable to find instrumentation target package:" am I missing something?

I created another manifest into the androidTest package and the target package is red with "cannot resolve symbol" and nothing changed.

I also changed the targetPackage to the name of the package of the application I'm trying to test, in case that was the problem, and nothing changed.

My androidTest manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.myapplication.test"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk android:minSdkVersion="18" android:targetSdkVersion="28"/>


    <instrumentation
        android:targetPackage="com.example.myapplication"
        android:name="androidx.test.runner.AndroidJUnitRunner"
        />

    <application
        tools:replace="label" android:label="SampleTest"/>


</manifest>

Upvotes: 1

Views: 1135

Answers (1)

xerxes720
xerxes720

Reputation: 379

After a lot of research, I found out that gradle changes the target package automatically to the application package name which I'm writing test on. So I had to move my tests to my application project and generate test apk from it, so it will have the same target package while setting the same signature for both.

Upvotes: 1

Related Questions