0

We have a Xamarin Forms Application updated to 5.0 all the builds are successful including the Android binding libraries. Switched from Proguard to r8 due to multiple errors occurring on release build.

The main issue we have is on release mode where some features on Here SDK for Android (Premium Edition) versions 3.16 to 3.20 are no longer working like SearchRequest and TextAutoSuggestionRequest. Both of these are working if Code shrinker is set to blank or running in Debug. When in Release and r8 SearchRequest doesn't return any result. While TextAutoSuggestionRequest would crash the application with the following error:

W System.err: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.nokia.maps.AutoSuggestImpl
W System.err: at com.nokia.maps.PlacesTextAutoSuggestionResult.a(Unknown Source:34)
W System.err: at com.nokia.maps.PlacesBaseRequest.c(Unknown Source:253)
W System.err: at com.nokia.maps.PlacesBaseRequest.onResult(Unknown Source:57)
W System.err: at com.nokia.maps.PlacesBaseRequest.poll(Native Method)
W System.err: at com.nokia.maps.PlacesBaseRequest.d(Unknown Source:0)
W System.err: at com.nokia.maps.PlacesBaseRequest$h.a(Unknown Source:33)
W System.err: at com.nokia.maps.PlacesBaseRequest$h.doInBackground(Unknown Source:2)
W System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333)
W System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W System.err: at java.lang.Thread.run(Thread.java:764)
W System.err: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.nokia.maps.AutoSuggestImpl
W System.err: at com.nokia.maps.PlacesTextAutoSuggestionResult.a(Unknown Source:34)
W System.err: at com.nokia.maps.PlacesBaseRequest.c(Unknown Source:253)
W System.err: at com.nokia.maps.PlacesBaseRequest.onResult(Unknown Source:57)
W System.err: at com.nokia.maps.PlacesBaseRequest.poll(Native Method)
W System.err: at com.nokia.maps.PlacesBaseRequest.d(Unknown Source:0)
W System.err: at com.nokia.maps.PlacesBaseRequest$h.a(Unknown Source:33)
W System.err: at com.nokia.maps.PlacesBaseRequest$h.doInBackground(Unknown Source:2)
W System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333)
W System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W System.err: at java.lang.Thread.run(Thread.java:764)

I used the same config file from Proguard settings and adding more -keep class lines almost adding all the package names

Also tried the following but not working:

  • disable Multidex
  • AOT Compilation + Use LVVM
  • tried VS 2022 Enterprise from VS 2019

Is there anything I missed to make r8 build be deployed with out issue?

Thank you,

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
Ryan
  • 1
  • 1
  • *"some features on Here SDK for Android (Premium Edition) versions 3.16 to 3.20 are no longer working"* If you don't include that SDK, do you have any problem with r8? – ToolmakerSteve Jul 05 '22 at 22:59
  • only these 2 calls on the SDK are not working. GeocodeRequest and turn by turn navigation are both working – Ryan Jul 06 '22 at 11:44
  • I am afraid we can't reproduce this problem on our side. Could you please post a basic demo here so that we can test on our side? – Jessie Zhang -MSFT Jul 07 '22 at 08:17
  • To replicate 1) Create Xamarin Forms application 2) Create Android binding library from Here SDK 3.20 3) Edit metadata for transforms 4) Add some code to call TextAutoSuggest from the SDK 5) Build in Release mode with d8 r8 settings then deploy 6) During runtime call the auto suggest then application will crash with the error above – Ryan Jul 07 '22 at 14:23
  • According to suggested fix on https://learn.microsoft.com/en-us/answers/questions/915331/visual-studio-xamarin-r8-build.html. Adding gson to Proguard config would fix the type erasure. This works on VS2022 but fails to build on VS2019 – Ryan Jul 07 '22 at 14:28

0 Answers0