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.
Related
I am trying to generate source maps in the Gradle build process of a React Native app and read the source map file in the application.
I used this project as a starting point: https://github.com/philipshurpik/react-native-source-maps
I didn't succeed in including it as it is, so I tried to take and modify parts of it.
In app/gradle.build I added:
project.ext.react = [
extraPackagerArgs: ["--sourcemap-output", "$buildDir/intermediates/assets/release/index.map"]
]
and indeed when I'm running the release build I see the file index.map under android/app/build/intermediates/assets/release , but when I deploy the APK to a device or emulator, I can't see this file anywhere in Android's filesystem. For that matter, I also can't see the bundle file or any files that were in android/app/src/main/assets and I do see in android/app/build/intermediates/assets/release after build.
The application code uses https://github.com/itinance/react-native-fs to read the file. This is how I first check if the file exists:
const fileExists = await RNFS.existsAssets(`${RNFS.DocumentDirectoryPath}/index.map`)
and the file doesn't exist there. RNFS.DocumentDirectoryPath returns /data/user/0/mypackagename/files , which is empty when I check (using adb shell with root access).
What am I missing? How do I get the source map file to a location which will be available to the application to read?
Turned out the gradle.build part was fine, and in order to read the source map file I needed to use just the file name, like so: RNFS.existsAssets('index.map')
I am building a daemon on Android Platform. For which I have cross compiled the existing code, which is present in Linux to Android. Please consider my below 2 cases -
I cross compile the code using Cmake with Android NDK-15 and push manually to the board on which Android Code is available. The path in which we push is /system/lib. Then if I try to execute my daemon (which is also pushed manually to /system/bin ) everything works fine.
But,
2 The cross compiled library have been pushed into the AOSP code by writing an Android.mk file written in vendor specific folder. I have used BUILD_PREBUILTS method and was successfully able to push the libraries to /system/lib. Now, when I try to execute my application (Compiled with CMake ) I get a linker error.
Below is the error which I get ( Reference Example ) -
Below is the folder structure -
Total Number of folders - 3
a. abc folder which produces output libabc.so and links to libdef.so and
libghi.so
b. def folder which produces output libdef.so
c. ghi folder which produces output libghi.so
When I push all the 3 libraries (libabc.so, libdef.so, libghi.so ) directly in /system/lib and my executable (drive_test) which links all the 3 libraries, I have no issue. But, when I push it along with AOSP build I get the following error on execution of the executable (drive_test) -
a. Unable to link ../abc/def.so file.
I am unable to debug how to solve this linker issue. I am not getting whether it is because of CMake (or) any other issue.
If you're trying to make a system daemon (something that goes in /system/bin), don't use the NDK. Just use the AOSP build system.
In mydaemon/Android.bp (make sure to add this path to the root Android.bp file):
cc_library {
name: "libmylib",
srcs: ["mylib.cpp"],
}
cc_binary {
name: "mydaemon",
srcs: ["mydaemon.cpp"],
shared_libs: ["libmylib"],
}
The build system will deal with getting libraries and binaries into the right place for you.
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
In my other computer I have ripple emulating a phonegap android app, but now I´m trying to emulate in my classroom pc and doesn´t work the hello world neither my project.
I have phonegap,npm,ant,java dk,android sdk and ripple-emulator installed.
When I go to:
mypath/platforms/android/assets/www
and type:
ripple emulate
this error happend:
INFO: Server instance running on: localhost:4040 INFO: CORS XHR
proxy service on: localhost:4040/ripple/xhr_proxy INFO: JSONP
XHR proxy service on: localhost:4040/ripple/json_xhr_proxy
Cordova 3.0 project dected...
**fs.js:654 return binding.readdir(pathModule._makeLong(pah)): Error: ENOENT, no such file or director "c:\mypath...
Try running ripple emulate from the root of the project, not in the platform www folder.
one solution which is currently working on all platforms are based on some small source code tweaks. The major problem is regarding the www/platform folder. Especially older phonegap versions doesnt introduce the same Folder structure so you needto adjust the following file to make it properly:
Additional information:
Make sure ripple was installed globally as well as Phonegap and/or Cordova
npm install -g ripple-emulator
npm install -g phonegap
npm install -g cordova
This solution works for Linux, Mac and Windows. You only need to pay attention on the path. Filenames about the source code adjustments remain same. This explanation is based on windows but can be easily used for any other operating system.
1.) Find the ripple Folder on your hard Disk (on Windows you need to show your hidden files and than you should be able to find it at the following path:
Windows:
C:\Users\YOUR_USERNAME\AppData\Roaming\npm\node_modules\ripple-emulator
Pay attention to replace YOUR_USERNAME with your current username in the shown path. If you have customized your path where npm modules get installed please go to that folder and search for the following directory in it /ripple-emulator
2.) Next lets find the file which makes trouble to start ripple correctly. Within the /ripple-emulate directory navigate through the following subdirectories server\emulate. Full path e.g.
Windows:
C:\Users\YOUR_USERNAME\AppData\Roaming\npm\node_modules\ripple-emulator\lib\server\emulate
3.) Open cordovaProject.js and replace all strings which contain "platforms" with an empty one "" as shown Bellow, you can also copy the code shown bellow...
var platforms = fs.readdirSync(path.join(paths.orig, ""));
if (platforms.indexOf('android') >= 0) {
opts.cordova = 'android';
paths.android = path.join(paths.orig, "", "android", "assets", "www");
}
if (platforms.indexOf('ios') >= 0) {
opts.cordova = 'ios';
paths.ios = path.join(paths.orig, "", "ios", "www");
}
if (platforms.indexOf('firefoxos') >= 0) {
opts.cordova = 'firefoxos';
paths.firefox = path.join(paths.orig, "", "firefoxos", "www");
}
if (platforms.indexOf('blackberry10') >= 0) {
opts.cordova = 'blackberry10';
paths.blackberry = path.join(paths.orig, "", "blackberry10", "www");
4.) Now save it.
5.) Make sure you have uninstalled the ripple emulator plugin in chrome (to check open chrome browser, go to Settings and choose extensions). In case you don't know how to uninstall extensions in chrome you can find some additional instruction here https://support.google.com/chrome/answer/113907?hl=en In addition make sure you are using chrome as your Default browser.
6.) Now open your command line and navigate to your phonegap specific www folder and run the command
ripple emulate
optional you also can run it with the following command:
ripple emulate --path/TO_YOUR_PROJECT_FOLDER/www
Thank you & br
Schreda
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");