'Ionic6 Capacitor: After adding "cordova-plugin-advanced-http", app build in studio start giving error cannot find symbol CordovaPluginPathHandler
Please help resolving this issue. I was able to build app in android studio after command "ionic capacitor build android". Android works fine until I added the plugin cordova-plugin-advanced-http, the error stated as follows:
D:\temp\myApp4\android\capacitor-cordova-android-plugins\src\main\java\org\apache\cordova\file\FileUtils.java:39: error: cannot find symbol import org.apache.cordova.CordovaPluginPathHandler; ^ symbol: class CordovaPluginPathHandler location: package org.apache.cordova
[capacitor] [info] Found 5 Cordova plugins for android:
[capacitor] [email protected]
[capacitor] [email protected]
[capacitor] [email protected]
[capacitor] [email protected]
[capacitor] [email protected]
[capacitor] √ copy android in 4.44s
[capacitor] √ Updating Android plugins in 25.69ms
[capacitor] [info] Found 4 Capacitor plugins for android:
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] [info] Found 5 Cordova plugins for android:
[capacitor] [email protected]
[capacitor] [email protected]
[capacitor] [email protected]
[capacitor] [email protected]
[capacitor] [email protected]```
Solution 1:[1]
You should upgrade the version of the cordova android.
For the file android/variables.gradle
Change the cordovaAndroidVersion = '7.0.0' to cordovaAndroidVersion = '10.1.2'
In the meantime, you should change the minSdkVersion to >= 22
Solution 2:[2]
To ensure this works, do following;
- Go to this location on your file explorer
<android\capacitor-cordova-android-plugins\src\main\java\org\apache\cordova\file>the location houses plugins to make your app work. - Create a new file name it "CordovaPluginPathHandler.java"
- Open the file, then paste the code below in there
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.apache.cordova;
import androidx.webkit.WebViewAssetLoader;
/**
* Wrapper class for path and handler
*/
public class CordovaPluginPathHandler {
private final WebViewAssetLoader.PathHandler handler;
public CordovaPluginPathHandler(WebViewAssetLoader.PathHandler handler) {
this.handler = handler;
}
public WebViewAssetLoader.PathHandler getPathHandler() {
return handler;
}
}
- save file, then go and build app.
Solution 3:[3]
As a temporary solution, I downgraded the version of cordova-plugin-file to 6.0.2, it works for me
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | liuwin7 |
| Solution 2 | Tyler2P |
| Solution 3 |
