#NFC doesn't work in the APK

17 messages · Page 1 of 1 (latest)

sturdy haven
#

I made a app with NFC plugin on Tauri mobile. In the development environment, NFC reading and writing worked fine, but when I installed the APK after building the app, it doesn't work. Does anyone have any ideas to solve this problem?

sturdy haven
#

This is the only error I see when trying to use NFC

         E  win=Window{cc6012f u0 com.example.app/com.example.app.MainActivity} destroySurfaces: appStopped=true cleanupOnResume=false win.mWindowRemovalAllowed=false win.mRemoveOnExit=false win.mViewVisibility=8 caller=com.android.server.wm.ActivityRecord.destroySurfaces:6539 com.android.server.wm.ActivityRecord.destroySurfaces:6520 com.android.server.wm.ActivityRecord.notifyAppStopped:6584 com.android.server.wm.ActivityRecord.activityStopped:7172 com.android.server.wm.ActivityClientController.activityStopped:258 android.app.IActivityClientController$Stub.onTransact:613 com.android.server.wm.ActivityClientController.onTransact:136 ```
#

And tauri info:


[✔] Environment
    - OS: Arch Linux Rolling Release X64
    ✔ webkit2gtk-4.1: 2.44.2
    ✔ rsvg2: 2.58.0
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.1 (2024-05-07)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 22.2.0
    - pnpm: 9.1.2
    - npm: 10.8.0
    - bun: 1.1.9

[-] Packages
    - tauri [RUST]: 2.0.0-beta.17
    - tauri-build [RUST]: 2.0.0-beta.13
    - wry [RUST]: 0.39.3
    - tao [RUST]: 0.27.1
    - @tauri-apps/api [NPM]: 2.0.0-beta.11
    - @tauri-apps/cli [NPM]: 2.0.0-beta.17

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite
#

I've been trying various methods for hours but none of it worked

#

I think I'm thinking about something wrong but I don't know what is..

merry radish
sturdy haven
#

also even if I don't add it to the manifest, it already shows the permission for NFC

#

maybe it's not completely unrelated

sturdy haven
#

added this lines:

  <uses-permission android:name="android.permission.NFC"/>
  <uses-feature android:name="android.hardware.nfc" android:required="true"/>

And add this in proguard-rules.pro

-keep class app.tauri.nfc.** { *; }
#

Solved ✅

#

it takes 16hour

#

maybe proguard broke invoke?

sturdy haven
#

I tried some cases. The result is I don't need to add NFC permission in manifest, Tauri do that. Just add -keep class app.tauri.nfc.** { *; } in progaurd-rules.pro. Maybe progaurd broke invoke?

merry radish
sturdy haven
#

It seems need option for progaurd, just as we can set permissions for Tauri plugins to automatically add to the manifest