NativeScript when adding custom resource/json files -


i creating project target android , in it, want come .json file data loaded.

i put .json file android folder. when running "tns run android --device 1" (which physical device) get:

-code-gen: [mergemanifest] no changes in androidmanifest files.  [echo] handling aidl files...  [aidl] no aidl files compile.  [echo] ----------  [echo] handling renderscript files...  [echo] ----------  [echo] handling resources...  [aapt] found new input file  [aapt] generating resource ids...  [aapt] invalid resource directory name: /users/konrad/desktop/nativescript/hello-world/platforms/android/res res  [aapt] invalid resource directory name: /users/konrad/desktop/nativescript/hello-world/platforms/android/res small.json  build failed /usr/local/cellar/android-sdk/24.3.3/tools/ant/build.xml:649: following error occurred while executing line: /usr/local/cellar/android-sdk/24.3.3/tools/ant/build.xml:694: null returned: 1  total time: 0 seconds command ant failed exit code 1 

the file called small.json

edit: if remove file, problem still remains.

the property of android restricts access parts of file system. there 2 ways of accessing files on nativescript android:

1) javascript way

var fs = require('file-system'); var documents = fs.knownfolders.documents(); var myfile = documents.getfile(filename);    

as specified in docs: https://github.com/nativescript/docs/blob/master/apireference/file-system/how-to.md

2) android specific way including third party library called "json-simple" needs attached using command tns library add android .

var context = app.android.context; var assets = context.getassets();  var br = new java.io.bufferedreader(new java.io.inputstreamreader(assets.open(filename)));  var parser = new org.json.simple.parser.jsonparser(); try {     parser.parse(br); } catch (ex) {     var javaex = ex.nativeexception;     var msg = javaex.getmessage();     console.log("whops! : "+msg);  } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -