使用Cocos2d-x
开发Android应用程序时出现崩溃。所以我使用的是ndk-stack
,我收到了这个错误:
D:\Android\android-ndk-r8e>adb logcat | ndk-stack.exe -sym e:\graduation_project
\cocos2d-x-2.1.5\projects\Test_py\proj.android\obj\local\armeabi\
********** Crash dump: **********
Build fingerprint: 'google/mysid/toro:4.2.2/JDQ39/573038:user/release-keys'
pid: 9911, tid: 9950, name: Thread-1096 >>> com.einverne.test_py <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr ff7a8390
Stack frame #00 pc 0001055e /system/lib/libc.so (dlmalloc+1729): Unable to ope
n symbol file e:\graduation_project\cocos2d-x-2.1.5\projects\Test_py\proj.androi
d\obj\local\armeabi\/libc.so. Error (9): Bad file descriptor
Stack frame #01 pc 0000dcc7 /system/lib/libc.so (malloc+10): Unable to open sy
mbol file e:\graduation_project\cocos2d-x-2.1.5\projects\Test_py\proj.android\ob
j\local\armeabi\/libc.so. Error (9): Bad file descriptor
Stack frame #02 pc 002a4bff /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (cocos2d::unzOpenCurrentFile3(void*, int*, int*, int, char const*)+482): Rou
tine unzOpenCurrentFile3 in e:\graduation_project\cocos2d-x-2.1.5/cocos2dx/suppo
rt/zip_support/unzip.cpp:1494
Stack frame #03 pc 002a4d9f /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (cocos2d::unzOpenCurrentFile(void*)+10): Routine unzOpenCurrentFile in e:\gr
aduation_project\cocos2d-x-2.1.5/cocos2dx/support/zip_support/unzip.cpp:1677
Stack frame #04 pc 002a302d /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (cocos2d::ZipFile::getFileData(std::string const&, unsigned long*)+76): Rout
ine getFileData in e:\graduation_project\cocos2d-x-2.1.5/cocos2dx/support/zip_su
pport/ZipUtils.cpp:556
Stack frame #05 pc 002943c5 /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (cocos2d::CCFileUtilsAndroid::getFileData(char const*, char const*, unsigned
long*)+76): Routine getFileData in e:\graduation_project\cocos2d-x-2.1.5/cocos2
dx/platform/android/CCFileUtilsAndroid.cpp:126
Stack frame #06 pc 00173267 /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (CLuaScriptReader::RunScriptFile(char const*, char*, char*)+46): Routine Run
ScriptFile in jni/../../Classes/LuaScriptReader.cpp:318
Stack frame #07 pc 00172129 /data/app-lib/com.einverne.test_py-1/libcocos2dcpp
.so (JudgeManager::getResult(std::string, std::string, CharacterEntity*, std::st
ring)+200): Routine getResult in jni/../../Classes/JudgeManager.cpp:51
当我回到我的代码时。
bool CLuaScriptReader::RunScriptFile(const char *filename,char* ret_string,char *name){
if( m_plua == NULL || ret_string == NULL || filename == NULL ) return false;
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
char filebuff[MAX_LUA_FILE_LEN] = "";
char line[1024] = "";
FILE* fpFile = fopen(filename,"r");
if( fpFile == NULL ) {
printf("can not find file %s\n",filename);
return false;
}
while( fgets(line, 1024, fpFile) != NULL) {
strcat(filebuff,line);
}
fclose(fpFile);
RunScriptBuffer(filebuff,ret_string,name);
#endif
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
unsigned long int size = 0;
unsigned char* filebuff = CCFileUtils::sharedFileUtils()->getFileData(filename,"r",&size);
CCString* ccStr = CCString::createWithData(filebuff,size);
RunScriptBuffer(ccStr->getCString(),ret_string,name);
#endif
return true;
}
此行发生错误:
unsigned char* filebuff = CCFileUtils::sharedFileUtils()->getFileData(filename,"r",&size);
但是,我总是使用此代码在Android下读取文件。可以找到here
类CLuaScriptReader
答案 0 :(得分:0)
如何编译文件?
脚本似乎有问题。这些行:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr ff7a8390
Stack frame #00 pc 0001055e /system/lib/libc.so (dlmalloc+1729): Unable to ope
n symbol file e:\graduation_project\cocos2d-x-2.1.5\projects\Test_py\proj.androi
d\obj\local\armeabi\/libc.so. Error (9): Bad file descriptor
信号11-&gt;内存失败,路径无处可去。 /适用于UNIX系统中的路径,以及适用于WINDOWS系统的路径,因此查找libc.so有错误
错误的文件描述符是linux,如果在尝试访问文件时收到此错误消息,则最突出的原因是文件系统损坏或磁盘块损坏。在这种情况下,您也会出现写入错误。