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

PlatformException with new release #167

Closed
adar2378 opened this issue Jan 5, 2020 · 29 comments
Closed

PlatformException with new release #167

adar2378 opened this issue Jan 5, 2020 · 29 comments

Comments

@adar2378
Copy link

adar2378 commented Jan 5, 2020

Unhandled Exception: PlatformException(unregistered_view_type, trying to create a view with an unregistered type, unregistered view type: 'plugins.flutter.io/mapbox_gl')

@kleeb
Copy link
Contributor

kleeb commented Jan 9, 2020

I am getting java.lang.UnsatisfiedLinkError: No implementation found for void com.mapbox.mapboxsdk.net on the 0.0.5 version

Caused by: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libmapbox-gl.so caused by: dlopen failed: "/data/data/com.sample.app/lib-main/libmapbox-gl.so" has unexpected e_machine: 40 (EM_ARM)

@kleeb
Copy link
Contributor

kleeb commented Jan 9, 2020

Ok. My case was that I used AVD simulator with Android 9. For Android 8.1 it works properly.

@fayaz07
Copy link

fayaz07 commented Jan 12, 2020

I observed this to be happening when I made hot-restart. I used physical device

Performing hot restart...
Syncing files to device SM J600G...
Restarted application in 2,463ms.
I/flutter ( 2348): requesting location permissions
I/flutter ( 2348): permissions already granted
E/flutter ( 2348): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create an already created platform view, view id: 0
E/flutter ( 2348): 	at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:85)
E/flutter ( 2348): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:96)
E/flutter ( 2348): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
E/flutter ( 2348): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/flutter ( 2348): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/flutter ( 2348): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/flutter ( 2348): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 2348): 	at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter ( 2348): 	at android.os.Looper.loop(Looper.java:181)
E/flutter ( 2348): 	at android.app.ActivityThread.main(ActivityThread.java:7081)
E/flutter ( 2348): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 2348): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/flutter ( 2348): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
E/flutter ( 2348): , null)
E/flutter ( 2348): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 2348): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter ( 2348): <asynchronous suspension>
E/flutter ( 2348): #2      AndroidViewController._create (package:flutter/src/services/platform_views.dart:640:54)
E/flutter ( 2348): #3      AndroidViewController.setSize (package:flutter/src/services/platform_views.dart:557:14)
E/flutter ( 2348): #4      RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:174:29)
E/flutter ( 2348): #5      RenderAndroidView.performResize (package:flutter/src/rendering/platform_view.dart:155:5)
E/flutter ( 2348): #6      RenderObject.layout (package:flutter/src/rendering/object.dart:1703:9)
E/flutter ( 2348): #7      RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #8      RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #9      MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:163:11)
E/flutter ( 2348): #10     _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:477:7)
E/flutter ( 2348): #11     MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:232:7)
E/flutter ( 2348): #12     RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:391:14)
E/flutter ( 2348): #13     RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #14     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #15     RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #16     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #17     _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1232:11)
E/flutter ( 2348): #18     RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #19     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #20     RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #21     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #22     RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #23     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #24     RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #25     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #26     RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #27     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #28     RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter ( 2348): #29     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter ( 2348): #30     RenderObject.layout (package:flutter/src/rende

@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 12, 2020

These seem to be different issues to me.

The issue @kleeb is encountering might be the same that is described upstream here and here. When you encountered the issue, how did you build the apk?
I also found this PR upstream, @tobrun could you verify whether that fixes this UnsatisfiedLinkError?

@adar2378 and @fayaz07: did you encounter these issues repeatedly or only once?

@fayaz07
Copy link

fayaz07 commented Jan 13, 2020

@m0nac0 it happens everytime I made hot-restart and along with it, map goes blank after hot-restart

@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 13, 2020

@fayaz07 Okay, could you please tell us exactly which version and channel of flutter you are running, which Android OS and whether you are on a emulator or a physical device? And I assume you are using version 0.0.5 of the plugin from pub.dev, is that correct?

@adar2378 Did you try doing a full restart of the app (not a hot restart) after adding the plugin? The reason I'm asking is because I think I have encountered a similar issue where flutter's hot restart couldn't handle new plugins with platform views.

@fayaz07
Copy link

fayaz07 commented Jan 13, 2020

@m0nac0 I was running on beta channel maybe version 1.12.5, I tried switching to stable channel even there was same issue

Current version
Flutter 1.12.13+hotfix.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 27321ebbad (5 weeks ago) • 2019-12-10 18:15:01 -0800
Engine • revision 2994f7e1e6
Tools • Dart 2.7.0
Device: Physical Device

@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 13, 2020

Thank you @fayaz07, I found this issue at flutter, which describes the same problem occurring also with other plugins using platform views. It also has more information. So I guess there's unfortunately not much we can do about this, but you could comment at that issue to let the flutter team know that the problem also occurs with mapbox_gl.

@wpietri
Copy link

wpietri commented Jan 16, 2020

I'm getting the same error just trying to run a fresh checkout of the example code. I'm using a physical device, my up-to-date Pixel 3a. In particular, I'm getting Unhandled Exception: PlatformException(error, Trying to create a platform view of unregistered type: plugins.flutter.io/mapbox_gl, null)

I first got it with:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Android Studio (version 3.5)
[✓] Connected device (1 available)

I then upgraded and got it with this:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Android Studio (version 3.5)
[✓] Connected device (1 available)

Either way, I do flutter run, which launches successfully, and get the error when I tap on "User interface".

@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 16, 2020

