Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic Could not find support-vector-drawable.aar

Having a weird issue on my Ionic app, I was able to build just fine yesterday but on one build it downloaded a bunch of files like it does when building android and then I got the following error:

Could not find support-vector-drawable.aar (com.android.support:support-vector-drawable:27.1.1). Searched in the following locations: https://jcenter.bintray.com/com/android/support/support-vector-drawable/27.1.1/support-vector-drawable-27.1.1.aar

When following the link https://jcenter.bintray.com/com/android/support/support-vector-drawable/27.1.1/support-vector-drawable-27.1.1.aar the page has the following JSON:

{
  "errors": [
    {
      "status": 404,
      "message": "Could not find resource"
    }
  ]
}
like image 597
Joe Scotto Avatar asked Oct 24 '18 17:10

Joe Scotto


2 Answers

Glad to know I'm not the only one. This happened to me too.

I've had to use the cordova-android-support-gradle-release plugin in the past to handle conflicts with different plugins leveraging different versions of the android support libraries. I had been using this cordova plugin with version 27.+. Changing that to force version 27.1.0 got things building again for me. (A command to add that plugin is below).

cordova plugin add cordova-android-support-gradle-release  --variable ANDROID_SUPPORT_VERSION=27.1.0

Obviously it would be nice to know why this 27.1.1 file went missing today, which would allow continuing to use 27.+. However, hopefully this gets you running again.

----2/6/2019 Update:----

This issue was resolved in my project for the past 4 months. Then today it came back. For some reason the cordova-android-support-gradle-release .gradle file wasn't getting added to the build (even though others were). I followed the answer from @Moofish, and removed/re-installed the plugin (at 27.1.0 again). Then builds started working again. For me this did upgrade the cordova-android-support-gradle-release plugin from @1.4.4 to @2.0.1. Not sure if that was a fluke or a predictable thing.

like image 145
BRass Avatar answered Nov 08 '22 01:11

BRass


I will leave a different solution from BRass' in case you don't want to play around with your plugins or Android support versions.

We had the exact same errors when trying to build our app and solved it by adding a script hook on after_platform_add to re-order the repository list in build.gradle file so the project looks for the .aar in a different place.

// Add <hook src="path/to/after_platform_add.js" type="after_platform_add" /> to your config.xml

var fs = require('fs');

module.exports = function(ctx) {
    var gradlePath = './platforms/android/build.gradle';
    var gradleFile = fs.readFileSync(gradlePath, 'ascii');
    if (ctx.opts.platforms[0].indexOf('android') !== -1) {
        gradleArray = gradleFile.split('\n');
        for (var i = 0; i < gradleArray.length; i++) {
            if (gradleArray[i].includes('jcenter()') && gradleArray[i + 1].includes('maven')) {
                var jcenter = gradleArray.splice(i, 1)[0];
                gradleArray.splice(i + 3, 0, jcenter);
            }
        }
        gradleFile = gradleArray.join('\n');
        fs.writeFileSync(gradlePath, gradleFile);
        console.log('Reordered repositories');
    }
}
like image 1
Joao Avatar answered Nov 08 '22 00:11

Joao