0

I am using https://github.com/amalChandran/trail-android this library in my android project. The animation was working perfectly fine. But, after enabling R8, the animation is not working. The library does not have any Proguard suggestion. I added the following block in one of my method,

googleMap.setOnMapLoadedCallback(() -> {

    Route normalOverlayPolyline = new Route.Builder(mRouteOverlayView)
        .setRouteType(RouteType.PATH)
        .setCameraPosition(mMap.getCameraPosition())
        .setProjection(mMap.getProjection())
        .setLatLngs(mRoute)
        .setBottomLayerColor(Color.YELLOW)
        .setTopLayerColor(Color.RED)
        .create();
map.setOnCameraMoveListener(() -> mRouteOverlayView.onCameraMove(map.getProjection(), map.getCameraPosition()));

Where I have two global variables defined,

public Route route;
public RouteOverlayView mRouteOverlayView;

Now, I have some details in my usage.txt

public void onCameramove(com.google.android.gms.maps.GoogleMap,com.obhai.polyline.trail.RouteOverlayView)

Is there any way to write something in proguard-rules.pro so that R8 doesn't remove this part?

Mihodi Lushan
  • 670
  • 5
  • 24
  • 1
    Hi, I work on the R8 team. In the snippet from `usage.txt` is the method from a class in the `com.amalbit.trail` package? One way to start narrowing down the issue would be by stating with keeping the whole package with `-keep class com.amalbit.trail.**` and see is that helps. Then narrow down the parts which need to be kept. Are you using the latest version of Android Studio? Does the same happen with the demo app from https://github.com/amalChandran/trail-android? Feel free to file a bug on https://issuetracker.google.com/issues/new?component=326788 if this looks like an R8 issue. – sgjesse Jul 28 '20 at 06:52
  • thanks for your suggestion @sgjesse I will definitely try this and get back to you. – Mihodi Lushan Jul 28 '20 at 19:29

1 Answers1

1

Thanks to @sgjesse for his hint. I finally got my narrowed down proguard rule to keep my feature functioning.

-keep class com.amalbit.trail.AnimationRouteHelper { *;}

adding this rule served my purpose.

Mihodi Lushan
  • 670
  • 5
  • 24
  • 1
    Good to hear. Maybe create a pull request on `https://github.com/amalChandran/trail-android` to put this information into their `README.md` or in a library provided keep rule. – sgjesse Aug 05 '20 at 11:53