I am currently developing an Android application with Cordova and am trying to use the following plugin, to encrypt the source files.
https://github.com/tkyaji/cordova-plugin-crypt-file
While iOS is working fine, on Android I get the following error.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
Without the plugin, everything is working fine. I do have the CSP set and am also using the whitelist plugin where I have added localhost in my config.xml. I have searched for quite a while now, but all seem to be solving the problem with whitelisting, which is not working for me.
I am currently using Cordova 5.4.1
Any help/idea would be appreciated.
Best regards
Runned into the same problem, solved this by allowing localhost request on the server for that specific action.
header("Access-Control-Allow-Origin: http://localhost");
See also the github issue: https://github.com/tkyaji/cordova-plugin-crypt-file/issues/4
Related
I have created an Angular 2 application and I'm looking for creating an Android application with Apache Cordova. When I load the application in a Marshmallow emulator, the application does not load any of the declared resources. If I use the browser plugin it works as expected. Using Chrome to inspect the device's console reveals the following output.
Chrome console output:
If I run the Cordova initial sample it works in the same Android emulator so it has to be a problem with the sources. The code can be checked in the Github repository. The application is in the www directory, for testing it is necessary to add the android platform.
$ cordova platform add android
$ cordova run android
I can not found an answer for this problem:
The resources looks fine - discard file path issues.
The browser plugin works (Chrome) - discard application errors and security policies.
The cordova sample works as expected for Android - discard environment errors.
Please, does anyone knows what is the problem with this setup?
I have found the root cause. The problem is that by using the angular-cli tool, the tag <base href="/"> is being added automatically. According to the tag documentation, it serves a base to resolve all the document's relative URLs.
For this use case, removing the base tag or configuring it to a valid value like <base href="/android_asset/www/"> fixes the problems. As I do not use routing features (yet) I feel more confortable removing it or setting a value like <base href="."/> that it's suitable for more platforms builds.
Have you tried modifying Content-Security-Policy?
Or how about modifying 'allow-intent' in config.xml?
When I was having resources issue, these were helping.
My issue is similar to this question.
I have an HTML5-based Android app. It is wrapped in Cordova, and built using the Ionic Framework. When launched, the app loads an index.html file, which is located locally on the device and makes a cross-origin resource request. It therefore does not load for Android API 18 and higher.
The workaround to this restriction is to enable the setAllowUniversalAccessFromFileURLs setting. Given that my project is built using the Ionic Framework, what would be the correct way to enable this flag? Would I necessarily need to go into the Android project to enable the flag, or is there a cleaner way to do it via a settings file?
I have inherited this project and have very little experience with Ionic, Cordova, and HTML5, therefore any detail would be greatly appreciated. In the question above, the solution was to update to Cordova 2.8.1. I am running Cordova 5.1.1. and still experience the problem.
Can be a origin problem try to whitelist your remote domain.
Read this http://docs.phonegap.com/en/4.0.0/guide_appdev_whitelist_index.md.html
I have just updated my app to version 5 of apache cordova, but now I keep receiving: 404 (Not Found) on my AJAX requests, I also checked config.xml and access origin parameter is *.
Can someone help me?
Seeking a solution to the problem, I found a answer in documentation, I just install the new cordova-plugin-whitelist and the problem is solved.
After update to the Cordova 5 if you develop on Android platform version 4.0 you should add cordova-plugin-whitelist plugin.
Now by default all network requests is blocked. You could use CSP(Content Security Policy) to specify which resources allowed to access by webpage inside Cordova App.
I'd like to create a PhoneGap App and open a connection to another device through Bluetooth (https://github.com/don/BluetoothSerial). I started with the sample projects but nothing seems to happen with my settings, no events are triggered / console shows nothing.
I'm new to Phonegap and after struggling for days with installing NodeJs, Cordova (4.0.0), Phonegap (3.6.0-0.21.19), Ant, getting new Java JDK (1.7.0_71), updating Android (23, target here is Android API19) I can build and run Android apps. I followed http://www.pycode.com/android/creating-a-phonegap-cordova-3.0-app-in-eclipse.html as installation guide.
Nevertheless I couldn't build the jar file for Cordova (Target "jar" is not found), paths are set correctly. I searched online but the existing posts didn't help. Actually I found out that it's better to just use the CordovaApp-CordovaLib as a library, so I used this instead. Anyway it seems like I can't use any plugins at the moment (added in config.xml and gave Bluetooth permission in AndroidManifest.xml). I'm not even sure if this is the problem here.
Seems like many people are struggling with Phonegap and I hope somebody experienced the same issues and can help.. Thanks in advance!
Update
Figured out that the onDeviceReady method wasn't called at all. Checked for cordova.js (don't just use any!) and copied it into my C:\ProjectPath\platforms\android\assets\www folder.
Quite embarrassing, maybe that's why nobody's answered. I used the PhoneGap Developer App - of course this couldn't work. Use cordova build to build apk and test it on device..
I'm now at my wits ends with Phonegap and its Plugins!!
I have created an a Phonegap app and it works and it runs well on android. I now wish to simply use the Facebook JS SDK. I have been using the plugin found here. But I keep constantly running into 100 different errors.
The code in the ConnectPlugin.java is saying that Plugins has been deprecated. But I'm using Cordova 2.3.0 and in the Cordova 2.3.0.jar the Plugin.java class exists as seen in the picture below:
I'm really not sure what on Earth to do now to get this plugin to work? I have tried everything and have searched the net for hours with no working solution. I just need the Facebook plugin to work. Please any help would really be appreciated!!
Should you ever have any plugin problems ie there is complainant about the Plugin Class as above, then at least for Facebook this problem has been solved here