question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mauron85 / cordova-plugin-background-geolocation Error in Ionic 6 Android

See original GitHub issue

This plugin gives error in ionic 6 android due to android permission

ionic info

Ionic:

Ionic CLI : 6.19.0 (/usr/local/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 6.0.12 @angular-devkit/build-angular : 13.2.6 @angular-devkit/schematics : 13.2.6 @angular/cli : 13.2.6 @ionic/angular-toolkit : 6.1.0

Cordova:

Cordova CLI : 11.0.0 Cordova Platforms : android 10.1.1 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 3 other plugins)

Utility:

cordova-res : 0.15.4 native-run : 1.5.0

System:

ios-deploy : 1.11.4 NodeJS : v16.14.0 (/usr/local/bin/node) npm : 8.1.0 OS : macOS Monterey Xcode : Xcode 13.3 Build version 13E113

  • Plugin version: Latest version
  • Platform: Android
  • OS version:
  • Device manufacturer and model:
  • Running in Simulator:
  • Cordova version (cordova -v): 11.0.0
  • Cordova platform version (cordova platform ls):
  • Plugin configuration options:
  • Link to your project:

Context

In Ios its working fine but in android while creating build it shows error of android permission.

Expected Behavior

Its should not have any issue while android build

Actual Behavior

Task :app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:mergeDebugResources’.

Could not resolve all files for configuration ‘:app:debugRuntimeClasspath’. Could not find com.intentfilter:android-permissions:0.1.7. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/intentfilter/android-permissions/0.1.7/android-permissions-0.1.7.pom - https://repo.maven.apache.org/maven2/com/intentfilter/android-permissions/0.1.7/android-permissions-0.1.7.pom Required by: project :app

  • Try:

Possible Fix

   - https://dl.google.com/dl/android/maven2/com/intentfilter/android-permissions/0.1.7/android-permissions-0.1.7.pom
   - https://repo.maven.apache.org/maven2/com/intentfilter/android-permissions/0.1.7/android-permissions-0.1.7.pom
   - no files found here.

Steps to Reproduce

1.create an ionic 6 app 2. installed this plugin 3.create android build Screenshot 2022-03-16 at 11 14 24 PM

Context

Debug logs

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:17

github_iconTop GitHub Comments

2reactions
josuelmmcommented, Mar 28, 2022

You must request permission to run in the background, and notify the client that they must remove the battery saving app.

You do the battery permission with powerOptimization import { PowerOptimization } from ‘@awesome-cordova-plugins/power-optimization/ngx’;

async requestPermissionLocationForever(){ this.androidPermissions.requestPermission('android.permission.ACCESS_BACKGROUND_LOCATION') .then(result => { if (!result.hasPermission){ this.permissionActivityForever = false; }else{ this.permissionActivityForever = true; } }) .catch(err=>{ this.permissionActivityForever = false; }); }

`async RequestOptimizations(){ this.powerOptimization.RequestOptimizations().then(status =>{ this.IsIgnoringBatteryOptimizations(); this.IsIgnoringDataSaver(); this.HaveProtectedAppsCheck(); }) .catch(error => { this.permissionBattery = false; }); }

async IsIgnoringDataSaver(show = false){ this.powerOptimization.IsIgnoringDataSaver().then((status) => { this.permissionBackground = status; if (status == false && show == true){ this.powerOptimization.RequestDataSaverMenu().then((result) => {}, (err) => {}); } }, (err) => { this.permissionBackground = false; }); }

async IsIgnoringBatteryOptimizations(show = false){ this.powerOptimization.IsIgnoringBatteryOptimizations().then(status =>{ if (status == false && show == true){ this.showAlertBattery(); }

  if (status == false){
    setTimeout(()=>{
      this.IsIgnoringBatteryOptimizations();
      this.IsIgnoringDataSaver();
      this.HaveProtectedAppsCheck();
    },10000);
  }
  this.permissionBattery = status;
})
.catch(error => {
  this.permissionBattery = false;
});

}

async HaveProtectedAppsCheck(){ this.powerOptimization.HaveProtectedAppsCheck().then((result) => { this.permissionBatteryProtect = result; }, (err) => { this.permissionBatteryProtect = false; }); }`

1reaction
josuelmmcommented, Mar 27, 2022

this.androidPermissions.requestPermission('android.permission.ACTIVITY_RECOGNITION') .then(result => { if (!result.hasPermission){ this.permissionActivity = false; }else{ this.permissionActivity = true; } }) .catch(err=>{ this.permissionActivity = false; });

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mauron85/cordova-plugin-background-geolocation not ...
background geolocation plugin doesn't works in ionic 6 angular. does anyone know how to fix please help us too.
Read more >
@heartmon/cordova-plugin-background-geolocation - npm
@heartmon/cordova-plugin-background-geolocation. TypeScript icon, indicating that this package has built-in type declarations.
Read more >
ionic ios build fail background geolocation - cordova
I think somting wrong with the Geolocation, but i don't know what. ionic version: 6.6.0 cordova.cmd plugin ls cordova-android-play-services ...
Read more >
Location Permissions and Accuracy: Ionic 4 | by Rajesh Mishra
ionic cordova plugin add @mauron85/cordova-plugin-background-geolocation Add following in your app.module page: · import { BackgroundGeolocation } from '@ionic- ...
Read more >
cordova-plugin-background-geolocation - Issuehunt
mauron85 / cordova-plugin-background-geolocation Error in Ionic 6 Android ... Forground and background issues in API 31-32 Android 12 emulator.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found