create-android-project.bat not working

Hi,

I’ve download cocos2d-2.1rc0-x-2.1.3 and edited create-android-project.bat to set some variables:

set CYGBIN=C:setANDROIDTOOLS=C:~~bundle-windows-x86-20130219\sdk\tools
set _NDKROOT=C:~~ndk-r8e

When I run the batch I get this output:

X:\cocos2d-2.1rc0-x-2.1.3>create-android-project.bat
Please enter your package path. For example: org.cocos2dx.example:com.test
Please enter your project name:Test
"Now cocos2d-x suppurts Android 2.1-update1, 2.2, 2.3 & 3.0"
"Other versions have not tested."
Available Android targets:
----------
id: 1 or "android-17"
     Name: Android 4.2.2
     Type: Platform
     API level: 17
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, W
XGA720, WXGA800, WXGA800-7in
     ABIs : armeabi-v7a
Please input target id:1
Create android project
Create Android project inside proj.android
Created project directory: X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\src\com\test
Added file X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\src\com\test\Test.java
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\bin
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\libs
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res\values
Added file X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res\values\strings.xml
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res\layout
Added file X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res\layout\main.xml
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res\drawable-xhdpi

Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res\drawable-hdpi
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res\drawable-mdpi
Created directory X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\res\drawable-ldpi
Added file X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\AndroidManifest.xml
Added file X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\build.xml
Added file X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\proguard-project.txt
Resolved location of library project to: X:\cocos2d-2.1rc0-x-2.1.3\cocos2dx\plat
form\android\java
Updated project.properties
Updated local.properties
Updated file X:\cocos2d-2.1rc0-x-2.1.3\Test\proj.android\proguard-project.txt
/cygdrive/x/cocos2d-2.1rc0-x-2.1.3/template/android/gamemk.sh: line 32: /cygdriv
e/x/cocos2d-2.1rc0-x-2.1.3/Test/proj.android/jni/Android.mk: Permission denied
sed: can't read /cygdrive/x/cocos2d-2.1rc0-x-2.1.3/Test/proj.android/src/org/coc
os2dx/hellocpp/HelloCpp.java: Permission denied
rm: cannot remove `/cygdrive/x/cocos2d-2.1rc0-x-2.1.3/Test/proj.android/src/org/
cocos2dx/hellocpp': Permission denied
Press any key to continue . . .

X:\cocos2d-2.1rc0-x-2.1.3>

Some folders and files are getting strange permissions, which make them un-editable and undeletable.

Is this a known issue?

Thanks,

Andre

i have no idea what happened to you,but i suggest you that right click “create-android-project.bat” and run it as administrator.hope it works.:smiley:

lu bai wrote:

i have no idea what happened to you,but i suggest you that right click “create-android-project.bat” and run it as administrator.hope it works.:smiley:

It works, thanks. It would never cross my mind that the batch needs administrator privileges.

Spoke too soon… It seems the project is created, but the permissions are wrong. I have to edit them to add my user with full control to the project directory and its children.

Even then, when the project is imported into Eclipse it has some errors:

Description Resource    Path    Location    Type
The import org.cocos2dx.lib cannot be resolved  Test.java   /Test/src/com/leiradella/test   line 26 Java Problem
Cocos2dxActivity cannot be resolved to a type   Test.java   /Test/src/com/leiradella/test   line 33 Java Problem
Cocos2dxActivity cannot be resolved to a type   Test.java   /Test/src/com/leiradella/test   line 30 Java Problem
error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon').    AndroidManifest.xml /Test   line 10 Android AAPT Problem

I took a look at the proj.android\src\org\cocos2dx folder and it’s empty. I was expecting to find a lib subfolder and Cocos2dxActivity.java in it. I then copied everything under cocos2dx\platform\android\java\src\org and, after fixing the icon error, I was able to build and run the project.

However, the application fails to run in the emulator, and LogCat is showing some link errors which lead me to believe that the project is still broken…

Note: I get an error when I try to run create-android-project.bat as Administrator:

Error!!! You should run it under cocos2dx root

What I did was running cmd.exe as Administrator, navigating to cocos2d-x root directory and then executing the batch file.

Cheers,

Andre

Is there any documentation on how I can, after setting up an Android project in Eclipse, manually copy the necessary files to build a cocos2d-x application?

Never mind. I really should stop multitasking and follow the documentation. After executing build_native.sh the project worked.