问题
I am trying to build a solution in Xamarin with an android library that I imported.
The library come from a manufacturer called bbpos.
I have the following error message :
Error com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.String using a local variable of type byte[]. This is symptomatic of .class transformation tools that ignore local variable information.
I think it comes from the library but i dont know from where exactly. Is there a way to know where is the problem ?
回答1:
In case it my help someone else i have finally found the solution.
It turns out the compiler was the problem.
I went to the Xamarin.Android Properties, then went to the Android Options tab. In the Dex compiler field I selected d8.
回答2:
It's quite likely that the library you received isn't built correctly. If you remove the library and the build goes through normally, the problem is definitely there. The thing is, I haven't seen this problem in years and it's quite surprising to see now.
Just to be sure, are you talking about a jar library, not a dll? The (likely) root cause of the problem is explained well in other posts here and here. What you should do to resolve your issue is to try two things:
- Build your application with ProGuard enabled.
- If that doesn't work, run the library itself through ProGuard as suggested by one of the posts I linked to.
来源:https://stackoverflow.com/questions/58344368/error-local-variable-type-mismatch-in-xamarin-android