android / android/android-test

androidx.test.internal.runner.InstrumentationConnection.init error in androidU

Open
#1,907 1 comment 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
In androidU,if the app target is 34 , when we registerReceiver,we must use the RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED flag , but the class InstrumentationConnection did not do this when it int.
so my app is crash on androidU devices

the error code in InstrumentationConnection is on line 173
targetContext.registerReceiver(messengerReceiver, new IntentFilter(BROADCAST_FILTER));

### Expected Results
I want the class InstrumentationConnection on line 173 like this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
targetContext.registerReceiver(messengerReceiver, new IntentFilter(BROADCAST_FILTER),Context.RECEIVER_EXPORTED);
} else {
targetContext.registerReceiver(messengerReceiver, new IntentFilter(BROADCAST_FILTER));
}
### Link to a public git repo demonstrating the problem:
https://developer.android.google.cn/guide/components/broadcasts#context-registered-receivers

Contributor guide

Open the contributing guide

Research direction

Start at InstrumentationConnection line 173, where targetContext.registerReceiver is called, and review the Android U receiver-registration requirement described in the issue. Done means an app targeting API 34 no longer crashes on Android U devices while registration continues to work on older Android versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.