Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaRuntimeException #21

Closed
pratik037 opened this issue Jun 17, 2019 · 14 comments
Closed

JavaRuntimeException #21

pratik037 opened this issue Jun 17, 2019 · 14 comments

Comments

@pratik037
Copy link

The line marked with asterik seems to be caused because of the geocoder plugin when used with flutter_google_places plugin

Restarted application in 2,320ms.
W/ResourceType(12219): No package identifier when getting name for resource number 0x00000000
I/Google Maps Android API(12219): Google Play services package version: 17455021
I/art     (12219): Do full code cache collection, code=506KB, data=486KB
I/art     (12219): After code cache collection, code=490KB, data=447KB
W/ResourceType(12219): No package identifier when getting name for resource number 0x00000000
W/ResourceType(12219): No package identifier when getting name for resource number 0x00000000
E/AndroidRuntime(12219): FATAL EXCEPTION: AsyncTask #2
E/AndroidRuntime(12219): Process: com.example.memories, PID: 12219
E/AndroidRuntime(12219): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime(12219): 	at android.os.AsyncTask$3.done(AsyncTask.java:318)
E/AndroidRuntime(12219): 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
E/AndroidRuntime(12219): 	at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
E/AndroidRuntime(12219): 	at java.util.concurrent.FutureTask.run(FutureTask.java:242)
E/AndroidRuntime(12219): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
E/AndroidRuntime(12219): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/AndroidRuntime(12219): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/AndroidRuntime(12219): 	at java.lang.Thread.run(Thread.java:760)
**E/AndroidRuntime(12219): Caused by: java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #2 **
E/AndroidRuntime(12219): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:605)
E/AndroidRuntime(12219): 	at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:556)
E/AndroidRuntime(12219): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:131)
E/AndroidRuntime(12219): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
E/AndroidRuntime(12219): 	at com.aloisdeniel.geocoder.GeocoderPlugin$1.doInBackground(GeocoderPlugin.java:79)
E/AndroidRuntime(12219): 	at com.aloisdeniel.geocoder.GeocoderPlugin$1.doInBackground(GeocoderPlugin.java:72)
E/AndroidRuntime(12219): 	at android.os.AsyncTask$2.call(AsyncTask.java:304)
E/AndroidRuntime(12219): 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime(12219): 	... 4 more
I/Process (12219): Sending signal. PID: 12219 SIG: 9
Lost connection to device.
Exited (sigterm)
@JordyBaylac
Copy link

I am having same issue with Geocoder.

@AlanSGC
Copy link

AlanSGC commented Jun 18, 2019

Same issue

@AlanSGC
Copy link

AlanSGC commented Jun 18, 2019

in my case, the error always occurs at this point: await Geocoder.local.findAddressesFromQuery (city);

@pratik037
Copy link
Author

Still no solution? 😞

@JordyBaylac
Copy link

JordyBaylac commented Jun 19, 2019 via email

@pratik037
Copy link
Author

it hapened to me cause I had my call o geocode inside a Future.delayed. I removed it and it works

On Wed, Jun 19, 2019 at 7:23 AM Pratik Singhal @.***> wrote: Still no solution? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#21?email_source=notifications&email_token=ADJCPYX6I4657ZH5UVQ2EWLP3IJKJA5CNFSM4HYWAYKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYBRSEA#issuecomment-503519504>, or mute the thread https://github.com/notifications/unsubscribe-auth/ADJCPYWBJZLOA3EZ6VCTUH3P3IJKJANCNFSM4HYWAYKA .
-- Jordy Baylac

I removed the geocode dependency, but I am still facing the same issue

@aloisdeniel
Copy link
Owner

I will look more in detail ! Thanks for the report

@pratik037
Copy link
Author

I will look more in detail ! Thanks for the report

Here's StackOverflow link: Issue

@gmcdowell
Copy link

gmcdowell commented Jul 9, 2019

