android / android/android-test

ActivityScenario does not work with MultiDex on API level < 21

Open
#1,433 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description
Hello,

I've noticed that ActivityScenario does not launch Activities when running MultiDex'ed applications on devices before API level 21.

### Steps to Reproduce
1. Use ActivityScenario
2. Enable MultiDex
3. Deploy on pre Lollipop device
### Expected Results
ActivityScenario launching Activity

### Actual Results
```
> Task :app:connectedDebugAndroidTest
Starting 1 tests on test(AVD) - 4.4.2
com.viliussutkus89.activityscenarioissue.ExampleInstrumentedTest > useAppContext[test(AVD) - 4.4.2] FAILED
java.lang.AssertionError: Activity never becomes requested state "[DESTROYED, STARTED, RESUMED, CREATED]" (last lifecycle transition = "PRE_ON_CREATE")
at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338)
Tests on test(AVD) - 4.4.2 failed: There was 1 failure(s).
```

### AndroidX Test and Android OS Versions
API levels 16, 17, 18 and 19.
```
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
```
### Link to a public git repo demonstrating the problem:
Recreated the issue from "Empty Activity" template project: https://github.com/ViliusSutkus89/ActivityScenarioIssue
Emulator run: https://github.com/ViliusSutkus89/ActivityScenarioIssue/actions/runs/2698898492

Thank you for looking into this :)

Contributor guide

Open the contributing guide

Research direction

Start with the linked ActivityScenarioIssue reproduction and the failure at ActivityScenario.java:338. Run its instrumentation test on a pre-Lollipop API level with MultiDex enabled, then compare the observed lifecycle transition with the expected activity launch. Done means ActivityScenario successfully launches the activity on the listed pre-21 API levels.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.