Cordova 3.3.x - Android CordovaLib - android

When was the cordova.jar file removed from Cordova and replaced with CordovaLib? I was previously running Cordova 3.1.0-0.1.0.
Today I have upgraded to Cordova 3.3.0 (which was quite a headache, but I've completed the upgrade) and I've noticed a difference in my Android project structure: Cordova has created my project (with what I've named it) and it has also created -CordovaLibs.
Is this right? I know iOS it does this - but not Android (as I say, usually a JAR is added).

It's introduced in 3.3, had me baffled too.
Cordova 3.3 release notes:
http://cordova.apache.org/announcements/2013/12/16/cordova-330.html
CB-5232 Change create script to use Cordova as a Library Project
instead of a .jar

To generate file cordova3.3.0.jar, just follow these steps bellow:
Open your cmd, and go to the root folder where Cordova is installed:
$ cd ~/.cordova/lib/android/cordova/3.3.0/framework
Run the following command, notice the trailing dot
$ android update project -p .
Use ant to generate file jar. Be sure you have configure PATH for
$ ant jar
Now, you can copy file cordova3.3.0.jar to libs directory and import to your project. Hope it's helpful

Related

How to launch a Cordova project with full rebuilding of plugins?

I'm working on a Cordova plugin. As a plugin can't be executed, I'm using a Cordova project to test it. I found that running a Cordova project will not reimport and rebuild plugins, so currently I'm doing this:
rmdir \"./plugins/my-plugin\" /q /s
cordova platform remove android
cordova platform add android
cordova run android --device
Did I miss something or Cordova really doesn't have a command to fully rebuild everything before running the project?
Unfortunately, cordova will check your plugins folder only when adding or updating a plugin or platform. Then it will build and copy the needed plugin(s) into the designated OS in the platforms folder.
By your script I assume the source of the plugin is outside of the project folder. So the script you're using should do the work. But if I may give you a better solution would be as follows:
Create a Symlink/shortcut of the source folder for your plugin into the plugins folder, so you'll not need to remove the folder and stress the disk into copying files everytime you want to run the update.
Your "update" script should delete only the installed plugin folder at platforms/android/platform_www/plugins/my-plugin and it'll make the update far more quickier than removing and adding the platform again.

How do I build a Cordova 8.x cordova.jar to include in existing Android app?

I this documentation:
Cordova documentation
I cloned the latest Cordova here: https://github.com/apache/cordova-android
But when I run "ant jar" as described in the documentation, I get this error:
cordova-android-master/framework/build.xml:124: Cannot find
/Users/neigaard/Library/Android/sdk/tools/ant/build.xml imported from
/Users/me/cordova-android-master/framework/build.xml
Google say that is because ant/build.xml was removed from Android SDK. I found a post saying that I should download a old Android SDK tools and replace my SDK tools folder with that, but I rely on my Android SDK to be working and up to date.
Is there no way to build the Cordova Android jar without an outdated Android SDK or is there somewhere I can download a pre-built jar or is there another way to integrate Cordova into a existing Android app?
You don't really need the .jar anymore, Cordova is distributed through gradle, so you can just add this in the dependencies section of your app gradle file:
implementation 'org.apache.cordova:framework:7.1.0'
Tutorial cordova.apache.org/docs/en/latest/guide/platforms/android/… looks outdated. If you just want to embed a cordova webview you don't really need the .jar anymore, Cordova is distributed through gradle, so you can just add this in the dependencies section of your app gradle file:
implementation 'org.apache.cordova:framework:7.1.0'
However if you want to create jar through ant then you don't required to use complete outdated Android SDK.You have to just place ant/build.xml in tools folder.
Below are the steps to create corodva.x.x.x.jar on Windows
Step-1 Download Android tool package from below location:
https://dl.google.com/android/repository/tools_r25.2.5-windows.zip
Step-2 Copy ant folder to
C:\Users\xxxx\AppData\Local\Android\sdk\tools
Step-3 Install Cordova using npm
npm install -g cordova
You can install specific version of cordova using cordova#version.
Step-4 Go to below location and copy your local.properties from your android project:
C:\Users\xxxxx\.cordova\lib\npm_cache\cordova-android\x.x.xx\package\framework
Step-5 Navigate to the Android package's /framework directory and run ant jar.
It creates the Cordova .jar file, formed as /framework/cordova-x.x.x.jar
FYI: It is recommended to refer the cordova requirements-and-support https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#requirements-and-support

Cordova android platform installation fails with error : Error during processing of action! Attempting to revert

We have automated scripts for installing the cordova plugins and installing all the cordova platforms and finally to build the binaries. The setup used for from long time. From today the builds started failing while installing the android platform with error Error during processing of action! Attempting to revert....
Log :
Creating android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.diona.mobility.clientApplication
Name: Client Application
Android target: android-19
Copying template files...
Running: android update project --subprojects --path "platforms\android" --target android-19 --library "CordovaLib"
Resolved location of library project to: E:\Products\Worksapce\dimas\build\clients\ClientApplication\full\cordova\platforms\android\CordovaLib
Updated and renamed default.properties to project.properties
Updated local.properties
No project name specified, using Activity name 'ClientApplication'.
If you wish to change it, edit the first line of build.xml.
Added file E:\Products\Worksapce\dimas\build\clients\ClientApplication\full\cordova\platforms\android\build.xml
Added file E:\Products\Worksapce\dimas\build\clients\ClientApplication\full\cordova\platforms\android\proguard-project.txt
Updated project.properties
Updated local.properties
No project name specified, using project folder name 'CordovaLib'.
If you wish to change it, edit the first line of build.xml.
Added file E:\Products\Worksapce\dimas\build\clients\ClientApplication\full\cordova\platforms\android\CordovaLib\build.xml
Added file E:\Products\Worksapce\dimas\build\clients\ClientApplication\full\cordova\platforms\android\CordovaLib\proguard-project.txt
Project successfully created.
Installing "com.phonegap.plugin.mobile-accessibility" for android
Fetching plugin "https://github.com/apache/cordova-plugin-device.git" via git clone
Installing "cordova-plugin-device" for android
Fetching plugin "https://github.com/apache/cordova-plugin-network-information.git" via git clone
Installing "cordova-plugin-network-information" for android
Installing "com.pushwoosh.plugins.pushwoosh" for android
Installing "de.appplant.cordova.plugin.email-composer" for android
Installing "de.appplant.cordova.plugin.local-notification" for android
Error during processing of action! Attempting to revert...
Is anyone aware of this error? Thanks in advance.
i think there is something wrong with the cordova Plugins. Like it is described in this Post: Broken BarcodeScanner Plugin i would say that the issue is about sth. with the Plugins.
You say that all worked fine for weeks, so i wouldn't worry about your script. The solution which worked for the other user was to copy the plugin from gitHub and install it from the local path.
git clone https://github.com/pathtoplugin.git
cd to your Cordova project.
Cordova plugin add InsertPath\BarcodeScanner
After wasting few hours found that this build failures are because of dependency changes in latest com.phonegap.plugin.mobile-accessibility plugin. Removing this plugin resolved the error(Had no other option as there is no previous tagged working version for the same plugin).

Can't find cordova.jar file in phonegap?

I am new to phonegap the tutorials I have referred to says that there should be a cordova.jar file inside the phonegap-2.9.1\lib\android path. But I don't have it in this phonegap 2.9.1 version.
Can I download the cordova.jar from anywhere or is there any alternative?
Someone please help me.
Thanks.
First, you need the following requisites, for sure are covered if you have been playing with phonegap/cordova for a while ;)
Java JDK 1.5 or greater
Apache ANT 1.8.0 or greater
Android SDK http://developer.android.com
And then, to generate the cordova-2.9.1.jar file, follow the next steps:
Download and extract the phonegap-2.9.1.zip file.
In a terminal/cmd window go inside the recently extracted directory:
$ cd phonegap-2.9.1\lib\android\framework\
Execute the following commands (you need android sdk and ant already configured in your system path):
$ android update project -p . -t android-17
If required add the --subprojects parameter:
$ android update project -p . -t android-17 --subprojects
You get a message like this:
Updated project.properties
Updated local.properties
build.xml: Found version-tag: custom. File will not be updated.
Updated file D:\work_NEW\phonegap-2.9.1\lib\android\framework\proguard-project.txt
Updated and renamed default.properties to project.properties
Updated local.properties
No project name specified, using Activity name 'DroidGap'.
If you wish to change it, edit the first line of build.xml.
Added file D:\work_NEW\phonegap-2.9.1\lib\android\framework\bin\build.xml
Added file D:\work_NEW\phonegap-2.9.1\lib\android\framework\bin\proguard-project.txt
Finally run:
$ ant jar
Blablabla....
jar:
[jar] Building jar: xxx\phonegap-2.9.1\lib\android\framework\ cordova-2.9.1.jar
BUILD SUCCESSFUL
Total time: 4 seconds
Done!!!!! The file is ready! And you can find this and other information reading a file inside the phonegap-2.9.1.zip:
phonegap-2.9.1\lib\android\README.md
Since 3.x version phonegap has changed a lot. I suggest you to install 3.3 version and create a proyect following the steps described in the offical page.
Also, you can download cordova from cordova web page, add to path, and create a proyect using terminal:
cordova create app_name
cordova platform add android || cordova build android
In 3.3.0 version, You can get cordova-3.3.0.jar file by following these steps:
Go to Command Prompt:
$ cd %HOMEPATH%/.cordova/lib/android/cordova/3.3.0/framework
$ android update project -p
$ ant jar
After executing these commands you will get cordova-3.3.0.jar in framework folder i.e.
=> %HOMEPATH%/.cordova/lib/android/cordova/3.3.0/framework/cordova-3.3.0.jar

Upgraded to Phonegap3, project does not load needed plugins correctly

So I've tried posting some of these issues on the Phonegap forum but have not heard from anyone regarding my issues...
I recently upgraded from PG 2.9 to 3.3 and am having trouble adjusting my project to the change... it should be as easy as installing phonegap 3.3 and creating a new project and dragging my /www to the root of the project and calling the cordova CLI commands to build and update my project-- both of which say that they complete successfully.
But it's not that easy! Instead, building and updating my project deletes the cordova2.9.jar and does not create a 3.3.0 jar... so I build it myself which goes fine. I stick it in my /libs folder and my app loads on my phone finally... The problem now is that running in PG 3 requires a change in how API calls are handled-- they are all plugins which you have to install before using them... so I installed all of the needed plugins...
The problem now is this message in logcat within Eclipse:
Unable to open asset URL: file:///android_asset/www/cordova/lib/cordova_plugins.js
so I find this cordova_plugins.js file in the root of my assets/www/ directory (Why is it here?! Shouldn't this be automated by cordova build & update to the correct location?!) So I try to copy the file to /www/cordova/lib/ where the error reports it is trying to find it.
When I do this, I get all of these errors:
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/DirectoryEntry.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/DirectoryReader.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/File.js
Unable to open asset URL:file:///android_asset/www/cordova/lib/plugins/org.apache.cordova.file/www/Entry.js
...etc (basically every plug-in that I had installed in the project.)
I am clearly missing something here... relocating these javascript files to the correct directory manually should not be what I need to do...
I should mention that this original error occurred when I was running the application in PG2.9 but the only plugins that I needed to use were included by default so I could still use the needed API functionalities.
Any ideas here?
You must need to create and deploy any phonegap project/application using Phonegap Command Line Interface
To Create any project write following command on command line:
$ phonegap create <path> <package_name> <project_name>
i.e.
$ phonegap create hello com.example.hello HelloWorld
To add any platform to your project:
cd <path_to_project>
$ phonegap build <platform>
i.e.
cd hello
$ phonegap build ios
$ phonegap build android
To add any plugin feature to your project:
cd <path_to_project>
$ phonegap local plugin add <path_to_plugin>
i.e.
cd hello
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

Categories

Resources