R8 and Proguard Rules

烂漫一生 提交于 2020-07-31 04:42:14

问题


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?


回答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.



来源:https://stackoverflow.com/questions/63110559/r8-and-proguard-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!