[Bug] PluginLoadException: Unable to load io.ionic.backgroundrunner.plugin.BackgroundRunnerPlugin on Android with Capacitor 7.2.0
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 32/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- android, java, javascript, kotlin
- Domain
- mobile-dev
Research direction
Start with the plugin's Kotlin file at .../io/ionic/backgroundrunner/plugin/BackgroundRunnerPlugin.kt and its android/build.gradle, then reproduce the failure with the minimal project using npx cap sync android and Android Studio Logcat. Compare the generated capacitor.settings.gradle and app/build.gradle entries with the plugin's loading path. Done means the plugin loads on Android and its JavaScript API initializes without the reported errors.
Written by the indexing model from the issue text.
Description
1. Plugin Version:
@capacitor/background-runner: v2.1.0
2. Capacitor Version:
@capacitor/core: v7.2.0
@capacitor/android: v7.2.0
@capacitor/cli: v7.2.0
3. Problem Description:
The @capacitor/background-runner plugin fails to load on the Android platform when the application starts. The primary error observed in Logcat is:
NativePlugin io.ionic.backgroundrunner.plugin.BackgroundRunnerPlugin failed to load com.getcapacitor.PluginLoadException: Unable to load plugin instance. Ensure plugin is publicly accessible at com.getcapacitor.PluginHandle.load(PluginHandle.java:107) at com.getcapacitor.PluginHandle.<init>(PluginHandle.java:65) at com.getcapacitor.Bridge.registerPlugin(Bridge.java:701) at com.getcapacitor.Bridge.registerAllPlugins(Bridge.java:657) at com.getcapacitor.Bridge.<init>(Bridge.java:231) at com.getcapacitor.Bridge$Builder.create(Bridge.java:1595) at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:48) at com.getcapacitor.BridgeActivity.onCreate(BridgeActivity.java:42) at com.MRtenfingers.fantasytimer.MainActivity.onCreate(MainActivity.java:16) // App package name and MainActivity // ... (Full Java stack trace can be attached if requested)
This native plugin load failure leads to subsequent errors in the JavaScript layer:
[background-runner-bridge] BackgroundRunner plugin is unavailable [timer-controller] BackgroundRunner initialization failed [timer-controller] Timer controller not initialized
as a result, any functionality relying on the background runner (e.g., starting a timer) fails.
4. Steps to Reproduce:
The issue was reproduced in a minimal Capacitor project:
- Initialized a new Capacitor project (npm init -y, npm install @capacitor/cli@^7.2.0 @capacitor/core@^7.2.0 @capacitor/android@^7.2.0, npx cap init TestApp com.example.testapp, npx cap add android).
- Installed only @capacitor/[email protected] (npm install @capacitor/[email protected]).
- Created a minimal www directory with an index.html and a basic js/app.js that attempts to check Capacitor.isPluginAvailable('BackgroundRunner') and access Capacitor.Plugins.BackgroundRunner on deviceready.
- Ensured capacitor.config.ts had webDir: 'www'.
- Ran npx cap sync android.
- Built and ran the application on an Android device/emulator using Android Studio.
- Observed the same PluginLoadException for io.ionic.backgroundrunner.plugin.BackgroundRunnerPlugin in Logcat upon app startup.
5. Expected Behavior:
The @capacitor/background-runner plugin should load and initialize successfully with Capacitor 7.2.0 on Android, allowing its JavaScript API to be used.
6. Actual Behavior:
The plugin fails to load at the native Android level with a PluginLoadException, making it unusable from the JavaScript side.
- Troubleshooting Steps Taken (in both main project and minimal reproduction):
- Verified that the plugin's peerDependencies ("@capacitor/core": "^6.0.0 || ^7.0.0") theoretically support Capacitor 7.2.0.
- Confirmed npx cap sync android detects the plugin (Found 5 Capacitor plugins for android: @capacitor/[email protected] ...).
- Ensured android/capacitor.settings.gradle correctly includes :capacitor-background-runner and its projectDir.
- Ensured android/app/build.gradle has the implementation project(':capacitor-background-runner') dependency.
- Confirmed the repositories { flatDir { ... } } in android/app/build.gradle points to ../../node_modules/@capacitor/background-runner/android/src/main/libs, and the android-js-engine-release.aar file exists at this location.
- Verified the plugin's own build.gradle (node_modules/@capacitor/background-runner/android/build.gradle) declares a dependency on android-js-engine-release.aar via implementation(name: "android-js-engine-release", ext: "aar").
- Confirmed the plugin's Kotlin file (.../io/ionic/backgroundrunner/plugin/BackgroundRunnerPlugin.kt) has the package and class name (io.ionic.backgroundrunner.plugin.BackgroundRunnerPlugin) that Logcat indicates Capacitor is trying to load.
- Ensured MainActivity.java does not contain manual this.init() calls for plugin registration, relying on Capacitor's automatic loading (consistent with Capacitor 4+ best practices).
- Performed thorough project cleanups: Android Studio's "Invalidate Caches / Restart" and manual deletion of android/build and android/.gradle folders.
- Environment Details:
- Capacitor Core Version: ^7.2.0
- Capacitor Android Platform Version: ^7.2.0
- Capacitor CLI Version: ^7.2.0
- @capacitor/background-runner Version: 2.1.0
- Node.js Version: [Your Node.js Version, e.g., v18.16.0]
- NPM Version: [Your NPM Version, e.g., 9.5.1]
- Development OS: [Your OS, e.g., Windows 10, macOS Sonoma]
- Test Device/Emulator: [Your Test Device and Android Version, e.g., Pixel 6 Android 13 / Xiaomi MIUI 14 Android 13]
- Android Studio Version: [Your Android Studio Version, e.g., Giraffe | 2022.3.1 Patch 2]
- Android Gradle Plugin Version (from root android/build.gradle): [e.g., com.android.tools.build:gradle:8.x.x]
- Gradle Version (from android/gradle/wrapper/gradle-wrapper.properties): [e.g., distributionUrl=https://services.gradle.org/distributions/gradle-8.x-bin.zip]
- Potentially Relevant Files (Can provide if needed):
- package.json
- android/capacitor.settings.gradle
- android/app/build.gradle
- node_modules/@capacitor/background-runner/android/build.gradle
- Logcat output from the minimal reproduction project.
Questions for the Plugin Maintainers:
- Are there any known compatibility issues or specific configuration steps required for @capacitor/[email protected] when used with @capacitor/[email protected] and @capacitor/[email protected]?
- Could the bundled android-js-engine-release.aar have compatibility issues with newer Android versions, build tools, or specific CPU architectures that might lead to this PluginLoadException?
- Is there a more recent version of @capacitor/background-runner recommended for use with Capacitor 7?
Thank you for your time and any assistance you can provide.
- Dominant language
- C
- Stars
- 57
- Forks
- 37
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ionic-team/capacitor-background-runner
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
ionic-team/capacitor-background-runner#158 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ionic-team/capacitor-background-runner#155 · 1 reaction ·
-
Capacitor keeps running old background runnersMay be free again @theproducer claimed this 245 days ago, and no pull request is open. Openbug
ionic-team/capacitor-background-runner#152 · 1 comment · 2 reactions · 1 assignee ·
All issues in ionic-team/capacitor-background-runner
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
python-pillow/Pillow#10087 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenPrinting/cups#1729 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
awslabs/amazon-kinesis-video-streams-webrtc-sdk-c#2406 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
DaveGamble/cJSON#1094 ·
-
status:needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
PX4/PX4-Autopilot#28923 ·
Maintainers usually reply within 1 day