Search code examples
androidbaidubaidu-map

Baidu maps release build crash : NoSuchMethodError: no static method "Lvi/com/gdi/bgl/android/java/EnvDrawText; following sample baidu map app


I integrated baidu maps as per the sample code available from the baidu maps sdk example center.

Everything works fine, but in the release build baidu map crashes everytime.

The error was something like this.

NoSuchMethodError: no static method "Lvi/com/gdi/bgl/android/java/EnvDrawText;

I was wondering what the reason could be.


Solution

  • The issue was with a missing proguard config. When is set minifyEnabled to false it works fine. So added this extra line -keep class vi.com.gdi.bgl.android.** {*; } to the baidu maps proguard rules. Final set of rules become ...

    # Baidu Map rules
    -keep class com.baidu.** {*;}
    -keep class mapsdkvi.com.** {*;}
    -keep class vi.com.gdi.bgl.android.** {*; }
    -dontwarn com.baidu.**
    

    And the crash is gone.