程序启动黑屏定位

【程序启动异常】
耗时30分钟
搜狐海外版本增加国家、币种配置。在该管理对象初始化时,需要通过android读取国家代码
DiamondPriceMgr::DiamondPriceMgr()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    const char * countryCode = ClientInterfaceAndroid::getCountryIso();
#else
    const char * countryCode = "ID"; 
#endif
    m_priceInfo = getPriceInfoByCountryCode(countryCode); 


#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    const char * appSecret = CommData::shared()->getTitleValue("CyPayAppSecret");
    CLDMessageBox(appSecret, "");
    ClientInterfaceAndroid::setPaySetting(m_priceInfo->country, m_priceInfo->currency, appSecret);
#endif
}
添加代码后,程序启动黑屏
11-13 09:35:54.446: I/DEBUG(26817): backtrace:
11-13 09:35:54.447: I/DEBUG(26817):     #00  pc 002727f4  /data/app-lib/com.cldeer.bubblebear.sohu-2/libbubblebear.so
11-13 09:35:54.447: I/DEBUG(26817):     #01  pc 00272911  /data/app-lib/com.cldeer.bubblebear.sohu-2/libbubblebear.so (cocos2d::JniHelper::getStaticMethodInfo(cocos2d::JniMethodInfo_&, char const*, char const*, char const*)+24)
11-13 09:35:54.447: I/DEBUG(26817):     #02  pc 0022c4df  /data/app-lib/com.cldeer.bubblebear.sohu-2/libbubblebear.so (ClientInterfaceAndroid::getCountryIso()+22)
11-13 09:35:54.447: I/DEBUG(26817):     #03  pc 001decc7  /data/app-lib/com.cldeer.bubblebear.sohu-2/libbubblebear.so (DiamondPriceMgr::DiamondPriceMgr()+10)
11-13 09:35:54.447: I/DEBUG(26817):     #04  pc 001ccb21  /data/app-lib/com.cldeer.bubblebear.sohu-2/libbubblebear.so
11-13 09:35:54.447: I/DEBUG(26817):     #05  pc 000032f3  /system/bin/linker
反复核对修改Jni转换函数,没有找到问题原因。不过可以排查Java代码的问题
后面仔细分析日志文件,发现一个疑点,这个错误是在加载so动态库时触发的。
11-13 09:28:21.039: D/dalvikvm(18696): Trying to load lib /data/app-lib/com.cldeer.bubblebear.sohu-1/libbubblebear.so 0x4137ff48
11-13 09:28:21.041: D/AudioMTKStreamOut(26904): AudioMTKStreamOut::write (-) latency_in_us,0.012379,0.000108,0.010716
11-13 09:28:21.042: I/(26904): MirrorAudioService::onAudioBuffer: outBuffSize=4460 size=4460 outConverterBytes=0
11-13 09:28:21.047: A/libc(18696): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 18696 (bubblebear.sohu)
11-13 09:28:21.047: A/libc(18696): Send stop signal to pid:18696 in debugger_signal_handler
联想到一个可能,刚加载so库时,jni功能还没准备好,才会出现空指针(0x00000000)
而代码中确实是把对象放到堆上了,需要错开
static DiamondPriceMgr sDiamondPriceMgr; 
DiamondPriceMgr * DiamondPriceMgr::shared()
{
    return &sDiamondPriceMgr;
}
将上面加载时初始化代码,修改为下面使用时才初始化的代码
DiamondPriceMgr * DiamondPriceMgr::shared()
{
    static DiamondPriceMgr * sDiamondPriceMgr = NULL;
    if (!sDiamondPriceMgr)
    {
    sDiamondPriceMgr = new DiamondPriceMgr();
    }
    return sDiamondPriceMgr;
}
测试正常。
这个错误说明,调用jni函数时要错开加载时的那段时间
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值