The title is pretty self explanatory, I had written a simple capacitor 6 plugin that scans and returns a list of available wifi networks. When I build and run a simple vue/capacitor app for testing the plugin, I get the error that the call is rejected with the message “Unable to request location permissionnnnn” whenever I launch the scanWifi method through a button click:
@PluginMethod
public void scanWifi(PluginCall call) {
if (wifiManager == null) {
wifiManager = (WifiManager) getContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
call.reject("WifiManager not initialized");
}
if (!wifiManager.isWifiEnabled()) {
call.reject("Wi-Fi is not enabled");
return;
}
if (hasLocationPermission()) {
startWifiScan(call);
} else {
requestLocationPermission(call);
// Handle the case where the location permission cannot be requested
call.reject("Unable to request location permission");
}
}
private boolean hasLocationPermission() {
if (getBridge() == null) {
// Handle the case where the Bridge is not available
return false; // or throw an exception, or take appropriate action
}
return getPermissionState(LOCATION_PERMISSION) == PermissionState.GRANTED;
}
private void requestLocationPermission(PluginCall call) {
if (getPluginHandle() == null) {
call.reject("Unable to request location permissionnnnn");
return;
}
requestPermissionForAlias(LOCATION_PERMISSION, call, "locationPermissionCallback");
}
so both the getBridge() and getPluginHandle() methods are returning null. Most likely due to a repeating error in Bridge.java, BridgeActivity.java, and BridgeFragment.java, which are a part of the package installed by capacitor for the plugin
Project directory
I never touched the files there but they just give out errors due to the missing com.getcapacitor.android package and they are the reason the Bridge isn’t being used
I never touched the files there but they just give out errors due to the missing com.getcapacitor.android package and they are the reason the Bridge isn’t being used.
Tried recreating the project from scratch but as soon as I try building those errors come back.