fluttercommunity / fluttercommunity/flutter_wear_plugin
MainActivity has leaked ServiceConnection when press Back exit Wear app
- Dominant language
- Dart
- Stars
- 143
- Forks
- 83
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I got the exception as title in above, since I :
- created new project
- apply library in `pubspec.yaml` file
- create Container widget (empty widget)
- run project
- application open as usual
- press Exit
- the exception in below, has appeared
Please help me check to avoid this exception,
Thanks,
p/s : I did not add anything in `Manifest.xml` file and `build.gradle` file (in folder /android)
**EXCEPTION**
> E/ActivityThread( 3770): Activity flutter.wear.MainActivity has leaked ServiceConnection com.google.android.wearable.compat.WearableActivityController$AmbientServiceConnection@efc6b0a that was originally bound here
> E/ActivityThread( 3770): android.app.ServiceConnectionLeaked: Activity flutter.wear.MainActivity has leaked ServiceConnection com.google.android.wearable.compat.WearableActivityController$AmbientServiceConnection@efc6b0a that was originally bound here
> E/ActivityThread( 3770): at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:1336)
> E/ActivityThread( 3770): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1231)
> E/ActivityThread( 3770): at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1450)
> E/ActivityThread( 3770): at android.app.ContextImpl.bindService(ContextImpl.java:1422)
> E/ActivityThread( 3770): at android.content.ContextWrapper.bindService(ContextWrapper.java:636)
> E/ActivityThread( 3770): at com.google.android.wearable.compat.WearableActivityController.onCreate(WearableActivityController.java:134)
> E/ActivityThread( 3770): at com.mjohnsullivan.flutterwear.wear.WearPlugin.onCreate(WearPlugin.kt:117)
> E/ActivityThread( 3770): at java.lang.reflect.Method.invoke(Native Method)
> E/ActivityThread( 3770): at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:216)
> E/ActivityThread( 3770): at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:194)
> E/ActivityThread( 3770): at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:185)
> E/ActivityThread( 3770): at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:37)
> E/ActivityThread( 3770): at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361)
> E/ActivityThread( 3770): at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:300)
> E/ActivityThread( 3770): at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:339)
> E/ActivityThread( 3770): at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145)
> E/ActivityThread( 3770): at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131)
> E/ActivityThread( 3770): at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:412)
> E/ActivityThread( 3770): at android.app.Activity.performCreate(Activity.java:6682)
> E/ActivityThread( 3770): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
> E/ActivityThread( 3770): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
> E/ActivityThread( 3770): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
> E/ActivityThread( 3770): at android.app.ActivityThread.-wrap12(ActivityThread.java)
> E/ActivityThread( 3770): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
> E/ActivityThread( 3770): at android.os.Handler.dispatchMessage(Handler.java:102)
> E/ActivityThread( 3770): at android.os.Looper.loop(Looper.java:154)
> E/ActivityThread( 3770): at android.app.ActivityThread.main(ActivityThread.java:6119)
> E/ActivityThread( 3770): at java.lang.reflect.Method.invoke(Native Method)
> E/ActivityThread( 3770): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
> E/ActivityThread( 3770): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
**CODE**
```
`HomePage.dart`
`class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return WatchShape(
builder: (context, shape, child) {
return AmbientMode(
builder: (context, mode, child) {
print('mode = $mode');
return mode == WearMode.active ? ActiveWatchFace() : AmbientWatchFace();
},
);
},
);
}
}`
`main.dart`
`void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Widget home = Scaffold(
body: Scaffold(
body: Builder(
builder: (context) => MainPage(),
),
),
);
return GetMaterialApp(
debugShowCheckedModeBanner: true,
home: home,
);
}
}
class MainPage extends StatefulWidget {
@override
MainPageState createState() => MainPageState();
}
class MainPageState extends State {
@override
Widget build(BuildContext context) => HomePage();
}`
```
**TOOLS**
> [✓] Flutter (Channel master, 2.3.0-17.0.pre.228, on macOS 11.4 20F71 darwin-x64,
> locale en-VN)
> • Flutter version 2.3.0-17.0.pre.228 at /Users/huytd/flutter
> • Upstream repository https://github.com/flutter/flutter.git
> • Framework revision 49733a4850 (11 days ago), 2021-06-07 05:19:03 -0400
> • Engine revision 2ffc823063
> • Dart version 2.14.0 (build 2.14.0-186.0.dev)
>
> [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
> ✗ cmdline-tools component is missing
> Run `path/to/sdkmanager --install "cmdline-tools;latest"`
> See https://developer.android.com/studio/command-line for more details.
> ✗ Android license status unknown.
> Run `flutter doctor --android-licenses` to accept the SDK licenses.
> See https://flutter.dev/docs/get-started/install/macos#android-setup for
> more details.
>
> [✓] Xcode - develop for iOS and macOS
> • Xcode at /Applications/Xcode.app/Contents/Developer
> • Xcode 12.5, Build version 12E262
> • CocoaPods version 1.10.1
>
> [✓] Chrome - develop for the web
> • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
>
> [✓] Android Studio (version 4.2)
> • Android Studio at /Applications/Android Studio.app/Contents
> • Flutter plugin can be installed from:
> 🔨 https://plugins.jetbrains.com/plugin/9212-flutter
> • Dart plugin can be installed from:
> 🔨 https://plugins.jetbrains.com/plugin/6351-dart
> • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
>
> [✓] Android Studio
> • Android Studio at /Users/huytd/Downloads/Android Studio
> Preview.app/Contents
> • Flutter plugin can be installed from:
> 🔨 https://plugins.jetbrains.com/plugin/9212-flutter
> • Dart plugin can be installed from:
> 🔨 https://plugins.jetbrains.com/plugin/6351-dart
> • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
>
> [✓] Connected device (2 available)
> • sdk google aw x86 (mobile) • emulator-5554 • android-x86 • Android
> 7.1.1 (API 25) (emulator)
> • Chrome (web) • chrome • web-javascript • Google
> Chrome 91.0.4472.106
>
> ! Doctor found issues in 1 category.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.