Cordova spatialite database for android not working - android

I am am trying to use spatialite plugin from
https://github.com/DisyInformationssysteme/Cordova-spatialite-storage
for my cordova application,
but the problem is that when i try to create database it shows me
Database open failed, aborting any pending transaction.
I dig a lot for alternative solution for using spatial feature, but unfortunately couldn't succeed.

We had the same problem but it looks like we managed to find a workaround. It seems that Cordova-spatialite-storage plugin has some issues with opening/creating a database if database does not already exist. If database exists, you should be fine but only if you also added cordova-plugin-file plugin.
Try these steps:
copy existing spatialite database to device (e.g. file:///storage/emulated/0/Download/database.sqlite - just for the sake of testing, later you should move it to more appropriate location)
add cordova-plugin-file plugin
check if cordova-plugin-compat plugin is also added
add cordova-spatialite-storage plugin
Try to open database with name: 'file:///storage/emulated/0/Download/database.sqlite' and run some spatial queries. It should work.
Please let me know how it went.

Related

AndroidManifest gets updated after prepare Cordova, missing lines

Have someone encountered problem when after prepare some data removes from AndroidManifest?
I add platform with android, when I prepare android platform, some values get lost from the AndroidManifest.
If i delete android.json and make prepare againg, it pulls the correct values.
Have someone been in touch with problem like this?
I have not seen such issue myself, but I would check installed plugin's plugin.xml files for 'after_platform_add' or 'before _platform_add' hooks scripts. and if one of the plugins is not altering AndroidManifest file in wrong way after/before platform add.

How to download a file from FTP and store it locally with Cordova?

I'm struggling for some days to do that. Without success.
I've found two ways that I think reasonably to follow:
1: Plugin cordova-sftp-plugin.
I see that it is writted to deal with 'secure ftp', but why wouldn't work in an ordinary non secure ftp? Nothing was metioned about it.
I've tried so, applying the 'Use Example' from the official page, the code fells in the success callback function, but when I list the local directory, nothing was changed! It gives me no clue about what goes wrong! In true, the software does not detect nothing wrong.
Before the previous steps, I did not forget to precautionally install and enable the 'cordova-plugin-file', 'cordova-plugin-file-transfer' and 'cordova-plugin-network-information' and to add the <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> in the AndroidManifest.xml. Tryied to save files in cordova.file.externalRootDirectory and cordova.file.externalRootDirectory + "/Downloads/. Nothing worked.
2. The macdonst FtpClient plugin.
Searching for my issue, one of the first pages that appears is How to ftp a file over to a server from PhoneGap/webapp?, and beyond some further search I've found another one in a relatively old post mentioned the successful use this plugin in a Cordova application. So I can consider this plugin as a stable choice.
The problem with this method comes earlier: I coundn't even build the application after a manual installation proccess. May it is a problem in the manual installation proccess.
The official plugin documentation teachs to install it in a PhoneGap application, and not a Cordova. The steps was not replicable to Cordova, due to some differences in paths and configuration, and some others links also supports the plugin installation solely in Phonegap, not Cordova.
I also tryied follow the steps in the http://antonylees.blogspot.com.br/2015/01/how-to-manually-add-cordova-plugins-to.html and Manually install Device plugin (and others) into cordova 3.0 to manually add the plugin. The steps in the first link also was not well replicable, and although the second one are more straitfoward, also does not solved the issue.
Building it gives me a java error compilation. The first error output (what uses to cause all the following errors are):
E:\danilo\Documentos\projetos_cordova\ftpDownload3\platforms\android\src\com\phonegap\plugins\ftpclient\FtpClient.java:27:
error: package org.apache.cordova.api does not exist
import org.apache.cordova.api.CallbackContext;
Very strange. May I have to search for the org.apache.cordova.api jar file and put in the lib folder? Also, I did not forget to put the commons-net-2.2.jar in the project libs folder.
Can anyone have some suggestion to succeed this? I just want to download a file through ftp protocol and save locally and so, if there's an alternative method to succeed, it will be appreciated too.
Thanks in advance.

which urls need to be accessible for android developemnt

I am working behind a strict proxy and struggling with identification of URLs which need to be accessible for android developement.
I know for SDK updates https://dl-ssl.google.com/ should be accessible.
I need answer to following queries:
What are the URLs for resolving dependencies using gradle also for updating gradle itself?
Are there any additional urls apart from sdk update and gradel dependencies which need to be accssible?
After a quick search,I also found below urls-
http://download.gradle.com
http://services.gradle.com
https://repo1.maven.org/maven2/
https://jcenter.bintray.com/
http://repo.jfrog.org
May be these will work.
This link provides with requirement for usage of gradle in android studio. with this following are answers to queries:
Following are the urls need to be accessible for basic gradle functionality:
https://repo1.maven.org/maven2/
https://jcenter.bintray.com/
Apart from these any URL required for access of custom libraries hosted on other then default location.
Getting exceptional access from network admin team for said URLs will solve the problem
if your'e running gradle behind a proxy. try adding the proxy settings to your gradle.properties file e.g.
systemProp.http.proxyUser=myusername
systemProp.http.proxyPort=yourport
systemProp.http.proxyPassword=proxypasswordhere
systemProp.http.proxyHost=proxy url/ip here

How to get owner's name / email using phonegap build

I am running a phonegap build application version 3.4.0.
Phonegap build has a list of plugins https://build.phonegap.com/plugins where you can find a lot of them for example to send mails, etc.
But i can't see a plugin that retrieve the account information for android devices like the email or name of the owner.
To add a plugin you have a config.xml file in wich you add a line like this:
<gap:plugin name="com.jcjee.plugins.emailcomposer" version="1.4.6" />
My problem is that i found a plugin that seems to be useful: https://github.com/seltzlab/AccountList-Phonegap-Android-Plugin but i cannot find a way to include it on phonegap build compilation.
I can see that you can create a custom public plugin http://docs.build.phonegap.com/en_US/developer_contributing_plugins.md.html but i don't need that, i only need to use one, wich is already created.
Is there any way to achieve this?
Thanks in advance.

PhoneGap Downloader plugin in Android

I am new to Phonegap and I am currently developing an android app using jquery mobile and Phonegap.
I googled a lot on how to use the downloader plugin and how to call it in your Html file which contains the link of the file you want to download with the downloader plugin but couldn't find any working example.
Can anyone here please provide me with a simple working demo of the PhoneGap downloader plugin so that I will get relevant information on how to use it. Or help me in implementing the plugin and calling it on the specific url.
Thanks in advance. :)
I've used a downloader plugin quite a long time ago with phonegap 2.2 and it was quite easy to use.
Is this the plugin you are trying to use? or maybe this one?
The fist one seems to have been updated for the phonegap 2.7+ format so maybe usable in a phonegap 3 project, except that you won't be able to install using the CLI and will have to had the plugin manually in platform/android or you could write a plugin.xml yourself.
To use it, you just have to follow the instructions in the readme.md or read the original article in http://www.toforge.com/2011/02/phonegap-android-plugin-for-download-files-from-url-on-sd-card/
Again I haven't tried to use it in recent versions of phonegap and am not sure if the plugin should be updated to be compatible.
Edit:
For each file you have to call:
window.plugins.downloader.downloadFile("http://server/file.txt", {overwrite: true},
function(res) {
//function called when the file is downloaded
//the file content is in res
}, function(error) {
//function called in case of error
}
);
if you need to download several files, you could download the next file in the function called in case of success.

Categories

Resources