Read Android Expansion File - PhoneGap Build - android

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" />

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.

Unity3D Command line Build not accessing libraries and updating Android Manifest

I have a unity project with multiple android plugins.
The plugins are placed in the recommended folders /Assets/Plugins/Android/NameOfPlugin and each have their own AndroidManifest.xml and .project file.
I also have an AndroidManifest.xml in /Assets/Plugins/Android
When building out a .apk from any of the dev machines in studio, the AndroidManifest is correctly compiled into a single .xml file containing all required activities.
However, when building on a Mac Mini via commandline this does not happen. The AndroidManifest.xml is missing required code and the app doesn't work.
I have done fresh installs of everything, tried different configurations, loads of things but to no avail. Anyone have any ideas as to what might be going wrong?
One of Dan's colleagues here, and after doing a straight up text diff on the two "Editor.log" files of Unity's editor, there was one glaring line that was missing from the broken builder,
DisplayProgressbar: Android Library Support
Googling that lead me to http://answers.unity3d.com/questions/792979/android-library-support-build-issue.html who had already discovered the answer, which was damn near exactly the same as what we had suffered,
It appears having a "." in the name of a directory on the build path results in failure of the android-libraries to be correctly found and added to the StagingArea.
Moving our repository on the Autobuilder from ~/.jenkins/workspace/game_project to ~/game_project fixed the issue.
We've just done the same ourselves, and it's solved the issue.

Cordova android class not found

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.

What is resources.ap_ and why does it have a penchant for not existing?

Every once in a while a borked Eclipse build gets nailed down to the absence of this file, with the simple fix of cleaning the build, or occasionally doing a deeper clean on the project's metadata. I can live with this state of affairs, but the curious side of me has to ask why.
A search for it on developer.android.com turns up nothing :(, and a search on Google turns up various threads by folks wondering why their build is broken.
This guy is the closest thing I've found to an explanation of the thing itself. Hopefully some nice, patient guru can shed some light on the fundamentals here without this noob digging too far into the source :)
The resource.ap_ is all the resources for you file zipped up. Everything from the res, assets folders and the Manifest file.
The apk file added in the class.dex (all your compiled code) and any linked .so (native code).
Both of these files are in .zip format. They can easily be view by changing the extension to .zip and opening them.
The .ap_ file is probably your apk before it is signed with your certificate (by default, a debug certificate generated by ADT in your home directory.)
here is a picture which may give you the answer.

Categories

Resources