I found that it said to add code in MainActivity, and when I tried to add code in MainActivity.kt (my flutter project has only kotlin code by default) then I am getting error. So, I figured out that on flutter dev, the code was given for MainActivity.java & not for kotlin version.
E/flutter (18308): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method getSharedText on channel app.channel.shared.data)
AND
Launching lib/main.dart on RMX1851 in debug mode...
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (15, 27): Expecting a top level declaration
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (15, 35): Expecting a top level declaration
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (15, 51): Expecting a top level declaration
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (15, 51): Function declaration must have a name
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (20, 52): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (23, 19): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (23, 31): Expecting an expression
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (24, 19): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (24, 27): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (24, 38): Expecting an expression
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (25, 17): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (25, 25): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (25, 34): Expecting an expression
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (26, 19): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (26, 27): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (26, 38): Expecting an expression
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (34, 39): Expecting ')'
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (34, 39): Unexpected tokens (use ';' to separate expressions on the same line)
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (35, 29): Expecting an expression
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (37, 49): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (37, 78): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (43, 8): Unexpected tokens (use ';' to separate expressions on the same line)
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (43, 9): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (46, 36): Expecting an element
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (17, 3): Unresolved reference: private
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (17, 18): Unresolved reference: sharedText
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (19, 3): This annotation is not applicable to target 'expression'
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (20, 3): Unresolved reference: protected
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (20, 18): Unresolved reference: onCreate
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (20, 27): Classifier 'Bundle' does not have a companion object, and thus must be initialized here
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (21, 5): No supertypes are accessible in this context
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (21, 20): Unresolved reference: savedInstanceState
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (22, 44): 'this' is not defined in this context
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (23, 5): Classifier 'Intent' does not have a companion object, and thus must be initialized here
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (24, 12): Unresolved reference: action
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (25, 12): Unresolved reference: type
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (26, 12): Unresolved reference: scheme
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (28, 35): Unresolved reference: action
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (28, 46): Unresolved reference: scheme
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (29, 26): Unresolved reference: scheme
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (30, 9): Unresolved reference: handleSendText
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (30, 24): Unresolved reference: intent
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (34, 5): Unresolved reference: new
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (34, 23): Unresolved reference: getFlutterView
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (35, 7): Unresolved reference: new
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (36, 9): This annotation is not applicable to target 'expression'
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (37, 9): Unresolved reference: public
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (37, 21): Unresolved reference: onMethodCall
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (37, 34): Classifier 'MethodCall' does not have a companion object, and thus must be initialized here
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (37, 65): Classifier 'Result' does not have a companion object, and thus must be initialized here
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (38, 15): Unresolved reference: call
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (39, 13): Unresolved reference: result
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (39, 28): Unresolved reference: sharedText
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (40, 13): Unresolved reference: sharedText
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (46, 3): Unresolved reference: void
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (46, 23): Classifier 'Intent' does not have a companion object, and thus must be initialized here
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (47, 5): Unresolved reference: sharedText
e: /home/yash/programming/flutter/app_name/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt: (47, 18): Unresolved reference: intent
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 23s
Exited (sigterm)
Exception: Gradle task assembleDebug failed with exit code 1
Here is the flutter doctor -v-
[✓] Flutter (Channel stable, 1.20.1, on Linux, locale en_GB.UTF-8)
• Flutter version 1.20.1 at /usr/local/flutter
• Framework revision 2ae34518b8 (7 days ago), 2020-08-05 19:53:19 -0700
• Engine revision c8e3b94853
• Dart version 2.9.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at /home/yash/Android/Sdk
• Platform android-30, build-tools 30.0.1
• Java binary at: /usr/local/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Android Studio (version 3.6)
• Android Studio at /usr/local/android-studio
• Flutter plugin installed
• Dart plugin installed
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (1 available)
• RMX1851 (mobile) • 65e4bff3 • android-arm64 • Android 10 (API 29)
• No issues found!
Flutter version- 1.20 Channel- Stable
I was looking to implement Incoming intent from external application. I found a article on Flutter dev- Handle Incoming Intent from ext. apps.
I found that it said to add code in MainActivity, and when I tried to add code in MainActivity.kt (my flutter project has only kotlin code by default) then I am getting error. So, I figured out that on flutter dev, the code was given for MainActivity.java & not for kotlin version.
I have also tried this- https://github.com/flutter/flutter/issues/54364#issuecomment-613352024, but exact way of implementation is not given.
Following are the error shown in Debug console-
E/flutter (18308): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method getSharedText on channel app.channel.shared.data)
AND
Here is the
flutter doctor -v
-Thanks in advance.