possible reasons for black screen on both emulator and real devices?

cocos2d-x version: cocos2d-2.0-x-2.0.3
platform: android

I experimented running HelloCpp example on emulator and real devices, it works well.

when it went to my program(the program runs fine on win32, I ported it to android), it showed black screen on both of them.

so far I learned two possible reasons for this:

  1. opengl es support, which is not the cause here ’cause I tried on real device.

  2. resource files are not found, which is not either, I checked on it the image files are in the apk file, besides, the app would crash if CCSprite is not created successfully, wouldn’t it?

The app runs normally, showing nothing but fps.

So what other reasons could it be?

thank you in advance.

Can you post a logcat of the application starting up on your Android device?

Cory Trese wrote:

Can you post a logcat of the application starting up on your Android device?

the following is part of the logcat, as it’s too much to post it all. this part includes some words that could be clues, like failed, not permitted.

@
03-22 15:59:52.127: E/OMXCodec(1183): Successfully allocated software codec ‘VorbisDecoder’
03-22 15:59:52.135: E/OMXCodec(1183): Successfully allocated software codec ‘VorbisDecoder’
03-22 16:00:14.190: E/MyLog(8030): ZY>>LOGD=false
03-22 16:00:14.448: E/JavaBinder(1697): ! FAILED BINDER TRANSACTION !
03-22 16:00:17.127: E/JavaBinder(1697): ! FAILED BINDER TRANSACTION !
03-22 16:01:23.096: E/ActivityThread(8244): Failed to find provider info for com.google.settings
03-22 16:01:23.096: E/ActivityThread(8244): Failed to find provider info for com.google.settings
03-22 16:01:23.783: E/dalvikvm(8271): could not disable core file generation for pid 8271: Operation not permitted
03-22 16:02:05.619: E/ActivityManager(1264): ANR in com.android.test (com.android.test/.testandroid)
03-22 16:02:05.619: E/ActivityManager(1264): Reason: keyDispatchingTimedOut
03-22 16:02:05.619: E/ActivityManager(1264): Load: 2.14 / 3.83 / 4.48
03-22 16:02:05.619: E/ActivityManager(1264): CPU usage from 28431ms to 0ms ago:
03-22 16:02:05.619: E/ActivityManager(1264): 80 8271/com.android.test: 80 user + 0.1 kernel / faults: 72 minor
03-22 16:02:05.619: E/ActivityManager(1264): 12 1360/tiwlan_wq: 0 user + 12 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 1 1264/system_server: 0.6 user + 0.3 kernel / faults: 115 minor 1 major
03-22 16:02:05.619: E/ActivityManager(1264): 0.2 1180/battd: 0 user + 0.2 kernel / faults: 30 minor
03-22 16:02:05.619: E/ActivityManager(1264): 0.1 1915/com.moji.mjweather: 0.1 user + 0 kernel / faults: 549 minor
03-22 16:02:05.619: E/ActivityManager(1264): 0.1 217/omap2_mcspi: 0 user + 0.1 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 0.1 741/pvrflip/0: 0 user + 0.1 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 0.1 1389/com.android.launcher: 0.1 user + 0 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 0.1 1755/com.sina.weibo.servant: 0 user + 0 kernel / faults: 426 minor
03-22 16:02:05.619: E/ActivityManager(1264): 0.1 695/dsi: 0 user + 0.1 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 0.1 1697/com.qihoo.daemon: 0.1 user + 0 kernel / faults: 80 minor
03-22 16:02:05.619: E/ActivityManager(1264): 0 1331/com.android.systemui: 0 user + 0 kernel / faults: 8 minor
03-22 16:02:05.619: E/ActivityManager(1264): 0 2079/com.tencent.qqpimsecure: 0 user + 0 kernel / faults: 39 minor
03-22 16:02:05.619: E/ActivityManager(1264): 0 7889/com.qihoo360.mobilesafe: 0 user + 0 kernel / faults: 86 minor 1 major
03-22 16:02:05.619: E/ActivityManager(1264): 0 220/cpcap_irq/0: 0 user + 0 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 0 1357/sdio_wq: 0 user + 0 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 0 1383/wpa_supplicant: 0 user + 0 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 0 1760/cn.goapk.market: 0 user + 0 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 96 TOTAL: 82 user + 13 kernel + 0.1 irq
03-22 16:02:05.619: E/ActivityManager(1264): CPU usage from 1028ms to 1547ms later:
03-22 16:02:05.619: E/ActivityManager(1264): 74 8271/com.android.test: 74 user + 0 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 77 8272/HeapWorker: 77 user + 0 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 3.5 2174/com.halfbrick.fruitninjahd: 3.5 user + 0 kernel / faults: 365 minor
03-22 16:02:05.619: E/ActivityManager(1264): 2.3 2174/ck.fruitninjahd: 2.3 user + 0 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 1 1180/battd: 0 user + 1 kernel / faults: 2 minor
03-22 16:02:05.619: E/ActivityManager(1264): 1.9 1264/system_server: 1.9 user + 0 kernel / faults: 3 minor
03-22 16:02:05.619: E/ActivityManager(1264): 3.8 1308/InputDispatcher: 0 user + 3.8 kernel
03-22 16:02:05.619: E/ActivityManager(1264): 100 TOTAL: 96 user + 3.8 kernel
03-22 16:02:13.557: E/InputDispatcher(1264): channel ‘40847398 com.android.test/com.android.test.testandroid (server)’ ~ Consumer closed input channel or an error occurred. events=0x8
03-22 16:02:13.557: E/InputDispatcher(1264): channel ‘40847398 com.android.test/com.android.test.testandroid (server)’ ~ Channel is unrecoverably broken and will be disposed!
03-22 16:02:19.119: E/dalvikvm(8299): could not disable core file generation for pid 8299: Operation not permitted
@

turns out the app can’t open the json file in assets folder…then the question turns to “how to open the json file”.

the coce I tried is like, and p.json is located in the assets folder.

std::string fullpath4json = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(“p.json”);
FILE *pFileJson = fopen(fullpath4json.c_str(), “r”);

or

std::string fullpath4json = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(“p.json”);
ifstream FileJson(fullpath4json.c_str());

neither pFileJson nor FileJson is !NULL.

any suggestions on it? thanks

That will not work in Android. Under the Android OS, all of your ‘assets’ are stored inside of the APK (a zip file, essentially.)

You need to use code like this to read the file contents.

unsigned long tmpSize;
string fullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("p.json");
unsigned char* jsonData = CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "r", &tmpSize);

Cory Trese wrote:

That will not work in Android. Under the Android OS, all of your ‘assets’ are stored inside of the APK (a zip file, essentially.)
>
You need to use code like this to read the file contents.
>
[…]

ya, this is it. with this function, I can get the content and size of the json file now, seems right.

however, it’s not working correctly. when I tried to CCLog the content of json file, it only printed part of it. and the size of json got on win32 and android were different.

more help needed.