Jump to content
Alex40

Rad Studio 11.1 - Android v. 12 - Android Service is throwing an error: com.embarcadero.rtl.NativeDispatchException: Invoke error: method "onLocationChanged" not found

Recommended Posts

I am trying to use my App with Android Service for Location running in the background. App crashes after service is being started, I see the following error in the Log cat:

 

10-14 11:12:45.861: E/AndroidRuntime(30933): com.embarcadero.rtl.NativeDispatchException: Invoke error: method 'onLocationChanged(Ljava/util/List;)V' not found
10-14 11:12:45.861: E/AndroidRuntime(30933):     at com.embarcadero.services.LocationServiceProxyInterface.dispatchToNative2(Native Method)
10-14 11:12:45.861: E/AndroidRuntime(30933):     at com.embarcadero.services.LocationServiceProxyInterface.invoke(LocationServiceProxyInterface.java:26)

 

image.thumb.png.58cee204c788cf6480852a77f4932b32.png

 

I found out that another person was struggling with the same issue after upgrading from Rad Studio 11 to 11.1 and after regenerated the new .java files:

 

https://stackoverflow.com/questions/72807321/android-12-on-locationchanged-has-invalid-location

 

Unfortunately there is no answer / fix to his report about this error.

 

I tried a lot ot things but nothing helped fixing this issue.

 

This issue is happening on Android 12.

 

Android 10 is working fine (not tested on Android 11).

 

If I upgrade to Rad Studio 11.2 is it possible to fix this issue?

 

------------------------------------------------------------

 

Another question: 

 

Is it mandatory to target sdk version 31 (with exported=true) in the android manifest template if I want to run fully compatible app on Android 12?

 

Because after I put 31 in the target sdk version (with exported=true), my app is built but can't be installed on the device after that.

 

The error that the .apk file throws is: Error parsing the file. (Same thing happens on Android 10 device)

 

Any help would be higly appreciated!

 

Thank you in advance !

Edited by Alex40

Share this post


Link to post
3 hours ago, Alex40 said:

If I upgrade to Rad Studio 11.2 is it possible to fix this issue?

Yes, the issue is fixed in 11.1, so 11.2 also has the fix.

3 hours ago, Alex40 said:

Is it mandatory to target sdk version 31 (with exported=true) in the android manifest template if I want to run fully compatible app on Android 12?

It's only mandatory if publishing to the Play Store.

3 hours ago, Alex40 said:

The error that the .apk file throws is: Error parsing the file. (Same thing happens on Android 10 device)

It should report the line/char that it fails on, so you should be able to tell where the problem is

Share this post


Link to post
21 hours ago, Dave Nottage said:

Yes, the issue is fixed in 11.1, so 11.2 also has the fix.

I am already with Rad Studio 11.1, but I am still getting this error:

 

com.embarcadero.rtl.NativeDispatchException: Invoke error: method 'onLocationChanged(Ljava/util/List;)V' not found

 

image.thumb.png.22c92f4b1af5a9af902611622e4bb9fb.png

 

Edited by Alex40

Share this post


Link to post
10 hours ago, Alex40 said:

I am already with Rad Studio 11.1, but I am still getting this error:

Are you using TLocationSensor? That's where it was fixed. If you're attempting to use JLocationListener on its own, you'll need to modify the class that implements it, such as in the Unit14.pas attachment, here: https://quality.embarcadero.com/browse/RSP-39566

Share this post


Link to post
On 10/15/2022 at 10:28 PM, Dave Nottage said:

Are you using TLocationSensor? That's where it was fixed. If you're attempting to use JLocationListener on its own, you'll need to modify the class that implements it, such as in the Unit14.pas attachment, here: https://quality.embarcadero.com/browse/RSP-39566

I am using JLocationListener.

 

Your modifications definitely fixed my issue, as described in the Embarcadero Thread. 

 

Thank you very much!

  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×