"Reprint" Cocos2d-x-3.0beta on Android Pack error problem

Source: Internet
Author: User
Tags gz file android sdk manager

Demo Cocos2d-x-3.0beta on ANDROID1 Environment preparation
    • Cocos2d-x: V3.0beta
    • Android sdk:revision 22.3 (SDK Tools)
    • Android Ndk:revision 9c
    • Apache ant:1.9.3 Released
    • python:2.7.6

Android SDK Manager:

PS: This time I have promoted the environment to the newest state, except Java still is jdk-7u45.

1.1 Prerequisite Instructions
    1. First, the following are all operating on the Win7 32 bit.
    2. Second, it is assumed that the above environment is installed on the e: disk.
1.2 Configuring environment variables
ANDROID_SDK_ROOT = E:\android-sdk-windowsNDK_ROOT = E:\android-ndk-r9cANT_HOME = E:\apache-ant-1.9.3PY_HOME = E:\Python27JAVA_HOME = C:\Program Files\Java\jdk1.7.0_45NDK_TOOLCHAIN_VERSION = 4.8

ANDROID_SDK_ROOTToo long, you can set a different:

SDK_ROOT = E:\android-sdk-windows

And then:

Path += %SDK_ROOT%\tools;%SDK_ROOT%\platform-tools;%NDK_ROOT%;        %ANT_HOME%\bin;%PY_HOME%;%PY_HOME%\Scripts;%JAVA_HOME%\bin;...

PS:,, ANDROID_SDK_ROOT NDK_ROOT NDK_TOOLCHAIN_VERSION after running android-build.py , build_native.py will be used.

2 Compiling hellocpp examples

Location: E:\cocos2d-x-3.0beta\samples\Cpp\HelloCpp\

2.1 android-build.py

Location: E:\cocos2d-x-3.0beta\build\android-build.py

Open cmd to its directory location, and then:

Ps:win7 can select "Open command Window Here" or "w+enter" directly in its directory "Ctrl+shift+right click".

13 -b debug hellocpp

Then, into the Hellocpp engineering position, namely E:\cocos2d-x-3.0beta\samples\Cpp\HelloCpp\proj.android .

After connecting the phone, run the ant installd install compiled debug version.

3 Do you want to create a hellococos? 3.1 create_project.py Create Project

Location: E:\cocos2d-x-3.0beta\tools\project-creator\create_project.py

Run directly create_project.py , and a high-end TK interface will emerge.

projectName: HelloCocospackageName: org.join.hello.cocosprojectPath: E:/language: cpp

Create, and then E:\HelloCocos\ is our project.

3.2 build_native.py Compiling so

Location: E:\HelloCocos\proj.android\build_native.py

Enter the Hellococos project location, ie E:\HelloCocos\proj.android .

build_native.pyThe compile so is started.

3.3 Ant compiling Android project

First, you need to add Android Library engineering support for COCOS2DX on Android platform for Java Lib code.

Location: E:\HelloCocos\cocos2d\cocos\2d\platform\android\java\

// 添加android library工程支持android update lib-project -t android-13 -p .

Then, go back to the Hellococos project location and add Android engineering support for it.

// 添加android工程支持android update project -p . -t android-13// 编译并安装(debug版)ant debug install

See: Managing Projects from the Command line.

4 Other Instructions 4.1 Why is Android platform selected 13, that is, Android 3.2?

Build project (including samples) AndroidManifest.xml , the activity of the configchanges is set by default Smallestscreensize, and it is supported in API 13. See:<activity>.

Or, remove the settings to select the lower version. Otherwise, there will be the following error:

[AAPT]E:\cocos2d-x-3.0beta\samples\cpp\testcpp\proj.android\bin\androidmanifest. xml: Error: error:string types not allowed (@ ' configchanges ' with value ' Orientation|screen Size|smallestscreensize '). BUILD FAILEDE:\android-sdk-windows\tools\ant\build.  XML:653:the following error occurred while executing this line  :E:\android-sdk-windows\tools\ant\ Build. xml:698: null returned: 1            
How does the 4.2 cocos2dx library depend?

Android Engineering also needs to rely on COCOS2DX's Java lib code, which is project.properties based on the android.library.reference.1 dependency. See: Referencing a Library Project.

In addition, you need to add Android Library engineering support to COCOS2DX's Java LIB Code first (step 3.3). Otherwise, you will encounter the following error when you execute ant:

BUILD FAILEDE:\android-sdk-windows\tools\ant\build.xml:601: The following error occurred while executing this line:E:\cocos2d-x-3.0beta\cocos\2d\platform\android\java\build.xml:46: sdk.dir is missing. Make sure to generate local.properties using ‘android update project‘ or to inject it through an env var
4.3 ndk_toolchain_version=4.8, used to specify the compilation chain for GCC 4.8.

Location: E:\android-ndk-r9c\toolchains\arm-linux-androideabi-4.8\

This needs to be set to the environment variable, run android-build.py , and build_native.py will be detected. Otherwise, it can also be added Application.mk (if you compile from the command line).

Then, specifying gcc4.8 is due to the introduction of the C++11 feature in COCOS2DX 3.0. For c++11 features, you can read the following:

    • C + + Primer, 5th Edition, Chinese version already available.
    • C++11 FAQ, Chinese translation already available.
4.4 Private Key Signature

ant.properties, add Key.store, Key.alias properties.

If you want to avoid password input, you can increase the Key.store.password, Key.alias.password properties.

key.store=keystore路径key.alias=keyalias名称key.store.password=keystore密码key.alias.password=keyalias密码

See: Signing Your applications.

There is no need for ps:proguard confusion.

5 Command-line compilation

Note: Resources\ the inside of something needs to be manually copied proj.android\assets\ inside. Also, for the testcpp example, delete Images\ the. gz file.

"Reprint" Cocos2d-x-3.0beta on Android Pack error problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.