I want use dojo in phonegap application.I tried test applications of dojo in android.But they are not displaying anything in emulator.Can anyone help me how to use dojo in phonegap application.
thanks
Himabindu
Android has some problems with the dynamic loading. This means you have to make a custom-build of dojo 1.7.1.
To make a custom build you need the src version of dojo.
I extended the profile file "baseplus.profile.js" found in the directory "dojo/util/builsscripts/profiles/" as follows:
dependencies = {
selectorEngine: "acme",
layers: [
{
// This is a specially named layer, literally 'dojo.js'
// adding dependencies to this layer will include the modules
// in addition to the standard dojo.js base APIs.
name: "dojo.js",
dependencies: [
"dijit._Widget",
"dijit._Templated",
"dojo.fx",
"dojo.NodeList-fx",
//this wasn't included in the standard build but necessary
"dojo._firebug.firebug",
//my used dojo requirements
"dojox.mobile.parser",
"dojox.mobile",
"dojox.mobile.Button",
"dojox.mobile.SwapView",
"dojox.mobile.ScrollableView",
"dojox.mobile.TabBar",
"dojox.mobile.SpinWheelTimePicker",
"dojox.mobile.compat"
]
}
],
prefixes: [
["dijit", "../dijit" ],
["dojox", "../dojox" ]
]
}
you have to execute the build.sh (Unix/OSx) or build.bat (Windows) in the shell with the command "./build.sh action=release profile=profiles/myBaseplus.profile.js -r"
After a successful build you find the dojo.js file in "dojo/release/djojo/dojo.js".
You only need this file.
Never the less you will also need the following require statement in your html file:
require([
"dojox/mobile/parser", // (Optional) This mobile app uses declarative programming with fast mobile parser
"dojox/mobile", // (Required) This is a mobile app.
"dojox/mobile/Button",
"dojox/mobile/SwapView",
"dojox/mobile/ScrollableView",
"dojox/mobile/TabBar",
"dojox/mobile/SpinWheelTimePicker",
"dojox/mobile/compat" // (Optional) This mobile app supports running on desktop browsers
],
function(parser, mobile, compat){
//Optional module aliases that can then be referenced inside callback block
}
);
Try renaming tweetview.html to index.html.
The PhoneGap entry point file name needs to match the file name from the native source. On Android the connection comes from src/{com.package}/{activityname}.java.
super.loadUrl("file:///android_asset/www/index.html");
Related
Problem description
Preconditions: The Android project uses "Android.bp" files for defining the modules to build.
I'm using a shared library "my-module" that gets installed on "/vendor/lib/lua/5.1/modules/" folder by using the relative_install_path property.
In addition a Google-test executable is build that uses the shared library to verify implementation.
After the vendor.img is built and the emulator runs, I connect via "adb root && adb shell" to execute the "/vendor/bin/my-module-test".
(!) But if fails with...
CANNOT LINK EXECUTABLE "/vendor/bin/my-module-tests": library "my-module.so" not found: needed by main executable
...since the library is stored on a sub-folder inside of the "/vendor/lib".
Unsuccessful fix
I tried to create a symlink "/vendor/lib/my-module.so" that refers to the origin in "/vendor/lib/lua/5.1/modules/my-module.so".
Creating it manually inside of the build artifacts and running...
make "vendorimage && make systemimage"
...worked fine.
But I want to have it defined in the build-steps (like Android.bp) to run it automatically.
Until now without success.
There exists an option with "LOCAL_POST_INSTALL_CMD" but that would require using "Android.mk" files for the module/executable which I'm not allowed to use.
Android.bp sources
Android.bp of shared library named "my-module" used for Lua as a module to be loaded:
cc_library_shared {
name: "my-module",
srcs: [
...
],
...
vendor: true,
relative_install_path: "lua/5.1/modules"
}
Android.bp of a Google test executable to test the implementation of "my-module":
cc_binary {
name: "my-module-tests",
srcs: [
"test.cpp",
],
shared_libs:[
"my-module",
...
],
required: [
"my-module",
...
],
vendor: true
}
Questions
Do you have any idea how to solve this problem without manual adaptations of the build artifacts?
Do you see a way how to create symlinks for the shared library in that case (please describe in detail)?
Thanks!
I have a NativeScript/Angular application that uses code sharing.
To make my project more organized, I have created a core folder that contains a sub-folder for routing:
Routes are defined in app.common.ts:
export const appRoutes: Routes = [
{ path: '', redirectTo: '/products', pathMatch: 'full' },
{
path: 'products',
loadChildren: '../products/products.module#ProductsModule'
}
]
Of particular interest is the module path shown in the following property:
loadChildren: '../products/products.module#ProductsModule'
Serving this in the browser using ng serve -o works fine.
Bundling this to run on Android using tns run android --bundle doesn't work as it can't find the module.
If I change the path to ~/app/products/products.module#ProductsModule, the Android app then runs, but the web application can't find the module.
If I then leave the file watcher running for the Android build and change the path back to ../products/products.module#ProductsModule, both Android and web work fine.
I don't want to move my routing files back to the src folder. I am also reluctant to include any hacks such as platform-driven path string mangling.
If you have any explanations as to why this is happening and/or a robust fix that isn't 'hacky', I'd be keen to hear it.
The problem was stemming from some quirks regarding the file watchers. When I change the path to the following, both platforms work fine:
../../products/products.module#ProductsModule
The reason I didn't select this path from the outset is because I used ~/app/products/products.module#ProductsModule to begin with and edited this to get the web build to work while the Android file watcher was still running.
With both the Android and web file watchers terminated and the path adjusted to the one provided above, they both work.
I'm trying to build an application on Sencha Touch for android, so I use Cordova to put it on my device.
The problem I'm facing is that everything works fine on my computer, but on android, the device can not find and read the locales files for each stores (I've already test on other Android device).
Here is the error on logcat:
E/AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/www/app/store/recipes/list.json?_dc=1481398604306&node=ext-data-treestore-1-root&page=1&start=0&limit=25
E/AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/www/app/store/recipes/pates.json
And here is the store that I use to read "pates.json":
var ingredientsData = Ext.create('Ext.data.Store', {
model: 'fr.ESIR.GreenVentory.model.IngredientListModel',
autoLoad: true,
proxy: {
type: 'ajax',
noCache: false,
enablePagingParams: false,
limitParam: null,
url: "./app/store/recipes/pates.json",
reader: {
rootProperty: 'ingredients',
totalProperty: 'totalCount'
}
}
});
And the files that I try to load are locally stored in "app/store/recipes/"
If someone have a solution, it would be cool for me to know it
I resolve my own problem:
All the data was stored on app/store of the sencha application, and when I build the Android application with Cordova, it doesn't take the json file because I haven't specify the file location.
So I create a data folder on the project root, put my json file and the folders that contain them on the data folder.
Don't forget to update the differents references of your json files
After that, it still working on the web version, but not on Android, because cordova don't integrate your files. Cordova reads the app.json file that you have on the root of your project. Go to the "resources" section of the file. Normally you have something like this:
/**
* Extra resources to be copied along when build
*/
"resources": [
"resources/images",
"resources/icons",
"resources/startup",
"data/*",
"data/recipes"
]
Just add the location of the folder that contains your file and cordova should integrate them when it compiles
I am developing an android app based on ionic 2 using typescript.
I would like o open a PDF file inside my app with another app that is registered for the fyletype (e.g. Acrobat Reader).
Therefore i tried the two standard plugins:
https://github.com/disusered/cordova-open
https://github.com/pwlin/cordova-plugin-file-opener2
Although ive added both plugins via "ionic plugin add ..." and of course played around with several combination referencing to it
the result is always that they ere not found
cordova-open
var open = cordova.plugins.disusered.open;
Property 'disusered' does not exist on type 'CordovaPlugins'.
cordova-plugin-file-opener2
cordova.plugins.fileOpener2.open(
filePath,
fileMIMEType,
{
error : function(){ },
success : function(){ }
}
);
Property 'fileOpener2' does not exist on type 'CordovaPlugins'.
I am running the app on an emulator via ionic run android
Could you please give some hint how i can achieve to use one of these plugins?
Thank you very much
Shane
I want to use this cordova plugin at https://github.com/katzer/cordova-plugin-local-notifications
How to go about integrating this plugin with my existing IBM Worklight project? I have trying various methods to integrate it without any result.
I am getting this error currently from the logcat:
02-24 11:15:03.035: D/CordovaLog(2439): file:///data/data/com.iCareApp/files/www/default/index.html: Line 17 : Uncaught TypeError: Cannot read property 'notification' of undefined
Or is there any other easier alternatives to get this done? Basically i want to be able to schedule local notification on the device at specific times from the data stored in my application
I got this to work by following the below.
Demo project: https://www.dropbox.com/s/58urdluauc8u3l1/AndroidLocalNotifications.zip
Because Worklight does not support Cordova's Plugman to easily "install" Cordova v3 plug-ins, some manual labor is required to get it all set-up properly... blachs.
Note the appName , it is used throughout the process for plug-in declarations. If you use a different name for in your app, you will need to update the values accordingly with yours.
Pay attention to the nativeResources folder, where I've placed the files I edited:
AndroidManifest.xml:
In it I added the required permission, receivers, activities
libs folder:
Contains required .jar file by the plug-in
src folder:
Contains the plug-in's Java classes
In them I've edited the plug-in import declaration
res\xml folder:
Contains config.xml; see at the bottom for the plug-in feature declaration
In index.html:
The plug-in's JavaScript implementation is referenced in the head element
<script src="js/local-notification.js"></script>
In main.js:
function wlCommonInit(){
window.plugin.notification.local.add({ message: 'this is a local notification' });
}
The above will send a local notification immediately after the application's launch.
In the plug-in's homepage you can read more about the possible notification options.
In local-notification.js:
Add at the top:
cordova.define("LocalNotification", function(require, exports, module) {
Add at the bottom:
});
In the generated Android project\assets\www\default\js\worklight\cordova_plugins.js, add:
,
{
"file": "../js/local-notification.js",
"id": "LocalNotification",
"clobbers": [
"plugin.notification.local"
]
}
Note that re-building the Worklight project will overwrite this file, and thus your changes in it will be gone... you'll need to repeat this step after every build.
There is no good way that I could find to preserve changes to this file between Worklight Studio builds.