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]```
3

There are 3 answers

1
Mou Yo On

To ensure this works, do following;

  1. 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.
  2. Create a new file name it "CordovaPluginPathHandler.java"
  3. 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;
    }
}
  1. save file, then go and build app.
5
inkrot On

As a temporary solution, I downgraded the version of cordova-plugin-file to 6.0.2, it works for me

3
liuwin7 On

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