Ionic Could not find support-vector-drawable.aar - android

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"
}
]
}

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.

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');
}
}

I had the same problem and I already installed the plugin of cordova-android-support-gradle-release, so I removed the plugin (ionic cordova plugin rmcordova-android-support-gradle-release) and installed again the plugin (cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.1.0), emmm...and it worked!

Try changing the build.gradle in platforms and in app/build.gradle to:
{
mavenCentral()
google() // Add this
jcenter()
maven {
url "https://maven.google.com"
}
}

Related

Javadoc is not being generated for Android project

I'm working on an Android project and trying to generate javadoc with the task below, but it doesn't generate anything.
I have tried to trace back the issue to changes in the project. Checking out past commits and trying to create javadoc fails, even though in the past it worked.
The only thing for sure that changed for me that might explain this behaviour is the upgrade to a newer version of macOs Big Sur and updating Android Studio.
Does anyone have an idea what the problem might be?
Setup:
macOS Big Sur Version 11.4
Android Studio 4.2.1
Gradle 6.5
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
options.memberLevel = JavadocMemberLevel.PUBLIC
failOnError = false
source = variant.javaCompiler.source
def androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
doFirst {
classpath = files(variant.javaCompile.classpath.files) + files(androidJar)
}
options {
links "http://docs.oracle.com/javase/7/docs/api/"
linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
}
}
Well after a long time of searching I found the answer: it was the update from AS 4.1.3 to 4.2.x with which Google decided to package Java11 instead of 8.
Building and compiling was possible, but javadoc generation was broken for whatever reason.

Capacitor v3 plugins not working on android build

I'm using capacitor v3 beta and there are no problem working in web and iOS but can't run android app.
Build is done fine but when running the app appears this error:
E/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 41296 - Msg: ERROR Error: Uncaught (in promise): Error: "Storage" plugin is not implemented on android
Error: "Storage" plugin is not implemented on android
To solve this error I've removed the storage plugin and replaced with ionic/storage plugin. But when I use other plugin, for example the Keyboard, the error shows up saying that Keyboard plugin is not implemented on android.
So I suppose that there is some problem with Android builds or project configuration.
These are de node dependencies in my package.json
"#capacitor/android": "^3.0.0-beta.6",
"#capacitor/core": "^3.0.0-beta.1",
"#capacitor/storage": "^0.3.1",
And my capacitor.config.json file
{
"appId": "net.flowww.me",
"appName": "FLOWwwMe",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"cordova": {}
}
iOS version works well with this configuration.
Storage plugin not worked after Ionic v3 upgrades from v2.
It work after manually adding a plugin to MainActivity.java for me:
package com.ionic.app;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.capacitorjs.plugins.storage.StoragePlugin;
public class MainActivity extends BridgeActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(StoragePlugin.class);
}
}
I also faced the same problem when upgrading from capacitor 2 to 3
As it turned out, I forgot to execute:
npx cap sync android
This solved the problem
you must in mainActivity : add(StoragePlugin.class);
After creating new project and reviewing file differences saw that I have not installed
"#capacitor/cli": "^3.0.0-beta.6"
So I installed it and all compiles successfully.
In Capacitor's v2 doc, in the page dedicated to Storage Plugin (https://capacitorjs.com/docs/apis/storage) the import is done like:
import { Storage } from '#capacitor/storage';
Then in the Capacitor's v2 doc for Using Plugins (https://capacitorjs.com/docs/v2/apis) you'll find that:
Import the Plugins object. It represents the registry of all Capacitor plugins.
import { Plugins } from '#capacitor/core';
Get a plugin from the Plugin Registry (Plugins object).
const { Browser } = Plugins;
Use the plugin API:
async openBrowser() {
// On iOS, for example, open the URL in SFSafariViewController (the in-app browser)
await Browser.open({ url: "https://ionicframework.com" });
}
A common mistake is to import a plugin directly, then use the plugin API >immediately, resulting in the web implementation being used:
import { Browser } from '#capacitor/core';
async openBrowser() {
// On iOS, for example, this will open the URL in Safari instead of
// the SFSafariViewController (in-app browser)
await Browser.open({ url: "https://ionicframework.com" });
}
By using the plugins from the plugin registry (Plugins object), the native implementation of the plugin is used (if available), with fallback to the web version.
So if you're using Quasar with Capacitor v2 you probably gone crazy like me. Just replace Browser with Storage.
Maybe in v3 that problem is solved and that's why legomolina's answer works.
For Capacitor V3 plugins (tested on Android 11 & Ionic 5)
capacitor.plugins.json has the entry for Storage plugin,
MainActivity.java should not have the onCreate function, where CapV3 uses native API,
Try setting minifyEnabled=false in build.gradle.
If error disappears, create pro-guard rules in proguard-rules.pro as in https://github.com/ionic-team/capacitor/issues/739
I found the issue was solved by simply starting up Android Studio. It sync'd Gradle automatically and then I just restarted my Android dev environment - the error was gone and I was able to access Storage as per the capaitor plugin docs.
See https://capacitorjs.com/docs/android/troubleshooting#plugin-not-implemented

Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper

