El dia de hoy me encontré al compilar con la versión de cordova para android@10.0.0
Así que antes que nada les muestro el error y la solución que encontré en el siguiente enlace
https://githubmemory.com/repo/apache/cordova-plugin-file-transfer/issues/306
Este el error al compilar la aplicación
> Task :app:compileDebugJavaWithJavac FAILED
cordovaProjectFoler/platforms/android/app/src/main/java/org/apache/cordova/filetransfer/FileTransfer.java:48: error: cannot find symbol
import org.apache.cordova.Whitelist;
^
symbol: class Whitelist
location: package org.apache.cordova
cordovaProjectFoler/platforms/android/app/src/main/java/org/apache/cordova/filetransfer/FileTransfer.java:691: error: cannot find symbol
Whitelist whitelist = (Whitelist)gwl.invoke(webView);
^
symbol: class Whitelist
location: class org.apache.cordova.filetransfer.FileTransfer
cordovaProjectFoler/platforms/android/app/src/main/java/org/apache/cordova/filetransfer/FileTransfer.java:691: error: cannot find symbol
Whitelist whitelist = (Whitelist)gwl.invoke(webView);
^
symbol: class Whitelist
location: class org.apache.cordova.filetransfer.FileTransfer
Lo primero que realicé fue remover la app android con el comando
cordova platform rm android
despues agregre el plugin de cordova-plugin-file-transfer
me metí a los archivos y coloque lo siguiente
reemplacé la linea
import org.apache.cordova.Whitelist;
por la siguiente
import org.apache.cordova.AllowList;
y el siguiente código
Boolean shouldAllowRequest = null;
if (isLocalTransfer) {
shouldAllowRequest = true;
}
if (shouldAllowRequest == null) {
try {
Method gwl = webView.getClass().getMethod("getWhitelist");
AllowList whitelist = (AllowList)gwl.invoke(webView);
shouldAllowRequest = whitelist.isUrlAllowListed(source);
} catch (NoSuchMethodException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
}
por lo nuevo
Boolean shouldAllowRequest = null;
if (isLocalTransfer) {
shouldAllowRequest = true;
}
if (shouldAllowRequest == null) {
try {
Method gwl = webView.getClass().getMethod("getWhitelist");
AllowList whitelist = (AllowList)gwl.invoke(webView);
shouldAllowRequest = whitelist.isUrlAllowListed(source);
} catch (NoSuchMethodException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
}
después volví a compilar
con los comandos
cordova platform add android@10.0.0
y
cordova run android
y me funcionó .
Espero les ayude
Comentarios
Publicar un comentario
Hola que tal,dime tu opinión