Cocos Creator 1.10.0 cannot load JSON on Android

Cocos Creator 1.10.0 cannot load JSON on Android
0

#1

Hi,

first of all, I noticed that the cc.loader.load has been changed from 1.9.x to 1.10.0. I used the following code to load the game data in 1.9.x:

    // Load game data...
    var url = cc.url.raw('resources/gamedata.json');
    cc.loader.load( url, function(err, res) {
        GlobalData.gameData = res;
    });

In 1.10.0 I had to change the assignment as follows:

        GlobalData.gameData = res.json;

It works in the simulator/browser, but the compiled APK does not work on Android. What should I do?

Best regards,
Zsolt


#2

have you tried to do
loader.loadRes(url, cc.JsonAsset, (err, res) => GlobalData.gameData = res) ?

is there anything in err on Android?


#3

Hi,

I tried to use the “old method” to use the res directly, but it did not work. The next step is to log the err on Android. Now I simply insert the game data statically… development cannot stop! :slight_smile:

Thanks for your efforts,
Zsolt


#4

@slackmoehrle Any comment from the developers concerning this topic? Would you be so kind as to contact them?


#5

Can you please try 2.0 and see if the problem persists?


#6

Ok, I will.


#7

Well, there are some problems with CC 2.0, fromHSV generates very strange colors (the r-g-b-a variables are mixed?!) and the compiled APK cannot be installed on the Android devices… I don’t know why.

Best regards,
Zsolt