Cannot create project for android using create-android-project.bat

Hello ,

I am trying to create an android project using create-android-project.bat in cocos2d-1.0.1-x-0.13.0-beta .

I have edited the following lines of create-android-project.bat :
set CYGBIN=C:setANDROIDTOOLS=D:~~sdk_r11-windows-Api\android-sdk_r11-windows-Api\android-sdk_r11-windows\android-sdk-windows\tools
set _NDKROOT=D:~~ndk-r7c-windows\android-ndk-r7c

Then I have run this file,
It asks me for package name:org.cocos2d.android
project name:test_android
id : 7 (android 2.2)

Message on console :

Create android project
Created project directory: D:2d-1.0.1-x-0.13.0-beta\test_android
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\src\org\cocos2dx\e
xample
Added file D:2d-1.0.1-x-0.13.0-beta\test_android\src\org\cocos2dx\exampletest_android.java
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\res
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\bin
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\libs
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\res\values
Added file D:2d-1.0.1-x-0.13.0-beta\test_android\res\values\strings.xml
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\res\layout
Added file D:2d-1.0.1-x-0.13.0-beta\test_android\res\layout\main.xml
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\res\drawable-hdpi
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\res\drawable-mdpi
Created directory D:2d-1.0.1-x-0.13.0-beta\test_android\res\drawable-ldpi
Added file D:2d-1.0.1-x-0.13.0-beta\test_android\AndroidManifest.xml
Added file D:2d-1.0.1-x-0.13.0-beta\test_android\build.xml
Added file D:2d-1.0.1-x-0.13.0-beta\test_android\proguard.cfg
using lua
using box2d
/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/template/android/gamemk.sh: line 33: /cy
gdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/android/jni/Android.mk: Permis
sion denied
sed: can’t read /cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/android/src
/org/cocos2dx/application/ApplicationDemo.java: Permission denied
Press any key to continue . . .

Then I have tried to enter into /cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/android
and run the /build_native.sh

It gives me errors such as :
cp: cannot open `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/Resources/app.config.txt’ for reading: Permission denied
cp: cannot open `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/Resources/app.icf’ for reading: Permission denied
cp: cannot open `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/Resources/CloseNormal.png’ for reading: Permission denied
cp: cannot open `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/Resources/CloseSelected.png’ for reading: Permission denied
cp: cannot open `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/Resources/development.icf’ for reading: Permission denied
cp: cannot access `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/Resources/fonts’: Permission denied
cp: cannot open `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/Resources/HelloWorld.png’ for reading: Permission denied
Using prebuilt externals
make: Entering directory `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/android’
/cygdrive/d/E/android-ndk-r7c-windows/android-ndk-r7c/build/core/add-application.mk:49: jni/Application.mk: Permission denied
/cygdrive/d/E/android-ndk-r7c-windows/android-ndk-r7c/build/core/setup-toolchain.mk:147: jni/Android.mk: Permission denied
make: Leaving directory `/cygdrive/d/cocos2d-1.0.1-x-0.13.0-beta/test_android/android’

I know these errors are because the first step is not successful. Please give me solution to
this problem .Thank you very much.

it seems that your os is win7. right?

i think with XP, it will okay
but under win7, problem occurs as you see it.

it’s only permission problem,
my solutions was,

  1. execute cywin console, and change dir to your cocos2dx/project.
  2. “chmod 0755 -Rf .”
  3. try again, “./build_native.sh”

is that okay?

I understand that cocos2d-x have some issues with NTFS drive with permissions,Hence I have used a FAT32 formatted External hard drive to create a project .The project is created successfully .I have created a project in eclipse by selecting create from existing source and selected the android folder in the project directory created. There were some errors in the manifest. I have resolved them. And then when I run that project in an emulator a force close occurs. I think using ndk is not a better way to create apps in android. what do u say ? Because everything is cumbersome.

How do u run projct in an emulator?
as you said and as I understand you have a compiler error caused by file permission.
so I said you should change file permission from 0400 to 0755.
sorry if I misunderstood.

SEUNG-HYUN LEE ,

Thanks for your suggestions. I have changed to a FAT file system and placed cocos2d-x on it, created an android helloworld project and run build_native.sh present in android folder .
The project is successfully running on an android device.

The classes folder contained similar files that were generated in win32 project and hence I copy pasted the 4 files i.e AppDelegate.h,AppDelegate.cpp,helloWorld.h and helloWorld.cpp from a simple box2d project created in win32. And also copied the blocks.png into Resources folder. And issued the build_native.sh once again. But this time some errors have generated . I don’t have knowledge about jni .Isn’t this the correct procedure for working with . Please give me answer

In case you wish to make a project name “MyHelloWorld”

  1. execute “create-android-project.bat” with project name “MyHelloWorld”
  2. for your convience make win32 project as below
    I recommend you to execute install-templates-msvc.bat under cocos2d-x root folder.
    after do this create new project in MSvc, and you can see “Cocos2d-x” new project selection.
    input your new project name “MyHelloWorld” somewhere else cocos2d-x folder. it’s just temporary.
    you can find “proj.win32” or “win32” folder, just copy this folder to Cocos2d-x/MyHelloWorld.
    open cocos2dx soultion file “cocos2d-win32.vc2010.sln” or if your msvc is 2008 “cocos2d-win32.vc2008.sln”,
    and add existing project(MyHelloWorld.win32.vcxproj or MyHelloWorld.win32.vcproj in vc2008) to solution.
    compile and run in msvc(usally F5 key), you will see simple “HelloWorld” result.

and if you want to add new resource file, just put it under “Resource” folder.
new source files are should be exist in “Classes” folder.

To build android apk files,

  1. open your “jni/Android.mk” file and you will see,

    LOCAL_SRC_FILES := helloworld/main.cpp
    …/…/Classes/AppDelegate.cpp
    …/…/Classes/ABC.cpp
    …/…/Classes/DEF.cpp

just add new source files.

ok, all is done
(Android SDK/NDK, cygwin path must be set in build_native.sh)

just run build_native.sh and if no errors native .so file is made.

  1. open your eclipse, and import exist project and RU~~N.

SEUNG-HYUN LEE wrote:

it seems that your os is win7. right?
>
i think with XP, it will okay
but under win7, problem occurs as you see it.
>
it’s only permission problem,
my solutions was,
>

  1. execute cywin console, and change dir to your cocos2dx/project.
  2. “chmod 0755 -Rf .”
  3. try again, “./build_native.sh”
    >
    is that okay?

Thanks, this worked. Except I chmod’d the whole cocos2d-x directory and ran the batch file, as the project directory is created using the .batch file

@ysrikanth2011 thank you
my problem was solved with your solution

Awesome solve my same problem in cocos 2.1.5

Thank You very much