I'm trying to add a cordova plugin to a salesforce mobile android app. By default, the salesforce app uses the SalesforceSDK project as a library. This project already contains several cordova plugins listed in its config.xml file, however, when I try to add a plugin and config.xml file to my own project in the same way, cordova fails to initialise, citing 'Class not found' as the reason.
I've looked around to see what the structure should look like then to make it find the class, but every result I find shows a different way of setting up the config file, or adding a plugin.xml file somewhere, and nothing has worked so far because I just can't figure out how to do it properly.
Currently I only have
<?xml version="1.0" encoding="utf-8"?>
<plugins>
<plugin name="OpenAppPlugin" value="com.dev.testapp.OpenAppPlugin"/>
</plugins>
in my config file, because all the cordova guide says is to add that line.
Turns out, I had to copy the entire config.xml containing all the plugins to my own project and add the line to that.
Related
I'm building an app which name starts with a number "100 Times". But when I try to add the Android platform:
ionic cordova platform add android
I get the following error:
CordovaError: Error validating project name. Project name must not begin with a number
My config.xml is like:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.times100" ...>
<name>100 Times</name>
...
</widget>
As far as I know it is not a Google Play restriction, cause there are a lot of apps with names that starts with numbers.
How can I use an application name that starts with a number with Cordova?
I was able to use numbers at beginning of my app name following the steps below:
Create the android studio project running "cordova prepare android"
Open the Android Studio Project and edit "res/values/strings.xml"
Replace the "app_name" node content with the name you want.
Build the APK using Android Studio.
That's a cordova bug. There is an issue for that:
https://github.com/apache/cordova-android/issues/584
There's also a pull request to fix it in version 9.x of cordova-android:
https://github.com/apache/cordova-android/pull/859
For now the only way is to use some (hackish) workaround to fix that.
I generate the apk in a CI environment using docker containers, so executing commands manually in Android Studio was out of question in my case, so I forked the cordova-android repo, commented the lines that does that unnecessary (and wrong) validation and installed the android plugin in my project from the forked github repo.
I would like a way to access my expansion file in Cordova.
The issue is that the plugin I've heard most people recommend;
https://github.com/agamemnus/cordova-plugin-xapkreader
requires a bit more effort to get it working, namely modifying boilerplate Cordova files. I don't get to see or access these files with PhoneGap Build as it generates and compiles these files, along with my www files, into an apk in one go.
Is there a way to get this plugin working with PhoneGap Build, and if not, is there an alternative that I could perhaps use?
I eventually figured it out. I'll leave the answer here for anyone that may have a the same problem I did.
So this plugin: https://github.com/agamemnus/cordova-plugin-xapkreader
Works just fine with Phonegap Build. The issue was actually with the methods I was trying to use in setting it up correctly. The correct steps to take are as follows:
In your root/config.xml file, add the following:
<plugin name="com.flyingsoftgames.xapkeader" spec="https://github.com/agamemnus/cordova-plugin-xapkreader.git#cordova-6.5.0">
<variable name="XAPK_EXPANSION_AUTHORITY" value="YOUR_APP_NAME" />
<variable name="XAPK_PUBLIC_KEY" value="YOUR_GOOGLE_KEY"/>
</plugin>
Wherever you want a file to access the apk expansion file, use the following syntax:
content://YOUR_APP_NAME/path/to/file.jpg
This is fairly clear about it in the documentation, but it's worth noting that you set the path correctly. A lot of tutorials online will have you write something like:
content://YOUR_APP_NAME/main_expansion/path/to/file.jpg
This made me believe that the main_expansion portion of the path was a syntax meant for the plugin to access the main expansion file and not the patch expansion file, but this is resolved by the plugin as it prefers files in the patch to the main automatically.
The main_expansion portion is there because that's the file path that the tutorials online created. So their actual file path would be
main_expansion/images/funny_image.jpg
whereas mine was something like
audio_files/dialog/hello.mp3
It sounds so simple but this caused me an unnecessary amount of trouble.
Also, it's worth noting that it didn't work when I was using Cordova cli 6.2.0, but worked when I upgraded to 6.5.0. This is done in your root/config.xml file:
<preference name="phonegap-version" value="cli-6.5.0" />
I am working on a Visual Studio Cordova project which works on Windows, iOS and Android, and looking for AndroidManifest.xml or a build settings file and couldn't find any. I tried building it with no errors, but still couldn't find the file. Any suggestions, where/what I should be looking for?
It should be in your project root inside platforms/android.
Cordova generates a AndroidManifest.xml in platforms/android, but it's going to be reseted with each rebuild. If you need to add some data to it, you will have to create your own AndroidManifest.xml in res/native/android that will be automatically merged to the one in platforms/android.
You can read (a bit) more in the official documentation: https://msdn.microsoft.com/en-us/library/Dn757053.aspx
I'm trying to integrate push notifications using the pushwoosh plugin. I installed the plugin using the command line:
phonegap plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin.git
and in config.xml:
<access origin="*.pushwoosh.com" />
and added the javascript code for initPushwoosh() and the rest of the code.
Then when I build the app successfully
I found that pushwoosh plugin and some code from config.xml is removed automatically.
The push notification also does not work.
What am I missing?
Make sure you are editing the files in the correct "www" folder. There could be more than one "www" folders and one could override another when you make a 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.