cordova-plugin-background-geolocation icon indicating copy to clipboard operation
cordova-plugin-background-geolocation copied to clipboard

AAPT: error: resource mipmap/icon (aka io.ionic.starter:mipmap/icon) not found.

Open Absant94 opened this issue 4 years ago • 15 comments

Im using this plugin on my app, but when I use it on a page, all the times throws this error.

Your Environment

Ionic info:

   Ionic CLI                     : 6.4.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.0.7
   @angular-devkit/build-angular : 0.901.0
   @angular-devkit/schematics    : 9.1.0
   @angular/cli                  : 9.1.0
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 9.0.0 ([email protected])
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 11 other plugins)

Utility:

   cordova-res (update available: 0.11.0) : 0.9.0
   native-run (update available: 1.0.0)   : 0.3.0

System:

   Android SDK Tools : 26.1.1 (/root/Android/Sdk/)
   NodeJS            : v13.8.0 (/usr/local/bin/node)
   npm               : 6.13.6
   OS                : Linux 5.3

Cordova plugin list:```



cordova-android-support-gradle-release 3.0.1 "cordova-android-support-gradle-release"
cordova-plugin-advanced-http 2.4.1 "Advanced HTTP plugin"
cordova-plugin-background-geolocation 3.1.0 "CDVBackgroundGeolocation"
cordova-plugin-background-mode 0.7.3 "BackgroundMode"
cordova-plugin-ble-central 1.2.4 "BLE"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"

Steps to Reproduce

1.sudo ionic cordova run android 2. 3. 4.

Context

I want to use background geolocation to follow my movements durin a period of time

Debug logs

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
  /home/absant/Escritorio/workspace/project2/platforms/android/app/src/main/res/xml/authenticator.xml:2: AAPT: error: resource mipmap/icon (aka io.ionic.starter:mipmap/icon) not found.
      
  error: failed linking file resources.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s
[ERROR] An error occurred while running subprocess cordova.
        ```


Absant94 avatar Apr 06 '20 10:04 Absant94

Execute these commands:

mkdir -p platforms/android/app/src/main/res/mipmap 
cp resources/icon.png platforms/android/app/src/main/res/mipmap 
cp resources/splash.png platforms/android/app/src/main/res/mipmap 

pabloleone avatar Apr 06 '20 15:04 pabloleone

Execute these commands:

mkdir -p platforms/android/app/src/main/res/mipmap 
cp resources/icon.png platforms/android/app/src/main/res/mipmap 
cp resources/splash.png platforms/android/app/src/main/res/mipmap 

Hi! Thanks! Now the app "build" but launch a "defaultErrorLogger" , so the app is installed but is blank .And before install the plugin it was working. Am i doing something wrong?

Absant94 avatar Apr 06 '20 20:04 Absant94

With this fix I was able to build, but...

Is there any way to resolve this without digging in the platform-specific folders?

Also, how is this specific to this plugin (if it now is)?

If it is, could it be fixed once and for all by updating the plugin?

Thanks in advance.

andersborgabiro avatar May 03 '20 18:05 andersborgabiro

I already posted the solution here https://github.com/apache/cordova-android/issues/678#issuecomment-574714031

Is not a good practice to touch the files inside platforms> (edit or create stuff there), so I recommend to change the ICON variable and keep it like

<plugin name="@mauron85/cordova-plugin-background-geolocation" spec="3.0.3"> ... <variable name="ICON" value="@mipmap/ic_launcher" /> ... </plugin>

This route "mipmap/ic_launcher" will work. BTW now package is @mauron85/cordova-plugin-background-geolocation, the other one is deprecated

ZumelzuR avatar Jun 16 '20 09:06 ZumelzuR

Just to complement the answer from @ZumelzuR : You can also change this configuration in your package.json:

// package.json
  {
    "cordova": {
      "plugins": {
        "@mauron85/cordova-plugin-background-geolocation": {
          "ICON": "@mipmap/ic_launcher",        // <-- Change this to 'ic_launcher' 
          "SMALL_ICON": "@mipmap/ic_launcher",  // <-- Change this to 'ic_launcher' 
        },
      },
    },
  }

RaschidJFR avatar Jul 06 '20 18:07 RaschidJFR

After hours trying to solve this problem, my DEFINITIVE solution that worked fine (without touch the files inside platforms), was:

1º - run cordova platform remove android

2º - Added this line in my config.xml inside the tag <platform name="android"> <resource-file src="resources/android/icon/drawable-xxxhdpi-icon.png" target="app/src/main/res/mipmap/icon.png" />

3º - Update the plugin settings inside config.xml

<plugin name="@mauron85/cordova-plugin-background-geolocation" spec="3.1.0">
   <variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" />
   <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="26+" />
   <variable name="ICON" value="@mipmap/icon" />
   <variable name="SMALL_ICON" value="@mipmap/icon" />
   <variable name="ALWAYS_USAGE_DESCRIPTION" value="App requires background tracking " />
   <variable name="MOTION_USAGE_DESCRIPTION" value="App requires motion detection" />
