I created a web application that I need to convert to a mobile application, now all I have is html5/js/css files which means I don't have any www foder no platforms folder, not a cordova project ... I started first to build the app using cordova command lines, but I couldn't, I found many problems on that, I used then https://build.phonegap.com/ , and it works fine for me. In order to read the file, I have tried this code :
window.resolveLocalFileSystemURI("file:///android_asset/www/data/User.xml", function () {
alert("Success");
}, function () {
alert(" error ");
});
but, it didn't work. I added a try catch, the exception was :
window.resolveLocalFileSystemURI is not a function
Do i need to add something to my code to make it work ?
You need to install a plugin for this to work.
Basically, run "cordova plugin add org.apache.cordova.file" at your application's root directory.
For detailed instructions see here, under "Accessing the Feature":
http://docs.phonegap.com/en/edge/cordova_file_file.md.html#LocalFileSystem
UPDATE 2019
The correct way to add this plugin is now with this command in your project root:
cordova plugin add cordova-plugin-file
This is a core cordova plugin. Documentation found here on npm
Related
My previous builds work fine, but now I'm getting this error when I try to take a build. I don't know how to resolve this error.
If anyone faces the same issue please help me out.
Attempt to invoke virtual method'boolean com.facebook.react.uimanager.FabricViewStateManager.hasStateWrappper()' on a null object reference
I was able to narrow down what was causing the error for me by using adb logcat and tracing the app.
The issue stemmed from both <Input> (from react-native-elements) and <TextInput> (from react-native). Both would cause the error, and the app would run without error if I commented out any Input/TextInput elements in the Componenets.
I wasn't quite able to get it to work with #kangear 's response, but it was close. After a lot of digging and testing, I was able to get the app to work properly with the following line of code in android\app\build.gradle, in dependencies section:
implementation ("androidx.appcompat:appcompat:1.3.1") {
version {
strictly '1.3.1'
}
}
I tried just using implementation 'androidx.appcompat:appcompat:1.3.1', but that wouldn't work either.
Hope this is able to save someone some time, as it took me quite a long time to figure it out!
I had same issue for this.
do not use +
implementation "androidx.appcompat:appcompat:1.4.0-alpha01"
or
implementation "androidx.appcompat:appcompat:+"
Correct way:(lower than 1.4)
implementation "androidx.appcompat:appcompat:1.1.0"
see here: https://github.com/facebook/react-native/issues/31572
update
./gradlew -q app:dependencies > 1.txt
maybe you can see this:
| +--- com.github.AnJiaoDe:TabLayoutNiubility:V1.1.6 | | \--- androidx.appcompat:appcompat:+ -> 1.4.0-alpha01 (*)
3rd lib content a androidx.appcompat:appcompat:+
so you must be:
implementation ('com.github.AnJiaoDe:TabLayoutNiubility:V1.1.6') {
exclude group: 'androidx.appcompat', module: 'appcompat'
}
android/app/build.gradle
paste the following code in dependencies section
implementation ("androidx.appcompat:appcompat:1.3.1") {
version {
strictly '1.3.1'
}
}
Maybe you can update react-native version to 0.68.2.
This worked for me.
Verify Gradle version: 7.0.2
I Solve This Error Simple way.
No.1) create new expo project expo init {yourProjectName}
No.2) Your previous project copy all your create folder and files and copy you will install dependencies command.
No.3) You New Project Paste all folder and files and install all previous dependencies.
Now you run Your Project npm start or yarn start.
I hope your problem solve.
Update: This solution is for those who can't afford to use Appcompat 1.3.1.
Other solutions were not viable for me. Downgrading to appcompat to 1.3.1 is not a good solution. And upgrading to 0.68.2 is also quite an effort.
I instead
forked react-native version that I was on.
made the changes mentioned here
Re-built the ReactAndroid-release.aar by following this
place ReactAndroid-release.aar in android/app/libs
And now you can use Appcompat 1.4.x on any React native version.
Tried on 0.64.3.
I would like to add a plugin system to my Electron application so that my users can add new features to my application. I was originally thinking that I would let my users upload a .zip containing a plugin and then it would extract, and require the plugin to use it within the application. I then ran into problems with the idea.
How should I handle a plugin which has dependencies since I cannot use npm (e.g lodash)?
How can I give the plugin an API to use (e.g getting application theme or resource name)
I am not sure how this could be handled, I've looked around for similar cases but haven't found them. My ultimate goal is to have a system that works in Electron similar to how Wordpress plugins work.
You could use npm as a child process.
You can implement your own:
require('child_process').exec(
'npm ...',
{ maxBuffer: 1024 * 500 },
function (error, stdout, stderr) {
var response = JSON.parse(stdout).dependencies;
...
}
);
or use a library, as an example: https://github.com/getstation/electron-package-manager
I'm currently working on a project in ionic/angular 1. I'm using ionic native to wrap the cordova plugins.
I installed ionic native with bower, and added dependency to 'ionic.native' in my app's angular module. Now I can inject stuff like $cordovaFile into my controllers and use them. This works great.
My problem is using the MediaPlugin. I inject $cordovaMediaPlugin in my controller. Now the documentation ( https://ionicframework.com/docs/v2/native/mediaplugin/ ) says do this:
new MediaPlugin('path/to/file.mp3', onStatusUpdate);
Obviously i cant do this in angular1.
I tried stuff like this:
var media = this.$cordovaMediaPlugin('PATH');
var media = new this.$cordovaMediaPlugin('patch');
nothing seems to work, getting undefined all the time.
How would I make this calls in angular/ionic 1? I really think the 'new' keyword is the issue here...
Try to install ngCordova Media plugin.
Install ngCordova, and inject in your app module 'ngCordova'.
See de following steps
Install plugin
If you want create a service to provide a media resources see (Not required)
I'm using Grunt to build the Durandal starter kit pro package.
It all works fine, except for one tiny detail. I would like to exclude one file (app-config below) from the optimizer and keep it as a non minified file when my build is done.
Based on other SO thread suggestions, I'm currently excluding it using empty:, which removes it from the optimized file as expected. However, when I open the built project I get an error in the console:
Uncaught Error: main missing app-config
options: {
name: '../lib/require/almond-custom',
baseUrl: requireConfig.baseUrl,
mainPath: 'app/main',
paths: mixIn({ }, requireConfig.paths, {
'almond': 'lib/require/almond-custom',
'app-config': 'empty:'
}),
optimize: 'none',
out: 'build/app/main.js',
preserveLicenseComments: false
}
Is almond the problem? I tried switching it to the full requirejs using include: ['path/to/require'], without success.
If you want to reproduce it locally you can either download the starter kit from the above link, or use a slightly configurated version which is closer to my example. Just run an npm install in the folder and you're all set.
I have downloaded you source code and do the following steps.
Extract zip file, open cmd and change the directory to this folder.
Run npm install to install all the dependencies.
Run grunt to start to build the project.
And when I open http://localhost:8999/ and saw the alert 1 which is alert(appConfig.foo); in your main.js.
After clicked Ok to hide the alert, the web page works fines. Any more input for you ?
So I am not sure how you are facing with this issue.
From the reference of the durandal issues found in this particular link
grunt-durandal
The main module controls the implementation of the durandal services
The link can be found in main.js
Here you can see the system.debug(true).You can remove it as written in the post here document.
The function as quoted in the article Overrides request execution timeout making it effectively infinite.
Also while using uglify in grunt the debug is set to false as per the documentation.
As per the documentation you need to set the system.debug(false)
Hope this might help a bit.
try:
....
paths: mixIn({ }, requireConfig.paths, {
'almond': ['lib/require/almond-custom', '!lib/require/almond-custom/app-config.js']
}),
....
just note the second path of app-config.js is correct. I think you should find your way, the above is a hint, if not a direct solution.
My first Phonegap App. Everything working well except for plugins. I'm trying to install the cordova-plugin-purchase Plugin.
https://github.com/j3k0/cordova-plugin-purchase
I've followed the instructions. And when I run "phonegap plugins" in the console it shows the plugin as being installed.
According to the documentation, there is suppose to be a "store" object that I can reference. I set up the following code to test if it's working:
try {
store.register({
id: "my.reverse.item.example",
alias: "example name",
type: store.CONSUMABLE
});
} catch(err) {
alert(err);
}
On my real project, I have the real info in when registering the product, but I can't even get that far. In my TryCatch it returns the following alert:
"Can't find variable: store".
So it seems that the plugin isn't even installed correct. I'm not to phonegap plugins, so there's probably something very basic that I'm missing. Do I have to include a link to the plugin JS in my index.html file?
I ended up figuring out the problem. It seems to be that I didn't include the cordova.js file in my index.html. I don't see why I needed to do that since I've read over and over that you don't need to manually add the cordova files to your html files.
So the plugin works now and I can receive the store data that I setup using the cordova-plugin-purchase plugin tutorials.
Another thing to note once you actually have the plugin installed correctly:
The Bundle Identifier in Xcode needs to match the bundle ID for the In App purchases you are trying to connect to.