新建工程之后通过以下批处理加密,是加密lua文件的形式。
@echo off
set DIR=%~dp0
set QUICK_BIN="%QUICK_V3_ROOT%\quick\bin"
cd "%QUICK_BIN%"
set EK=EKkey
set ES=ESkey
call "compile_scripts.bat" -i "%DIR%\src" -o "%DIR%\crypto_src" -m files -ek %EK% -es %ES% -e xxtea_chunk
```
修改 AppDelegate.cpp文件
bool AppDelegate::applicationDidFinishLaunching()
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
initRuntime();
#elif (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
if (_launchMode)
{
initRuntime();
}
#endif
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
Size viewSize = ConfigParser::getInstance()->getInitViewSize();
string title = ConfigParser::getInstance()->getInitViewName();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
extern void createSimulator(const char* viewName, float width, float height, bool isLandscape = true, float frameZoomFactor = 1.0f);
bool isLanscape = ConfigParser::getInstance()->isLanscape();
createSimulator(title.c_str(),viewSize.width,viewSize.height, isLanscape);
#else
glview = cocos2d::GLViewImpl::createWithRect(title.c_str(), Rect(0, 0, viewSize.width, viewSize.height));
director->setOpenGLView(glview);
#endif
director->startAnimation();
}
auto engine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine);
lua_State* L = engine->getLuaStack()->getLuaState();
lua_module_register(L);
// use Quick-Cocos2d-X
quick_module_register(L);
LuaStack* stack = engine->getLuaStack();
#if ANYSDK_DEFINE > 0
lua_getglobal(stack->getLuaState(), "_G");
tolua_anysdk_open(stack->getLuaState());
tolua_anysdk_manual_open(stack->getLuaState());
lua_pop(stack->getLuaState(), 1);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
stack->setXXTEAKeyAndSign("EKkey", strlen("EKkey"), "ESkey", strlen("ESkey"));
//stack->loadChunksFromZIP("res/game.zip");
#endif
//register custom function
//LuaStack* stack = engine->getLuaStack();
//register_custom_function(stack->getLuaState());
#if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
if (_launchMode)
{
startRuntime();
}
else
{
engine->executeScriptFile(ConfigParser::getInstance()->getEntryFile().c_str());
}
#else
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
stack->executeString("require 'main'");
#else
engine->executeScriptFile(ConfigParser::getInstance()->getEntryFile().c_str());
#endif
#endif
return true;
}
```
然后先编译E:\Work2\quickTest\frameworks\runtime-src\proj.android\build_native_release.bat
然后再导入Eclipse编译。
将APK安装到安卓手机之后,就是只有黑屏。将加密模式改成zip的也一样。
是哪里做法不对吗?
logcat:
05-05 12:32:20.299: I/dalvikvm-heap(23690): Grow heap (frag case) to 33.406MB for 1048592-byte allocation
05-05 12:32:20.348: W/System.err(23690): java.io.FileNotFoundException: developerInfo.xml
05-05 12:32:20.348: W/System.err(23690): at android.content.res.AssetManager.openAsset(Native Method)
05-05 12:32:20.348: W/System.err(23690): at android.content.res.AssetManager.open(AssetManager.java:323)
05-05 12:32:20.348: W/System.err(23690): at android.content.res.AssetManager.open(AssetManager.java:297)
05-05 12:32:20.348: W/System.err(23690): at com.anysdk.framework.Wrapper.analysisDeveloperInfo(Unknown Source)
05-05 12:32:20.348: W/System.err(23690): at com.anysdk.framework.PluginWrapper.init(Unknown Source)
05-05 12:32:20.349: W/System.err(23690): at org.cocos2dx.lua.AppActivity.onCreate(AppActivity.java:98)
05-05 12:32:20.349: W/System.err(23690): at android.app.Activity.performCreate(Activity.java:5251)
05-05 12:32:20.349: W/System.err(23690): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-05 12:32:20.349: W/System.err(23690): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2151)
05-05 12:32:20.349: W/System.err(23690): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2236)
05-05 12:32:20.349: W/System.err(23690): at android.app.ActivityThread.access$800(ActivityThread.java:138)
05-05 12:32:20.349: W/System.err(23690): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
05-05 12:32:20.349: W/System.err(23690): at android.os.Handler.dispatchMessage(Handler.java:102)
05-05 12:32:20.349: W/System.err(23690): at android.os.Looper.loop(Looper.java:136)
05-05 12:32:20.349: W/System.err(23690): at android.app.ActivityThread.main(ActivityThread.java:5014)
05-05 12:32:20.349: W/System.err(23690): at java.lang.reflect.Method.invokeNative(Native Method)
05-05 12:32:20.349: W/System.err(23690): at java.lang.reflect.Method.invoke(Method.java:515)
05-05 12:32:20.349: W/System.err(23690): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
05-05 12:32:20.349: W/System.err(23690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
05-05 12:32:20.349: W/System.err(23690): at dalvik.system.NativeStart.main(Native Method)
05-05 12:32:20.450: I/(23690): Attempting to load EGL implementation /system/lib/egl/libEGL_tegra_impl
05-05 12:32:20.458: I/(23690): Loaded EGL implementation /system/lib/egl/libEGL_tegra_impl
05-05 12:32:20.548: I/(23690): Loading GLESv2 implementation /system/lib/egl/libGLESv2_tegra_impl
```
如果不加密,倒是可以正常显示Hello World