Cocos-js 3.5 升级到3.6.1后,打包安装到andriod黑屏!

环境:cocos ide 1.2 mac
从 cocos js 3.5 升级到3.6.1

直接打包安装到设备,游戏黑屏。

但是adb到设备调试,游戏正常!!

各位有没有遇到的啊

抓了下真机上到日志, 这里是可疑点:

I/Timeline( 929): Timeline: Activity_windows_visible id: ActivityRecord{424d97f0 u0 org.xxx.aaaaa/org.cocos2dx.javascript.AppActivity t119} time:20936572
D/PhoneStatusBar( 1017): disable: 0x00000180 -> 0x00000100 (diff: 0x00000080)
D/PhoneStatusBar( 1017): disable: < expand icons alerts ticker system_info back home recent clock full HIDE >
W/InputMethodManagerService( 929): Got RemoteException sending setActive(false) notification to pid 13443 uid 10137
V/PhoneStatusBar( 1017): setLightsOn(true)
W/Binder ( 1140): Caught a RuntimeException from the binder stub implementation.
W/Binder ( 1140): java.lang.NullPointerException
W/Binder ( 1140): at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
W/Binder ( 1140): at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
W/Binder ( 1140): at android.os.Binder.execTransact(Binder.java:404)
W/Binder ( 1140): at dalvik.system.NativeStart.run(Native Method)
I/WindowManager( 929): Screen frozen for +646ms due to Window{42e5b720 u0 Starting org.xxx.aaaaa}
I/Timeline(14800): Timeline: Activity_idle id: android.os.BinderProxy@4241d9c0 time:20936608
W/dalvikvm(14800): dvmFindClassByName rejecting ‘org/cocos2dx/lib/Cocos2dxLocalStorage’
D/cocos2d-x debug info(14800): (evaluatedOK == JS_FALSE)

自己顶起来

麻烦贴一下你使用LocalStorage的代码

ADB调试模式能跑,奇怪啊。

package org.cocos2dx.javascript.util;

import java.util.UUID;
import java.security.MessageDigest;
import java.io.UnsupportedEncodingException;

import android.content.Context;
import android.provider.Settings.Secure;
import android.content.SharedPreferences;
import android.telephony.TelephonyManager;

public class DeviceInfoUtil {
protected static String muuid;
private static Context mcontext;
protected static final String PREFS_FILE = “gank_device_id.xml”;
protected static final String PREFS_DEVICE_ID = “gank_device_id”;

public static void registerContext(Context context){
    DeviceInfoUtil.mcontext = context;
}

public static String getAndroidID() {
    String androidID = Secure.getString(mcontext.getContentResolver(),
            Secure.ANDROID_ID);
    return androidID;
}

public static String getIMEI() {
    TelephonyManager tm = (TelephonyManager) mcontext
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getDeviceId();
}

public static String getDeviceName() {
    return android.os.Build.MODEL;
}

public static String getDeviceModel() {
    return android.os.Build.MODEL;
}

public static String getOsVersion() {
    return android.os.Build.VERSION.RELEASE;
}

public static String getDeviceBrand() {
    return android.os.Build.BRAND;
}

public static String getSimSerialNumber() {
    TelephonyManager tm = (TelephonyManager) mcontext
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getSimSerialNumber();
}

public static String getUDID() {
    if( muuid !=null ) {
        return muuid;
    }

    synchronized (DeviceInfoUtil.class) {
        if( muuid != null) {
            return muuid;
        }
        final SharedPreferences prefs = mcontext.getSharedPreferences(PREFS_FILE, 0);
        final String id = prefs.getString(PREFS_DEVICE_ID, null );
        if (id != null) {  
             muuid = id;
             return muuid;
        } 
        final String androidId = getAndroidID();  
        try {  
            if (!"9774d56d682e549c".equals(androidId)) {  
                muuid = UUID.nameUUIDFromBytes(androidId.getBytes("utf8")).toString();  
            } else {  
                final String deviceId = getIMEI();  
                muuid = deviceId!=null ? UUID.nameUUIDFromBytes(deviceId.getBytes("utf8")).toString() : UUID.randomUUID().toString();  
            }  
        } catch (UnsupportedEncodingException e) {  
            throw new RuntimeException(e);  
        }  

        prefs.edit().putString(PREFS_DEVICE_ID, muuid).commit();  
    }
    return muuid;
}

}

我下了3.5,3.6,空的helloworld工程,编译到android,全是黑屏,下了一个3.2就正常!

有点奇怪,我们测试是没有问题的

我看错误是报了W/dalvikvm(14800): dvmFindClassByName rejecting ‘org/cocos2dx/lib/Cocos2dxLocalStorage’

看起来Android的LocalStorage实现没有加载成功

所以我才会问你在哪里用到了localStorage

用android ADB调试到设备正常,
就是一打包安装就不行了。
用的cocos ide 1.2哈

加入引擎源代码重新编译一下Runtime试试,应该能解决问题

弱弱的问一句:
我用的是引擎模式,并没有使用framework模式。

如何才能重新编译Runtime?

我之前用的是2.0的ide,换回1.2后就正常了!汗!!!!!!!

重新编译 还是不行~~~~~

这个不是吧,我用的1.2的IDE不能够编译通过

我也遇到过 一样的错误。。。。因为使用了anysdk showads 感觉有问题新版的。
后来使用github上面的demo解决了。 不知道为啥黑屏。。。

你好,我也遇到同样的问题,cocos2d-js 3.6 项目代码中并没有使用localstorage,测试机器为华为mate,没有存储卡,使用机身内存。

你好,我注释掉这段代码就可以了。

        var posX = 100;
        var posY = 50;
        var connBtn = new ccui.Button();
        connBtn.setTouchEnabled(true);
        connBtn.addTouchEventListener(this.testPomeloConnect, this);
        connBtn.setTitleText("connect");
        var title = connBtn.getTitleRenderer();
        title.setFontSize(40);
        title.enableShadow(cc.color.RED, cc.size(2, -2));
        //title.enableStroke(cc.color.GREEN, 2);
        //connBtn.setTitleFontSize(new cc.Size(100, 100));
        connBtn.attr({
            x : posX,
            y : posY
        });
        this.addChild(connBtn);


```


*--- Begin quote from ____*

引用第5楼fysp于2015-05-20 22:54发表的  :
有点奇怪,我们测试是没有问题的


我看错误是报了W/dalvikvm(14800): dvmFindClassByName rejecting 'org/cocos2dx/lib/Cocos2dxLocalStorage'

....... http://www.cocoachina.com/bbs/job.php?action=topost&tid=301014&pid=1311495
![](p_w_picpath/back.gif)



*--- End quote*

注释掉

var title = connBtn.getTitleRenderer();
        title.setFontSize(40);
        title.enableShadow(cc.color.RED, cc.size(2, -2));


```

就可以了,搞不明白...

*--- Begin quote from ____*

引用第14楼past106于2015-07-22 14:19发表的  :
你好,我注释掉这段代码就可以了。
        var posX = 100;
        var posY = 50;
....... http://www.cocoachina.com/bbs/job.php?action=topost&tid=301014&pid=1352635
![](p_w_picpath/back.gif)



*--- End quote*

解开apk包看看里面是不是缺少了index.html, 如果没有,就修改proj.Android下的build-cfg.json文件,看一下文件就知道怎么改了。

这种问题一定是你代码的问题, 跟引擎没关系的, 比如说加载的js文件没有, js文件语法出错等等。