I develop a hybrid app usin cordova. While I was trying to build the android verion of my App, i got this error:
Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio.
..although Android Studio is already installed and everything worked so far.
Does anybody know the reason for this issue?
The problem is in the file: \cordova\lib\check_reqs.js
When cordova checks the location of graddle is doing this: var androidPath = path.join(process.env['ProgramFiles'], 'Android') + '/';
If you don't have installed in certain location, cordova can't find the file.
So... edit tcheck_reqs.js and do this (i'm using Windows 10 and cordova 7.0.1):
return 'C:\\Android\\sdk\\gradle\\gradle-3.2\\bin\\gradle';
if (androidStudioPath !== null && fs.existsSync(androidStudioPath)) {
var dirs = fs.readdirSync(androidStudioPath);
if(dirs[0].split('-')[0] == 'gradle') {
return path.join(androidStudioPath, dirs[0], 'bin', 'gradle');
}
} else {
//OK, let's try to check for Gradle!
return forgivingWhichSync('gradle');
}
It's not a real fix, but if you are sure of your gradle location it will be fine, hope cordova fix this.
http://www.bubuko.com/infodetail-2108699.html,
its about your cordova version;

include.gradle file being generated is causing problems

When building a project I get the following error:
Flavor 'nativescript-telerik-ui' has unknown dimension 'nativescript-telerik-ui'.
It happens only when using the pro version through the #progress registry. Doesn't happen with the local .tgz pro version.
I noticed the error has to do with the include.gradle file it generates. I read the following article: https://docs.nativescript.org/plugins/plugins#includegradle-specification
It says that when the plugin doesn't have the include.gradle, at build time gradle creates a default one with default elements. When I saw the include.gradle it generated for the plugin it seems to have generated a default one like so:
android {
productFlavors {
"nativescript-telerik-ui" {
dimension "nativescript-telerik-ui"
}
}
}
The include.gradle generated for the local .tgz version of the plugin is like this:
android {
productFlavors {
"F6" {
dimension "nativescripttelerikuipro"
}
}
}
I replaced the default include.gradle with the latter and it got past the error. You can recreate the problem by following these steps:
create a new hello world app
use the command npm login --registry=https://registry.npm.telerik.com/ --scope=#progress to log in if you're a paying customer.
use the command npm install --save #progress/nativescript-telerik-ui-pro to install the plugin
use tns run android
Is there anything I can do to solve this problem? Really need help on this.
My name is Vladimir and I am part of the nativescript-telerik-ui-pro team. Thank you for logging this issue in our feedback portal. We are going to review it as soon as possible and update you regarding its status, but from what I currently see there is some incorrect "parameters" passed to the 'pro' version of the plugin that are going to be resolved very fast.
We apologize for any inconvenience that this is causing.

cordova_plugins.js is not updated after adding new plugin

I just started using cordova with android.
I have a problem when adding plugins.
I used cordova plugin to add org.apache.cordova.camera from cmd in Win7.
It is added but not in cordova_plugins.js file.
File is getting updated when I type cordova run android this in cmd but then all my code is deleted and replaced with skeletal web-based application. Why is this happening? How to automatically get this file updated?
This is how my cordova_plugins.js looks like:
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"file": "plugins/org.apache.cordova.dialogs/www/notification.js",
"id": "org.apache.cordova.dialogs.notification",
"merges": [
"navigator.notification"
]
},
{
"file": "plugins/org.apache.cordova.dialogs/www/android/notification.js",
"id": "org.apache.cordova.dialogs.notification_android",
"merges": [
"navigator.notification"
]
},
{
"file": "plugins/org.apache.cordova.vibration/www/vibration.js",
"id": "org.apache.cordova.vibration.notification",
"merges": [
"navigator.notification"
]
}
];
module.exports.metadata =
// TOP OF METADATA
{
"org.apache.cordova.dialogs": "0.2.5",
"org.apache.cordova.vibration": "0.3.6"
}
// BOTTOM OF METADATA
});
As you can see there is no camera plugin. It is added in my project, but not in this file and that's reason it is not working when I try to use it in my js files.
I hope you understood what I am saying.
Does it show up in the list when you type:
cordova plugin ls
Did you rerun:
cordova build wp7
What worked for me:
Delete ./platforms [or move to some other place as a backup]
Delete ./plugins [or move to some other place as a backup]
Build e.g: ionic cordova build android --prod or ionic cordova prepare
This resets everything, fetches FRESH plugins from config.xml
PS: add/remove/update versions of plugins and packages from package.json and run npm i beforehand.
You might need to update config.xml with the right versions too (if you are trying to fix a version conflict)
I was having the same issue with another plugin, and I did the old and magic trick: I restarted Windows (Windows 7)
After restart Windows I did the following steps:
Removed all plugins (I don't know if it is necessary to remove all)
Removed cordova_plugins.js
I executed platforms/android/cordova/clean.bat
Mi plugin had a dependency (Inappbrowser), so I installed Inappbrowser first.
I installed the plugin
I don't know if all these steps are necessary, maybe just works restarting Windows. However, it worked for me.

Categories

Resources