注册 登录
主题 : cocos lua AssetsManagerEx 热更新 安卓真机闪退
级别: 新手上路
UID: 596925
精华: 0
发帖: 2
可可豆: 11 CB
威望: 11 点
在线时间: 56(时)
注册时间: 2016-11-10
最后登录: 2017-08-19
楼主 : 发表于: 2017-07-10 16:54    发自: Web Page
来源于 未解决 分类

cocos lua AssetsManagerEx 热更新 安卓真机闪退   

//WIN7可以没问题,安卓手机就闪退,求解决办法


function MainScene:update(p_fun)
    local writablePath = cc.FileUtils:getInstance():getWritablePath()
    local storagePath = writablePath .. "new_version"
    --将下载目录的src和res作为优先级最高的搜索目录,这样才能保证下载的能覆盖原来的代码
    
    cc.FileUtils:getInstance():addSearchPath(storagePath.."/src/",true)
    cc.FileUtils:getInstance():addSearchPath(storagePath.."/res/",true)
    
    --------------------------------
    local srcPath = storagePath.. '/src/'
    local resPath = storagePath.. '/res/'

    if not (cc.FileUtils:getInstance():isDirectoryExist(storagePath)) then        
        cc.FileUtils:getInstance():createDirectory(storagePath)
        cc.FileUtils:getInstance():createDirectory(resPath)
        cc.FileUtils:getInstance():createDirectory(srcPath)
    end
    

  
    --------------------------------
    -- 创建AssetsManagerEx对象
    local assetsManagerEx = cc.AssetsManagerEx:create("version/project.manifest", storagePath)
    assetsManagerEx:retain()
    -- 设置下载消息listener
    local localManifest = assetsManagerEx:getLocalManifest()
    local Version=localManifest:getVersion()
    
    local searchPaths = cc.FileUtils:getInstance():getSearchPaths()
    table.insert(searchPaths, 1, storagePath)  
    table.insert(searchPaths, 2, resPath)
    table.insert(searchPaths, 3, srcPath)
    cc.FileUtils:getInstance():setSearchPaths(searchPaths)
    
    p_fun(Version)
    if Version~='' then
       --return ;
    end
    local function handleAssetsManagerEx(event)
        if (cc.EventAssetsManagerEx.EventCode.ALREADY_UP_TO_DATE == event:getEventCode()) then
            
            local str="已经是最新版本了,进入游戏主界面"
            print(str)
            p_fun(str)
            
            --app:enterScene("GameScene")
        end
        
        if (cc.EventAssetsManagerEx.EventCode.NEW_VERSION_FOUND == event:getEventCode()) then

            local str="发现新版本,开始升级"
            print(str)
            p_fun(str)
            
        end

        if (cc.EventAssetsManagerEx.EventCode.UPDATE_PROGRESSION == event:getEventCode()) then
            local upnum=event:getPercent()--当前进度
            local ByFile=event:getPercentByFile()--总进度
            local num=Global:Int(ByFile)
            local str="更新进度="..num.."%"
            print(str)
            p_fun(str,num)
            
        end
        
        
        if (cc.EventAssetsManagerEx.EventCode.UPDATE_FINISHED == event:getEventCode()) then
            --app:run()
            --cc.game.restart()
            local str="更新完毕,请重新启动"
            print(str)
            p_fun(str)
            
        end
        
        if (cc.EventAssetsManagerEx.EventCode.ERROR_NO_LOCAL_MANIFEST == event:getEventCode()) then

            local str="发生错误:本地找不到manifest文件"
            print(str)
            p_fun(str)
            
        end
        
        if (cc.EventAssetsManagerEx.EventCode.ERROR_DOWNLOAD_MANIFEST == event:getEventCode()) then
        
            local str="发生错误:下载manifest文件失败"
            print(str)
            p_fun(str)
            
        end
        
        if (cc.EventAssetsManagerEx.EventCode.ERROR_PARSE_MANIFEST == event:getEventCode()) then
        
            local str="发生错误:解析manifest文件失败"
            print(str)
            p_fun(str)
            
        end
        
        if (cc.EventAssetsManagerEx.EventCode.ERROR_UPDATING == event:getEventCode()) then

            local str="发生错误:更新失败"
            print(str)
            p_fun(str)
            
        end
    end

    local dispatcher = cc.Director:getInstance():getEventDispatcher()
    local eventListenerAssetsManagerEx = cc.EventListenerAssetsManagerEx:create(assetsManagerEx, handleAssetsManagerEx)
    dispatcher:addEventListenerWithFixedPriority(eventListenerAssetsManagerEx, 1)
    
    p_fun('检查版本并升级')
    assetsManagerEx:update()
end
级别: 新手上路
UID: 449777
精华: 0
发帖: 14
可可豆: 68 CB
威望: 68 点
在线时间: 147(时)
注册时间: 2015-03-16
最后登录: 2017-08-16
沙发 : 发表于: 2017-07-12 09:11    发自: Web Page
检查下

C++  AppDelegate 里面作了什么
级别: 新手上路
UID: 596925
精华: 0
发帖: 2
可可豆: 11 CB
威望: 11 点
在线时间: 56(时)
注册时间: 2016-11-10
最后登录: 2017-08-19
板凳 : 发表于: 2017-08-13 19:14    发自: Web Page
已经解决了,是菜单文件的问题

project.manifest 的问题
描述
快速回复

关注本帖(如果有新回复会站内信通知您)

验证问题:
苹果公司现任CEO是谁?2字 正确答案:库克

发帖、回帖都会得到可观的积分奖励。查看论坛积分规则

按"Ctrl+Enter"直接提交
    顶部