android / android/codelab-android-dynamic-features

FindViewById returns negative values For Dynamic Feature Module

Open
#54 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
129
Forks
51
PR merge metrics
No merged PRs in 30d

Description

I'm trying to use the DFM in my project but somehow it's returning negative values for my views, below is my project configuration:
```
**build.gradle(feature-moduleA)**
defaultConfig {
applicationId "com. sample.app"
minSdkVersion 28
targetSdkVersion 33
compileSdk 33
}
```
` findViewById(R.id.tvMsg).id // -2147418111
`
Now the catch is if we change the "minSdkVersion=24" automatically findViewById started returning the postive value:
```
**build.gradle(feature-moduleA)**
defaultConfig {
applicationId "com. sample.app"
minSdkVersion 24
targetSdkVersion 33
compileSdk 33
}
```
` findViewById(R.id.tvMsg).id // 2139095043`

Can you please provide the solution for this, I've to use minSdkVersion= 28 in my project.

Contributor guide

Open the contributing guide

Research direction

Start with build.gradle(feature-moduleA) and the code path containing findViewById(R.id.tvMsg). Reproduce the behavior with minSdkVersion 28 and 24, then compare the generated resource IDs and Android build configuration; done means the cause and a verified fix or project-specific reproduction are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.