mapbox / mapbox/mapbox-navigation-android

Incorrect proguard configuration for `Mapbox_TripNotificationModuleConfiguration`

Open
#4,689 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

jira-sync-complete
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

**Mapbox Navigation SDK version:** 1.6.1

### Steps to trigger behavior

1. Create a custom trip notification as explained [here](https://docs.mapbox.com/android/navigation/guides/modularization/#replacing-a-module)
2. Enable code shrinking and obfuscation by adding `minifyEnabled true` to the `build.gradle` file
3. Build the app

### Expected behavior
The generated `Mapbox_TripNotificationModuleConfiguration` class and its nested interface `ModuleProvider` are annotated with `@Keep` rules to prevent the code shrinking tool from removing it from the app,

### Actual behavior
Only the `Mapbox_TripNotificationModuleConfiguration` has the `@Keep` annotation and the `ModuleProvider` doesn't. This forces library user to manually add a keep rule to their `proguard-rules.pro` file (e.x. `-keep interface com.mapbox.module.Mapbox_TripNotificationModuleConfiguration$ModuleProvider { *; }
`)

Here's how the generated class looks like now (the `ModuleProvider` is missing the `@Keep` annotation)
``` kotlin
/**
* Configuration provider for TripNotification module.
*/
@Keep
object Mapbox_TripNotificationModuleConfiguration {
@JvmStatic
val enableConfiguration: Boolean = true

/**
* Set this dependency provider before initializing any components of the modularized library.
*
* When you're not using the library anymore, you should pass `null` to clean up the provider
* reference and prevent memory leaks.
*/
@JvmStatic
var moduleProvider: ModuleProvider? = null

interface ModuleProvider {
fun createTripNotification(): TripNotification
}
}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the source or generation entry point for Mapbox_TripNotificationModuleConfiguration, then compare its annotations with the nested ModuleProvider interface. Use the minifyEnabled true scenario from the issue and the proguard-rules.pro workaround to verify that the generated interface is retained without a manual keep rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.