Ionic6 Capacitor: After adding "cordova-plugin-advanced-http", app build in studio start giving error cannot find symbol CordovaPluginPathHandler
Asked Answered
O

3

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]        [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]```
Obie answered 15/4, 2022 at 11:24 Comment(6)
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!Splint
Using this plugin... ionicframework.com/docs/native/httpObie
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.Splint
Yes. That I have already doneObie
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 (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? npmjs.com/package/cordova-plugin-advanced-httpCharkha
@NurulhasanPhansopkar Unfortunately 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 npmjs.com/package/cordova-plugin-advanced-http.Gwenore
S
27

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

Suez answered 19/5, 2022 at 7:44 Comment(3)
This is the right answer!Claudineclaudio
Thank you, this is a good idea changing the versions to the ones suggested anyways.Lissalissak
Thank you, I was looking exactly for this.Leatrice
S
10

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

Symer answered 6/5, 2022 at 18:25 Comment(5)
Best solution...Sadism
This works for me, Version 7.x did not work as of today!Resendez
This works for me also V 7.x still not working!Thirion
This works for me also V 7.x still not working!Hayner
As you said, this is a temporary solution.Fifine
M
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.
Mariellemariellen answered 23/4, 2022 at 20:55 Comment(1)
didn't help at all..Harem

© 2022 - 2024 — McMap. All rights reserved.