Closed kust-wulin closed 4 years ago
@kust-wulin if it's production code, so I assume you cannot debug, could you add a couple of Log.i
to understand what's going on in the code you're running and where the glitch happens? Otherwise, there are so many variables and I cannot give you a precise answer to your issue.
@abusuioc thanks for the feedback. I can pinpoint the error now. In my code, I have a line of code: LocationData position = await _location.getLocation(); In debug version of the code, this call return position. However, in release version of the code, this call immediately throws an exception. PlatformException(UNEXPECTED_ERROR, -5:Core error, null) My cellphone is a Huawei's phone.
Do you know why I got this exception?
I have checked the source code of location and changed the error message to find which line throws this exception. The line throws this exception is: FlutterLocation.java:417 sendError("UNEXPECTED_ERROR", e.getMessage(), null);
Since the debug version of the code works, I expect the release version will return the location instead of throwing an exception. In simulator, the code runs without error. My location version is 3.0.2
I have tested on:
Android 9, API Level 28, real device
@abusuioc I have found the following two links that may solve my issue. https://stackoverflow.com/questions/63280882/flutter-hms-core-plugin-integration-error https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/configuration-obfuscation-script
I have checked the source code. I found file proguard-rules.pro is located at hms-gms-wrapper-location-1.0-beta-1\lib Does this mean I have to compile all the source codes by myself? Or you will update the hms-gms-wrapper-location-1.0-beta-1 and provide a new version which excludes hms from obfuscate.
Thanks a lot. Have a nice day.
@abusuioc Thanks a lot for your sincere help. Now I have solved the issue. My solution is:
My project is created by Android Studio. So I guess my solution works for all Android Studio users. You may want to update your README.md, so that people using your library will not meet this issue again.
Thanks a lot again. Have a nice day.
@kust-wulin thanks a lot for your persistence in figuring out what the issue was.
Please try the 1.0-beta-2
( implementation 'com.github.abusuioc:hms-gms-wrapper-location:1.0-beta-2'
). The issue is now fixed in the library and there is no need for you to modify your app code with the obfuscation configuration.
@abusuioc Thanks. I should thank you for providing us a wonderful solution for the hms and gms issue. This solution helps us a lot. Contributing to it is our duty for using it.
I cannot pinpoint what went wrong this time. My debug version of apk can run correctly, but the released version of apk just hangs up. No error message, never return. What files are you needed to help me to fix this issue?