@wpietri thank you for the report, there are some similar issues reported upstream at flutter suggesting this might have to do with the new Android plugin APIs and the generated MainActivity.java being faulty. (see e.g. flutter/flutter#47921 (comment))
Could you therefore paste the content of your generated MainActivity.java, please?

@wpietri
Copy link

wpietri commented Jan 16, 2020

Gladly, @m0nac0.

./android/app/src/main/java/com/mapbox/mapboxglexample/MainActivity.java
package com.mapbox.mapboxglexample;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
  }
}

I'll also figure out how to downgrade my Android tools and see what changes.

@wpietri
Copy link

wpietri commented Jan 16, 2020

Sorry, that apparently wasn't a generated MainActivity.java, but part of the example code. That's the only MainActivity.java file under the example directory, though.

Anyhow, downgrading to this makes the example work for me:

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

@wpietri
Copy link

wpietri commented Jan 17, 2020

In case it's helpful, now that I am trying out this library in my existing app, I too am seeing the UnsatisfiedLinkError when running in the emulator (API 28), but it works properly when running on my actual phone (Pixel 3a). I'm glad to debug further.

@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 18, 2020

@wpietri Thank you for the MainActivity, it looks fine. I honestly don't have any idea what might be causing this issue. For now I'd suggest we just watch the similar issues at flutter (flutter/flutter#48927, flutter/flutter#47921) and hope they can resolve this, unless someone else has an idea.

@maximumbuster
Copy link
Collaborator

Reverting the pubspec.yaml to
flutter: plugin: androidPackage: com.mapbox.mapboxgl pluginClass: MapboxMapsPlugin
worked on both android and ios for me, not sure why it was changed or what those changes are needed for.

m0nac0 added a commit that referenced this issue Jan 20, 2020
@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 20, 2020

@maximumbuster Great find! I changed pubspec.yaml because this is the new way to specify supported platforms according to https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms
Without this change the plugin would incorrectly show web as a supported platform on pub.dev (see #147)
I just noticed that I forgot to update the sdk constraints as mentioned in the above link, so I submitted a PR for that. Could you check whether that fixes the issue? (I unfortunately still can't reproduce it)

@maximumbuster
Copy link
Collaborator

@m0nac0 ahh yup, upgrading flutter to Flutter 1.12.13+hotfix.5 • channel stable and adding that sdk constraint fixed the issue for me

@tobrun tobrun closed this as completed in c8db3df Jan 20, 2020
@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 20, 2020

@maximumbuster That's great news, sorry for the inconvenience ;)
@wpietri and @adar2378 feel free to reopen this if you still experience this issue using the plugin's current version from master.

@adar2378
Copy link
Author

Hey, I was on vacation. Sure I'll reopen if needs. As far as I remember I could not run the 0.0.5 version on Flutter 1.9.1.hofix6. Gotta check again and I'll let you know asap!

@raphaaugustosilva
Copy link

I'm facing the same issue.

My reference is

mapbox_gl:
git:
url: git://github.com/tobrun/flutter-mapbox-gl.git

My flutter version is 1.14.3

error: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.example.mapa_offline_mapbox/lib-main/libmapbox-gl.so" has unexpected e_machine: 40 (EM_ARM)

Any clue? :(

@m0nac0
Copy link
Collaborator

m0nac0 commented Feb 7, 2020

@raphaaugustosilva Thank you for the report, could you tell us what hardware you are running the app on (especially the ABI), how you build the APK and have you tried using the latest stable release of flutter?

@raphaaugustosilva
Copy link

raphaaugustosilva commented Feb 10, 2020

Yes, sure!

I'm running into an Android Emulator x86 Nexus 5X API Level 28.
Flutter version: 1.12.13+hotfix.7

@kleeb
Copy link
Contributor

kleeb commented Feb 10, 2020

@raphaaugustosilva try downgrading API level to 27

@m0nac0
Copy link
Collaborator

m0nac0 commented Feb 10, 2020

@raphaaugustosilva Also could you try running flutter build apk --split-per-abi and installing the suitable out of the produced APKs?
As mentioned above at #167 (comment) the same issue has been reported upstream at Mapbox, so I suspect this isn't a flutter issue. I would guess that this occurs when building a "fat APK" with flutter (an APK with libraries for all ABIs) because a libmapbox-gl.so for the wrong architecture is somehow included.

@raphaaugustosilva
Copy link

@m0nac0 it worked when I generate the apk without the "fat way" and without changing the API level to 27 :)
Just a question: This way I need to build the "release apk per abi", so I will never be able to debug it?

@m0nac0
Copy link
Collaborator

m0nac0 commented Feb 12, 2020

@raphaaugustosilva Glad you were able to resolve the issue!
I'm not sure whether I correctly understand your question, but you should be able to debug these APKs just like any other APK, you just need to install the right apk for your device. Actually using the --split-per-abi flag is recommended by the flutter docs

@raphaaugustosilva
Copy link

raphaaugustosilva commented Feb 14, 2020

@m0nac0 thanks!
Correct me if I'm wrong: this --split-per-abi is just for release build, am I right?
It`s working when I build a release per-abi, but what if I just want to debug my application using the flutter-mapbox-gl?

@m0nac0
Copy link
Collaborator

m0nac0 commented Feb 14, 2020

@raphaaugustosilva Do you also encounter this issue when you debug the app?
(Because I thought this was only an issue with release builds)
If so you should probably comment at the flutter issues I linked above or open a new issue over at the flutter repo, because this issue seems to affect different plugins using external libraries.

@raphaaugustosilva
Copy link

@m0nac0 yes, sorry to don't clarify earlier. Its happening both debug and release mode, and it just works when I build a release per-abi. Ok, Ill check that flutter issue. Thanks again!

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

No branches or pull requests

8 participants