Skip to content

Unable to deep link into Android app #75261

@johnpryan

Description

@johnpryan

Deep linking into an android app using the Router widget throws an error:

E/AndroidRuntime( 8741): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference

Steps to Reproduce

  1. Create a new Flutter project with main.dart replaced with the contents of this sample
  2. Update main/AndroidManifest.xml with this configuration inside the <activity android:name=".MainActivity"> XML node:
            <!-- Deep linking -->
            <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="flutterbooksample.com" />
                <data android:scheme="https" />
            </intent-filter>
  1. Run this the app
  2. Run this command to trigger a deep link into the app:
adb shell am start -a android.intent.action.VIEW \
    -c android.intent.category.BROWSABLE \
    -d "http://flutterbooksample.com/book/1"
  1. Observe error (see below)

Logs

Logs
D/AndroidRuntime( 8741): Shutting down VM
E/AndroidRuntime( 8741): FATAL EXCEPTION: main
E/AndroidRuntime( 8741): Process: com.example.router_app, PID: 8741
E/AndroidRuntime( 8741): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
E/AndroidRuntime( 8741): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.maybeGetInitialRouteFromIntent(FlutterActivityAndFragmentDelegate.java:403)
E/AndroidRuntime( 8741): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onNewIntent(FlutterActivityAndFragmentDelegate.java:648)
E/AndroidRuntime( 8741): 	at io.flutter.embedding.android.FlutterActivity.onNewIntent(FlutterActivity.java:625)
E/AndroidRuntime( 8741): 	at android.app.Activity.performNewIntent(Activity.java:8015)
E/AndroidRuntime( 8741): 	at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1409)
E/AndroidRuntime( 8741): 	at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1422)
E/AndroidRuntime( 8741): 	at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:3664)
E/AndroidRuntime( 8741): 	at android.app.ActivityThread.handleNewIntent(ActivityThread.java:3676)
E/AndroidRuntime( 8741): 	at android.app.servertransaction.NewIntentItem.execute(NewIntentItem.java:53)
E/AndroidRuntime( 8741): 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime( 8741): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime( 8741): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
E/AndroidRuntime( 8741): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 8741): 	at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 8741): 	at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 8741): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8741): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 8741): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process ( 8741): Sending signal. PID: 8741 SIG: 9
Lost connection to device.
flutter doctor -v                                 
[✓] Flutter (Channel master, 1.26.0-18.0.pre.133, on macOS 11.1 20C69 darwin-x64, locale en)
    • Flutter version 1.26.0-18.0.pre.133 at /Users/ryjohn/code/sdks/flutter
    • Framework revision 5b6444f317 (64 minutes ago), 2021-02-02 09:34:01 -0800
    • Engine revision 8a01ce59bf
    • Dart version 2.12.0 (build 2.12.0-281.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/ryjohn/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 53.0.5
    • Dart plugin version 203.6912

[✓] Connected device (3 available)
    • sdk gphone x86 arm (mobile) • emulator-5554                        • android-x86    • Android 11
      (API 30) (emulator)
    • iPhone 12 Pro Max (mobile)  • AE85D456-A89C-4104-B6F0-F68F35A93165 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • Chrome (web)                • chrome                               • web-javascript • Google
      Chrome 88.0.4324.96

• No issues found!

Metadata

Metadata

Assignees

Labels

c: regressionIt was better in the past than it is nowf: routesNavigator, Router, and related APIs.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions