Code and apk build got no error but force close when open it

Im using cocos2d-x 4.0 c++, get this error when i ran it on android.

03-26 13:59:58.394 7160-7160/? E/Zygote: MountEmulatedStorage()
03-26 13:59:58.394 7160-7160/? E/Zygote: v2
03-26 13:59:58.394 7160-7160/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
03-26 13:59:58.394 7160-7160/? E/art: setrlimit(RLIMIT_CORE) failed for pid 7160: Operation not permitted
03-26 13:59:58.985 7160-7180/com.company.pattern A/libc: E:/Products/Shared/cocos2d/external/recast/…\json/document.h:1645: int rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >::GetInt() const [Encoding = rapidjson::UTF8, Allocator = rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator]: assertion “data_.f.flags & kIntFlag” failed
03-26 13:59:58.985 7160-7180/com.company.pattern A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 7180 (GLThread 877)

i think it cause by rapidjson, so i post my code line on json

json/document.h:1645: int rapidjson::GenericValue<rapidjson::UTF8, rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator >::GetInt() const [Encoding = rapidjson::UTF8, Allocator = rapidjson::MemoryPoolAllocatorrapidjson::CrtAllocator]: assertion “data_.f.flags & kIntFlag” failed

Header

#include “json/document.h”
#include “json/rapidjson.h”

Level.cpp
std::string file = “json/gameData.json”;
auto _jsonData = FileUtils::getInstance()->getStringFromFile(file.c_str());
rapidjson::Document doc;

	if (!doc.Parse(_jsonData.c_str()).HasParseError())
	{
		rapidjson::Value::ConstMemberIterator level_game = doc.FindMember("level_game");
		rapidjson::Value::ConstMemberIterator level_data = doc.FindMember("level_data");

		if (level_game != doc.MemberEnd())
		{
			totalLvl = level_game->value.GetInt();
		}
		if (level_data != doc.MemberEnd())
		{
			auto lvlData = level_data->value.GetArray();
		}

		arrlevelDataSize = doc["level_data"].Capacity();
		
		for (int j = 0; j < arrlevelDataSize; j++)
		{
			rapidjson::Value::ConstMemberIterator id_level = doc["level_data"][j].FindMember("id_level");

			if (id_level != doc.MemberEnd())
			{
				idLvl = id_level->value.GetInt();
			}

			rapidjson::Value::ConstMemberIterator pola_level = doc["level_data"][j].FindMember("pola_level");
			
			if (pola_level != doc.MemberEnd())
			{
				auto polaLvl = pola_level->value.GetArray();
			}

			int arrPolaLevelSize = doc["level_data"][j]["pola_level"].Capacity();

			for (int x = 0; x < arrPolaLevelSize; x++)
			{
				int arrSubLvlSize = doc["level_data"][j]["pola_level"][x].Capacity();

				for (int y= 0; y < arrSubLvlSize; y++)
				{
				}
			}

		}

	}

gameData.json

{
    "level_game": 20,
    "level_data": [
        {
            "id_level": 1,
            "pola_level": [
                [ 31, 32, 31, 32, 31, 32 ],
                [ 13, 23, 13, 23, 13, 23 ],
                [ 13, 11, 13, 11, 13, 11 ]
            ],
            "pola_soal": [
                [ 0, 0, 0, 0, 0, 32 ],
                [ 0, 0, 0, 0, 0, 23 ],
                [ 0, 0, 13, 0, 0, 0 ]
            ],
            "pola_jawaban": [
                [ 31, 32 ],
                [ 13, 23 ],
                [ 13, 11 ]
            ]
        },
        {
            "id_level": 2,
            "pola_level": [
                [ 22, 32, 22, 32, 22, 32 ],
                [ 23, 33, 23, 33, 23, 33 ],
                [ 12, 13, 12, 13, 12, 13 ]
            ],
            "pola_soal": [
                [ 0, 0, 0, 32, 0, 0 ],
                [ 0, 0, 23, 0, 0, 33 ],
                [ 0, 0, 12, 13, 0, 0 ]
            ],
            "pola_jawaban": [
                [ 22, 32 ],
                [ 23, 33 ],
                [ 13, 32, 12 ]
            ]
        },
        {
            "id_level": 3,
            "pola_level": [
                [ 21, 11, 21, 11, 21, 11 ],
                [ 32, 31, 32, 31, 32, 31 ],
                [ 14, 24, 14, 24, 14, 24 ]
            ],
            "pola_soal": [
                [ 0, 0, 21, 0, 0, 11 ],
                [ 0, 0, 0, 31, 32, 0 ],
                [ 0, 0, 14, 0, 0, 24 ]
            ],
            "pola_jawaban": [
                [ 11, 31, 21 ],
                [ 32, 31, 12 ],
                [ 23, 14, 24 ]
            ]
        }
    ]
}

Anybody know how to fix it ? So i can run it to my android device without a force close. Thank you

Why don’t you connect the debugger and step through the code? The error is in that section of code, and most likely related to one of the GetInt() calls.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.