</plugin>

4º - Configure my package.json

// package.json
  {
    "cordova": {
      "plugins": {
      "@mauron85/cordova-plugin-background-geolocation": {
        "GOOGLE_PLAY_SERVICES_VERSION": "11+",
        "ANDROID_SUPPORT_LIBRARY_VERSION": "26+",
        "ICON": "@mipmap/icon",
        "SMALL_ICON": "@mipmap/icon",
        "ACCOUNT_NAME": "@string/app_name",
        "ACCOUNT_LABEL": "@string/app_name",
        "ACCOUNT_TYPE": "$PACKAGE_NAME.account",
        "CONTENT_AUTHORITY": "$PACKAGE_NAME"
      },
      },
    },
  }

5º - Last step run cordova platform add android

IONIC VERSION: 6.4.0 CORDOVA VERSION: 9.0.0 ([email protected]) NODE VERSION: v10.16.0

lrcampos97 avatar Jul 06 '20 19:07 lrcampos97

I am new to both Android and Cordova plugins, but I wanted to try it for a Quasar app. I am not sure if I am right, but my impression is that there is very little amount of serious Cordova plugin development anymore...? Seems like there is a lot of abandoned forks, that people have moved on except for a few "bumped version" pushes, and many plugins seem to be slowly dying... I wanted to give this plugin a try, but I ran into the same error as described here... I have tried all the described solutions, but I am still getting an error: "Source path does not exist: resources/android/icon/drawable-xxxhdpi-icon.png".

But are these solutions just workarounds, and is this a real bug that should be solved in the plugin? (because from reading these comments I find it hard to tell where the real problem lies)

w-a-b avatar Jul 10 '20 21:07 w-a-b

Yeah, I know what you mean @w-a-b . I don't think it's a real bug, I think that many of us do not fully understand the structure of a Gradle project and its integration with Cordova, as well as how to successfully use the configuration options for the stack.

It's been a couple of months since my last Cordova project so my memory is getting blurry and I don't have a concrete example to show or to give you a solution, but from what I get is that the path to the icon file will depend on the file structure that your Gradle project generates. I wouldn't be surprised if it changed from one framework to another or even from one version to another. If this fix works for Ionic I don't know whether it will work for Quasar.

RaschidJFR avatar Jul 10 '20 22:07 RaschidJFR

I agree with you @w-a-b . I'm not an expert with Android and Cordova. But maybe you can try again the solution and change the Source path "resources/android/icon/ICON_NAME". I don't know how Quasar works, but after the framework builds the app, probably it will generate some files to "resources/android/icon" there you need to find the file that is your icon and then, change the Source path for your correct file name.

I think you @w-a-b are on the right way, just need to make a small change for this to work.

lrcampos97 avatar Jul 13 '20 09:07 lrcampos97

@RaschidJFR , @Ircampos97, thank you guys, I appreciate it and will give it a try. Plan B is to buy a cordova-background-geolocation-lt license, even if it seems to be a bit overkill for my needs.

w-a-b avatar Jul 13 '20 10:07 w-a-b

@lrcampos97 's solution worked for me.

JoseAlbertoDev avatar Sep 10 '20 16:09 JoseAlbertoDev

Please update this as a fix, it is ridiculous that we cannot compile until manual fix this bug.

linhtranvu avatar Nov 02 '20 01:11 linhtranvu

Mi solución fue armar un Hook que copie uno de mis iconos en la carpeta pedida y con el nombre adecuado.

            var fs = require('fs');
            var path = require('path');
            var rootdir = context.opts.projectRoot;

            var srcfile = path.join(rootdir,"resources/android/icon_notificacion/drawable-hdpi/icon.png");
            var destfile = path.join(rootdir,"platforms/android/app/src/main/res/mipmap/icon.png");

            fs.createReadStream(srcfile).pipe(fs.createWriteStream(destfile));

chacabuk avatar Nov 17 '20 12:11 chacabuk

Add the following line to the android platform in config.xml: <resource-file src="resources/android/icon/drawable-xxxhdpi-icon.png" target="app/src/main/res/mipmap/icon.png" />

markdegrootnl avatar Feb 20 '21 14:02 markdegrootnl

All I had to do to resolve this was add ICON and SMALL_ICON variables to the plugin add command line. Didn't need to copy any icon resource as @mipmap/ic_launcher already exists.

cordova --save plugin add @mauron85/cordova-plugin-background-geolocation \
  --variable GOOGLE_PLAY_SERVICES_VERSION="+" \
  --variable ANDROID_SUPPORT_LIBRARY_VERSION="$ANDROID_SUPPORT_LIBRARY_VERSION" \
  --variable ALWAYS_USAGE_DESCRIPTION="$ALWAYS_USAGE_DESCRIPTION" \
  --variable ICON="@mipmap/ic_launcher" \
  --variable SMALL_ICON="@mipmap/ic_launcher"

Mehuge avatar Apr 16 '21 12:04 Mehuge