7

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]        cordova-plugin-advanced-http@3.3.1
[capacitor]        cordova-plugin-file@7.0.0
[capacitor]        cordova-plugin-geolocation@4.1.0
[capacitor]        cordova-plugin-nativestorage@2.3.2
[capacitor]        cordova-plugin-request-location-accuracy@2.3.0
[capacitor] √ copy android in 4.44s
[capacitor] √ Updating Android plugins in 25.69ms
[capacitor] [info] Found 4 Capacitor plugins for android:
[capacitor]        @capacitor/app@1.1.1
[capacitor]        @capacitor/haptics@1.1.4
[capacitor]        @capacitor/keyboard@1.2.2
[capacitor]        @capacitor/status-bar@1.0.8
[capacitor] [info] Found 5 Cordova plugins for android:
[capacitor]        cordova-plugin-advanced-http@3.3.1
[capacitor]        cordova-plugin-file@7.0.0
[capacitor]        cordova-plugin-geolocation@4.1.0
[capacitor]        cordova-plugin-nativestorage@2.3.2
[capacitor]        cordova-plugin-request-location-accuracy@2.3.0```
  • Please, could you share the link to the `cordova-plugin-advanced-http` plugin? Why do you want to use this plugin? Is this plugin repo updated or outdated at this moment? Thanks! – Everton Costa Apr 15 '22 at 15:46
  • Using this plugin... https://ionicframework.com/docs/native/http – Nurulhasan Phansopkar Apr 16 '22 at 00:09
  • It can be a conflict between Http libraries... Have you declared this plugin in the `app.module.ts` file? And also removed the `HttpClientModule` from there? Please, do that and try again. – Everton Costa Apr 16 '22 at 14:42
  • Yes. That I have already done – Nurulhasan Phansopkar Apr 18 '22 at 02:21
  • I am having the same issue when installing ionicframework.com/docs/native/file as a capacitor plugin - good to know this isn't just me. It looks like the `file` plugin for capacitor was updated in the last week (https://www.npmjs.com/package/cordova-plugin-file) and rolling back to the previous 6.0.2 version from 7.0.0 allowed my application to compile. Could you try version 3.2.2 of the `http` plugin? https://www.npmjs.com/package/cordova-plugin-advanced-http – EpicVoyage Apr 18 '22 at 18:16
  • @NurulhasanPhansopkar Unfortunately https://ionicframework.com/docs/native/http has had an unaddressed bug for about 6 months now relating to POSTing FormData and so that's at least why I need to use https://npmjs.com/package/cordova-plugin-advanced-http. – Rozgonyi Jun 13 '22 at 20:24

3 Answers3

25

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

liuwin7
  • 493
  • 3
  • 6
10

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

inkrot
  • 448
  • 5
  • 12
6

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.
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Mou Yo
  • 61
  • 1