1

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

Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
  • and is app directory inside www directory, inside assets? – Nick Cardoso Dec 10 '16 at 21:01
  • The application is stored on /data/app/fr.ESIR.GreenVentory-1/base.apk and the data path is on /data/user/0/fr.ESIR.GreenVentory – digitalTrilunaire Dec 10 '16 at 21:42
  • I was asking about "And the files that I try to load are locally stored in "app/store/recipes/" Open your Android project in the IDE and click the "pates.json" file and take a screenshot of the structure view to add to your question please – Nick Cardoso Dec 10 '16 at 22:02
  • In fact I use Sencha Touch API, with this you can build web app normally "easily". However, what is good is that you can integrate Cordova with it, and Cordova transform your web app on Android app. But your comment help me, I just extract all files from the apk, looking for an nonexistent "pates.json"... – digitalTrilunaire Dec 10 '16 at 23:31

1 Answers1

0

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

  • Glad you fixed it, these json/web files (all of www directory) should probably be in assets (because they are not android resources) so you should update your gradle to include them there. That should mean you don't have to fix your paths (as you can see from the error log, it looks in assets by default) – Nick Cardoso Dec 11 '16 at 01:29