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

[Bug] AnkiDroid Instant-Add API cannot be invoked on Android 11 (SDK 30+) #8493

Closed
4 tasks done
arianneorpilla opened this issue Apr 6, 2021 · 3 comments
Closed
4 tasks done

Comments

@arianneorpilla
Copy link

arianneorpilla commented Apr 6, 2021

I've recently migrated my app from using the ACTION_SEND share intent to using the Instant-Add API on my Flutter app, jidoujisho, via a method channel calling native Java code derived from the API sample. I was informed by several users that they were unable to export from the app, and they were Android 11 users.

My app (on version 0.7.0) works fine exporting to AnkiDroid on versions below Android 11 (I myself use Android 10). However, I cannot get my app or the API sample to work on an Android 11 emulator, where it crashes instead. I've advised my users to keep using my app on 0.6.1 while I implement share intent as a fallback.

My app works fine on any devices and emulators on or below SDK 29. Maybe this is a problem on my end but I've tried to scour what problems I may be causing on my end and I'm grasping at straws. Any help would be much appreciated as I would like to make using the Instant-Add API available on any version for my app.

Cheers.

Reproduction Steps
  1. Install latest AnkiDroid (universal APK) as obtained from F-Droid. on an Android 11 (SDK 30) emulator.
  2. Start up AnkiDroid and confirm permissions on first startup.
  3. Install API sample on an Android 11 (SDK 30) emulator. / Install jidoujisho 0.7.0.
  4. Start up application and confirm permissions on first startup.
  5. Attempt to use the API sample. / Load any video on my application and attempt to export.
Expected Result

Instant-Add API should be invoked without issues.

Actual Result

API sample crashes. API Sample deck is added to AnkiDroid with no card.

My application hangs on export and never proceeds when getDeckList is called with message Failed to find provider info for com.ichi2.anki.flashcards. This does not occur on any version below SDK 30, and has been tested with approved permissions.

Debug info

API sample:
API sample has stopped working

jidoujisho from Flutter debug window, getDeckList returns null called from a method channel causing the hang up:

E/ActivityThread( 5782): Failed to find provider info for com.ichi2.anki.flashcards
E/flutter ( 5782): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: NoSuchMethodError: The getter 'values' was called on null.
E/flutter ( 5782): Receiver: null
E/flutter ( 5782): Tried calling: values
E/flutter ( 5782): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
E/flutter ( 5782): #1      getDecks (package:jidoujisho/util.dart:789:18)
E/flutter ( 5782): <asynchronous suspension>
E/flutter ( 5782): #2      exportToAnki (package:jidoujisho/util.dart:201:24)
E/flutter ( 5782): <asynchronous suspension>
Research

Enter an [x] character to confirm the points below:

  • I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
  • I have checked the manual and the FAQ and could not find a solution to my issue
  • I have searched for similar existing issues here and on the user forum
  • (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)
@arianneorpilla
Copy link
Author

arianneorpilla commented Apr 6, 2021

I have investigated workarounds and found that for the Instant-Add API to work on SDK 30, the following should be added to the manifest. This fixed issues with export on an Android 11 emulator.

Link to where solution was found for future reference.

<manifest>
...
    <queries>
        <package android:name="com.ichi2.anki" />
    </queries>
</manifest>

@arianneorpilla
Copy link
Author

I think the above snippet may be useful to include in the AnkiDroid API wiki page so I've gone ahead and edited it in.

@mikehardy
Copy link
Member

@lrorpilla thank you so much for finding that and adding it to the wiki! Will hopefully save future developers a lot of time

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

2 participants