I am developing a Cordova plugin that comes with some data files. I need these files to
Be copied to the mobile device, and
Be loaded the files in the runtime.
What I am currently doing is to define these files in plugin.xml as resource files, like:
<resource-file src="assets/data.xml" target="assets/data.xml"/>
However, I do not know how to open these files in my Android Java code. If I use a File class to open the file, what path should I use?
Any help is appreciated.
Since no one has answered this question after a few days, and I have not found a solution elsewhere, I am going to post my own workaround here.
Package all the data files with directory in a zip file.
Put zip file in the Cordova app.
When the app starts up for the 1st time, the app uploads the zip file to the plug-in, using a FileTransfer plug-in.
The plug-in unzips the file in the application's sandbox.
I have to admit that this is not a decent solution. It makes the plug-in depend on the app. However, if there is no better solution, this one just works.
Still, if there is a better solution, please post share it here.
Related
When I googled this question on the Internet, there was none about how to create instead of install. I saw they were just zip files but I do not really know if I can just put everything into a zip and change its file extension to .xapk and it is done. So my question is: Can I simply zip a .apk and a .obb files (build from Unity) to make a .xapk file? Or I need to arrange it with some specific folder structure? Or I can only make it from an Android project in Android Studio?
It seems the answer is NO. It needs an "manifest.json" file, as detailed in Caleb Fenton's blog.
http://calebfenton.github.io/2016/02/28/decompiling-xapk-files/
The question of how to generate the file automatically still eludes me. I haven't been able to find a "xapk creator" or something.
I have opened .apk archive file which shows me the following file:
Androidmanifest.xml
resource.ars
META-INF folder
RES folder
I am not able to get classes.dex. It shows me in zip folder but when I extract it classes.dex disappear after extraction.
No idea how that happened to you, but you can decompile the apk directly into Java source code using a tool called JADX. Just search it for your platform in Google.
I got the solution of my question and posting answer so may be helpful to someone.
Android .apk file which I was using was malware sample. My Antivirus was not allowing extraction of classes.dex, so it was removed by Antivirus automatically after few seconds.
I am trying to link to an external file from a shared repository between my iOS and Android apps. This does not present a problem for iOS, but it does for Android. My current solution is to create a copy of the file from the external repository and place it in my projects Assets folder. This solution works, but is not much of a good one in my opinion and involves too many extra steps.
Using Eclipse, I am able to link to a resource. It's as simple as copying a file into my Assets folder and being prompted to either copy the file or link to the resource. If I link to the resource and try to run my app, I get a FileNotFoundException. If I copy the file instead, the app file is found just fine.
Ideally, I'd like to link to the file so that when I pull a new update from git then I don't need to copy the file over every single time. I'd prefer to link to the file.
I don't know what Eclipse uses "under the covers" for "Link here" drag-and-drop stuff. However, it is an Eclipse-ism. Android's build tools are fairly isolated from Eclipse proper, and so they won't know about those links.
Using a hardlink, or perhaps a symlink, at the OS X filesystem level should work, as both Eclipse and Android's build tools should treat it like a local file.
Ive tried many zip pluggin but none of them has a password parameter. Do you know any cordova plugin that can unzip a password portected .zip Format?
The popular cordova-plugin-zip rely on ZipInputStream to unzip files, but this class do not support decrypting password-protected Zip files.
An alternative java decrypting library called zip4j exists, but isn't clear if it's compatible with Android. An Android porting of zip4j is available, but isn't present on maven repository so you should add it manually to your project.
Moreover, seems that somebody has written his custom java class to decrypt zip files.
Following the source code of the cordova zip plugin for Android, will be very easy for you to write your custom unzip plugin (and I hope that you'll publish it!).
Edit: see also these interesting answers to a similar question.
How can connect with SQLLite from Android using Unit3D and Javascript?
Someone can'i help me?
Here are the specific steps to getting SQLite set up in your project.
Download SQLite - you'll want the ZIP file with the DLL inside
that's in the Precompiled Binaries for Windows section.
Important Copy sqlite3.dll into your into your project's Plugins folder (make a folder called Plugins if you don't have one).
You won't get a warning if you don't do this, and your project will run fine in the editor, however, it will fail to work when you actually build your project, and will only provide information about this in the log file.
This will give you a License Error if you're using Unity Indie, but it doesn't seem to have an effect on the actual play in the editor, nor does it seem to effect the ability to build stand-alone versions.
Alternately, you can leave it out of your project entirely, but when you build your application, you'll need to include a copy of sqlite3.dll in the same directory as the .exe in order for it to work.
In your project, add in the dbAccess.js file: http://wiki.unity3d.com/index.php/SQLite#dbAccess.js
You should be good to go!
Source (and the above is pretty much copied word-for-word from):
http://wiki.unity3d.com/index.php/SQLite