Skip to content

-renamesourcefileattribute should not be in library consumer ProGuard rules #370

Description

@khurram18

Summary

The bundled proguard.txt consumer rules in rollbar-android contain a global ProGuard/R8 option (-renamesourcefileattribute) that should not be specified in library consumer rules. Android's build tooling flags this as a violation and reports it to developers via lint.

Steps to Reproduce

  1. Add rollbar-android as a dependency in any Android project
  2. Run Android Studio's built-in code analyzer (or build with lint enabled)
  3. Observe the following warning:

The consumer keep rules at rollbar-android-2.2.0/proguard.txt contains a global option which should not be specified in library consumer rules:
-renamesourcefileattribute rollbar

Root Cause

rollbar-android's proguard.txt contains:

-renamesourcefileattribute rollbar

-renamesourcefileattribute is a global ProGuard/R8 option. When placed in a library's consumer rules it is applied to the entire app, not just the library's own classes. This means:

  • It overrides the app developer's own -renamesourcefileattribute setting
  • If multiple libraries include conflicting global options, behaviour is unpredictable
  • Android's build tools explicitly flag global options in consumer rules as incorrect practice

Expected Behaviour

Library consumer rules should only contain -keep, -keepclassmembers, -dontwarn, and similar scoped rules. Global options like -renamesourcefileattribute must not be in consumer rules.

Suggested Fix

Remove -renamesourcefileattribute rollbar from proguard.txt and instead document it in the integration guide as something the app developer should add manually to their own
proguard-rules.pro if they want Rollbar's source mapping behaviour:

# Add to your app's proguard-rules.pro if using Rollbar source mapping
-renamesourcefileattribute SourceFile Environment - rollbar-android version: 2.2.0
- Android Gradle Plugin: 9.1.1
- R8 / ProGuard 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions