PhoneGap plugins won't load - android

I'm trying to build a PhoneGap app for android. I need to use the Sqlite plugin.
According to PhoneGap documentation I need to declare the plugins in config.xml and I'll be good to go but I'm not. It just won't work.
I'm using the Sqlite plugin this way:
window.db = window.sqlitePlugin.openDatabase({name: "my_db"});
The sqlitePlugin is undefined. I'm using the following plugins as well, so if anything's worth noting, please share them with me.
<gap:plugin name="com.phonegap.plugins.sqlite" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.dialogs" />
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.media" />
<gap:plugin name="org.apache.cordova.vibration" />
Edit: One important question. Do I need to include the plugins js file in my index.html using the script tag?

The line I see for sqlite plugin in the phonegap build plugins repository is
<gap:plugin name="ch.zhaw.sqlite" version="2.0.0" />
Does it work better if you replace the line in config.xml?

Related

plugin unsupported: sqliteplugin

I am trying to build an offline app using cordova, I am using the sqlite plugin for storage. In my config.xml file i have added an entry, but when i build apk i am getting the error Error - The following plugin, plugin version or a dependancy of this plugin is not on npm: SQLitePlugin
how can i resolve this?
here is my config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.plusminus.example"
versionCode = "10"
version = "1.0.0" >
<preference name="orientation" value="portrait" />
<name>DAPP</name>
<gap:plugin name="org.apache.cordova.camera" source="npm" />
<gap:plugin name="org.apache.cordova.device" source="npm" />
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
<gap:plugin name="SQLitePlugin" value="io.liteglue.SQLitePlugin"/>
<author href="https://build.phonegap.com" email="aadd#xxxxxx.com">
xxxxxxxx
</author>
<icon src="/lib/images/AppIcon.png" />
<gap:platform name="android" />
<access origin="*" />
</widget>
I think you have to installed sqlite plugin via CLI.
Installed plugin by Just Open command prompt and go to your project path and install plugin using CLI
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git
For more helps to check here & If you want add the customized plugin used plugman for that please look to here..
Hopes this will help you !!.

Cordova not copying appropriate icon and splash, using default, Android only

My app keeps using the default cordova icon and splash screen. Upon digging, what should happen is all of my icon/splash get copies to platforms/android/res/. When I look in there, it's just the default cordova ones. However, in my resources/android/ all of my custom ones are there.
Working fine for iOS, not fine for Android at. I am running Cordova CLI 6.4.0.
I have all the custom icons and splash images setup in correct directory structure, and receive no errors during platform add or build android
Below is my config.xml
<platform name="android">
<allow-intent href="market:*" />
<icon platform="android" src="resources/icon.png" />
<icon platform="android" qualifier="ldpi" src="resources/icons/android/icon-36-ldpi.png" />
<icon platform="android" qualifier="mdpi" src="resources/icons/android/icon-48-mdpi.png" />
<icon platform="android" qualifier="hdpi" src="resources/icons/android/icon-72-hdpi.png" />
<icon platform="android" qualifier="xhdpi" src="resources/icons/android/icon-96-xhdpi.png" />
<icon platform="android" qualifier="xxhdpi" src="resources/icons/android/icon-144-xxhdpi.png" />
<icon platform="android" qualifier="xxxhdpi" src="resources/icons/android/icon-192-xxxhdpi.png" />
<splash platform="android" src="resources/splash.png" />
<splash platform="android" qualifier="ldpi" src="resources/screens/android/screen-ldpi-portrait.png" />
<splash platform="android" qualifier="mdpi" src="resources/screens/android/screen-mdpi-portrait.png" />
<splash platform="android" qualifier="hdpi" src="resources/screens/android/screen-hdpi-portrait.png" />
<splash platform="android" qualifier="xhdpi" src="resources/screens/android/screen-xhdpi-portrait.png" />
</platform>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="2000" />
<preference name="FadeSplashScreen" value="false" />
<preference name="FadeSplashScreenDuration" value="0" />
<preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF" />
Same exact exact setup for iOS, and works perfectly there
I've triple checked the paths and everything is correct, and my custom icons are indeed in the indicated locations, but simply not copied over during build
I've tried several times to remove and add android platform, then build, same with cordova-plugin-splashscreen
Both the icon and the splash screen are not working on Android
And here's a screencap showing the folder layout, and the unfortunately incorrect images.
Update made some progress but not quite there. I replaced "qualifier" with "density" in my config.xml. Now what it does it create a correct looking "res" folder, but it puts it in the root of my project instead of platforms/android. It also creates platforms/android/res but all of the images in there are the default Cordova ones. If I move the new folder /res (my custom icons) into /platforms/android (default cordova icons) before build then the app shows my correct stuff. I guess it's a working workaround but an annoying one... and to note; I delete the /res folder but cordova platform add android builds it, just seems to create it in the wrong directory.
This is an issue in cordova-android solved in the version 6.1.0.
The recommended steps are:
cordova platform update android#6.1.0 --save
cordova platform rm android
cordova platform add android
Source: https://github.com/apache/cordova-android/pull/343
I have the same problem, If you find a solution tell me please :)
EDIT
I Solved updgrading my version of android
cordova platform update android#6.1.0
I had this problem some time before and I, and found two ways to pass over.
Upgrade Cordova Platform: This is the recomended, I believe that you upgrade to Cordova 6.4.x but not your Platform, please try: cordova platform update android#latest
OR
Downgrade Cordova CLI: Sometimes, the prev step does not work, so you have to do something that is disrecomended, downgrade cordova to work npm install -g cordova#6.3.1 (Note => CLI 6.3.1 is just the version I believe could work)

Android - Scheduling Local Notifications on PhoneGap Build / Apache Cordova 4.1.1

I'm having issues trying to schedule local notifications on an Android app (using PhoneGap build).
I'm trying to schedule a local notification at a set date and time (e.g. September 23rd 2016 at 12:00pm).
I've tried using the following plugin:
https://build.phonegap.com/plugins/2081
My config.xml file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id = "****"
versionCode = "292000"
version = "2.9.2" >
<gap:config-file platform="android" parent="/manifest">
<application android:debuggable="true" />
</gap:config-file>
<!-- versionCode is optional and Android only -->
<name>****</name>
<description>
****
</description>
<author href="****" email="****">
****
</author>
<icon src="icon.png" />
<allow-navigation href="*" />
<access origin="*" />
<preference name="phonegap-version" value="cli-5.2.0" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value="23"/>
<gap:plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.1" source="pgb" />
</widget>
I then schedule the notification using the code below:
cordova.plugins.notification.local.schedule({
title: $title,
text: $message,
at: $date
});
When building for the latest PhoneGap version (cli-6.3.0), I get the following error on the build.phonegap.com site:
Error - Some official plugins have to be updated if using PhoneGap >= 4.0.0. Please upgrade the version of any plugins that may include the following file: LocalNotification.java
It seems that the plugin has not been updated for the latest version of PhoneGap causing the build to fail.
I've tried building for the latest supported version of the plugin (PhoneGap 3.7.0). The build completes successfully and when installed directly on an Android device, everything works correctly. The notifications fire as scheduled.
However, when trying to submit this build to the Google Play store, the build is rejected with the following error:
Your APK has been rejected for containing security vulnerabilities, which violates the Malicious Behavior policy. The Alerts page has more information about how to resolve the issue. If you submitted an update, the previous version of your app is still live on Google Play.
The build now needs to use v4.1.1 of Apache Cordova to be accepted by the Google Play .
I've looked around but can't find a solution anywhere. Is anyone aware of a fix, or alternatively, a different plugin that allows scheduling of local notifications on Android supporting Apache Cordova v4.1.1 or above?
Change
<gap:plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.1" source="pgb" />
to
<plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.4" source="npm" />
I have fixed myself.
Changing the plugin name will work.
We need to find an appropriate plugin and replace older version in config.xml.
In my case, I have changed
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.4" source="pgb" />
to
<gap:plugin name="trunk.plugin.local-notification" />

How to set permissions for Android using Phonegap Build?

I tried other solutions around here but no matter what I do the same permissions are asked during install of my app.
I tried removing a bunch of the "plugins" phonegap uses, namely: (from the config.xml)
<gap:plugin name="org.apache.cordova.battery-status"/>
<gap:plugin name="org.apache.cordova.camera"/>
<gap:plugin name="org.apache.cordova.media-capture"/>
<gap:plugin name="org.apache.cordova.contacts"/>
<gap:plugin name="org.apache.cordova.geolocation"/>
<gap:plugin name="org.apache.cordova.globalization"/>
Yet when I update my code and then try to install the apps it still asks for stuff like location.
Anyone who knows this?
It isn't the plugins that declare the permissions. The permissions are declared with feature elements like
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/device"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/network"/>

Phonegap Android InAppBrowser not working

I am working on an Android App with Phonegap Cordova-3.0.0 and when I call InAppBrowser I got MotionEvent mTouchMode = 4 error. And InAppBrowser function is not working. So how can I fix this? Do I need do some setting on AndroidManifest.xml or config.xml?
And I got this on my AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
And I got this on my config.xml
<plugins>
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
</plugins>
In Phonegap Cordova-3.0.0 version, for the app to communicate closely with various device-level features, we need to add plugins that provide access to core Cordova APIs.
The cordova plugin add command requires you to specify the repository for the plugin code.
For example, In-app browser:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
we need run this in command line. Don't need worries about AndroidManifest.xml or config.xml files. After you run $ cordova build, it will auto write for you.
You could get more idea about it in doc.phonegap
Add following code in config.xml this works fine for mi.
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
<access origin="*" browserOnly="true"/>
You have to mention the below code line in config.xml
<plugin name="InAppBrowser" value="CDVInAppBrowser" />
try to add this to your manifest, it helps me with a f*king plugin to work
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
try also not use 'plugin' tag in config.xml, but:
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
</feature>
it will help for future updates of phonegap
To open a link in browser inside the app without opening external browser
HTML
<input type="button" id="button1" value = "click here"
onclick="window.open('https://example.com','_blank','location=yes','closebuttoncaption = Return');">
Now go into your project folder and open Terminal or Command Prompt (Windows) and type the following command:
cordova plugin add cordova-plugin-inappbrowser --save
It will configure the required files and also add the plugin into your config.xml file.
Open your HTML page where you're trying to open the link, and put this JavaScript.
<script src="cordova.js"></script>
<script type = "text/javascript" charset = "utf-8">
function onLoad(){
document.addEventlistner("deviceready", OnDeviceReady, false);
}
function onDeviceReady(){
}
</script>

Categories

Resources