same issue here but when using Local.findAddressesFromCoordinates

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.7.8+hotfix.2, on Mac OS X 10.14.5 18F132, locale en-NZ)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.4)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
[✓] VS Code (version 1.36.0)
[✓] Connected device (1 available)

• No issues found!

Not making use of Futures is not a viable solution for us due to App size and use of background location service from which coords are used to seed geocoder

E/AndroidRuntime( 8277): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime( 8277): 	at android.os.AsyncTask$3.done(AsyncTask.java:353)
E/AndroidRuntime( 8277): 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime( 8277): 	at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime( 8277): 	at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime( 8277): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
E/AndroidRuntime( 8277): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/AndroidRuntime( 8277): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/AndroidRuntime( 8277): 	at java.lang.Thread.run(Thread.java:764)
E/AndroidRuntime( 8277): Caused by: java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: AsyncTask #5
E/AndroidRuntime( 8277): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:794)
E/AndroidRuntime( 8277): 	at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:727)
E/AndroidRuntime( 8277): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:140)
E/AndroidRuntime( 8277): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:225)
E/AndroidRuntime( 8277): 	at com.aloisdeniel.geocoder.GeocoderPlugin$2.doInBackground(GeocoderPlugin.java:109)
E/AndroidRuntime( 8277): 	at com.aloisdeniel.geocoder.GeocoderPlugin$2.doInBackground(GeocoderPlugin.java:102)
E/AndroidRuntime( 8277): 	at android.os.AsyncTask$2.call(AsyncTask.java:333)

@jayvhaile
Copy link

anybody fixed this?

@jayvhaile
Copy link

jayvhaile commented Jul 9, 2019

i fixed it
changed the findAddressesFromCoordinates method in GeoCoderPlugin.java to this

@SuppressLint("StaticFieldLeak")
    private void findAddressesFromCoordinates(final float latitude, final float longitude, final Result result) {

        final GeocoderPlugin plugin = this;
        new AsyncTask<Void, Void, List<Address>>() {
            @Override
            protected List<Address> doInBackground(Void... params) {
                try {
                    plugin.assertPresent();
                    return geocoder.getFromLocation(latitude, longitude, 20);
                } catch (IOException ex) {
                    return null;
                } catch (NotAvailableException ex) {
                    return new ArrayList<>();
                }
            }

            @Override
            protected void onPostExecute(List<Address> addresses) {
                if (addresses != null) {
                    if (addresses.isEmpty())
                        result.error("not_available", "Empty", null);

                    else result.success(createAddressMapList(addresses));
                }
                else result.error("failed", "Failed", null);
            }
        }.execute();
    }

@Peter-717
Copy link

i fixed it
changed the findAddressesFromCoordinates method in GeoCoderPlugin.java to this

@SuppressLint("StaticFieldLeak")
    private void findAddressesFromCoordinates(final float latitude, final float longitude, final Result result) {

        final GeocoderPlugin plugin = this;
        new AsyncTask<Void, Void, List<Address>>() {
            @Override
            protected List<Address> doInBackground(Void... params) {
                try {
                    plugin.assertPresent();
                    return geocoder.getFromLocation(latitude, longitude, 20);
                } catch (IOException ex) {
                    return null;
                } catch (NotAvailableException ex) {
                    return new ArrayList<>();
                }
            }

            @Override
            protected void onPostExecute(List<Address> addresses) {
                if (addresses != null) {
                    if (addresses.isEmpty())
                        result.error("not_available", "Empty", null);

                    else result.success(createAddressMapList(addresses));
                }
                else result.error("failed", "Failed", null);
            }
        }.execute();
    }

I also applied your approach for the: findAddressesFromQuery! Worked perfect. Thanks!!!

@aloisdeniel
Copy link
Owner

Thanks changed the implementation with your proposal.

@aloisdeniel
Copy link
Owner

Published in version 0.2.0 on pub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants