2
\$\begingroup\$

What I am trying to do today is to import a full project to Android, but no tutorials are available for that that I have seen. My approach was to create a new android project, copy all the classes and resources in the folders and calling ./build_native.sh but I get an error because most of the files are not being included in the project. I tried opening the Android.mk and I can see why "LOCAL_SRC_FILES := AppDelegate.cpp \ HelloWorldScene.cpp" are the only files linked.

Should I manually modify the make file or can it be automated by some way I don't know?

Thank you.

UPDATE:

I manually added all files and headers to the make file and I get errors linking Box2D or cocosdenshion libraries.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

just add every file with cpp extention in your project into "LOCAL_SRC_FILES list", and of course if you don't have a file named "HelloWorldScene.cpp", remove it from that list.

UPDATE

I'm not sure this time but I'm guessing from what I can see inside test project: there are two file with name "android.mk"

  1. jni\android.mk
  2. jni\tests\android.mk (or equivalent address based on your project name)

in the first file add

subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \
    Box2D \
    cocos2dx \
    CocosDenshion/android \
    ))

note that $(LOCAL_PATH)/../../../ should point at cocos2dx root folder change it if it is not correct

and in the second file this line should do the trick

    LOCAL_SHARED_LIBRARIES := cocosdenshion_shared box2d_shared
\$\endgroup\$
6
  • \$\begingroup\$ I just added an update: UPDATE: I manually added all files and headers to the make file and I get errors linking Box2D or cocosdenshion libraries. \$\endgroup\$ Mar 19, 2012 at 13:12
  • \$\begingroup\$ @EfEs updated my answer. \$\endgroup\$
    – Ali1S232
    Mar 19, 2012 at 14:13
  • \$\begingroup\$ I did test it, it correctly imports the libraries but I can't say it is the answer because I still get a lot of project-related problems, sorry :( \$\endgroup\$ Mar 19, 2012 at 14:42
  • \$\begingroup\$ I tried using another build_native from previous version and everything looks like working, but I get realtime problems when calling System.loadLibrary("cocos2d"); If you want to help send me a message or we can talk in chat. Thanks. \$\endgroup\$ Mar 19, 2012 at 14:51
  • \$\begingroup\$ The problem was that someone else had updated the libraries in the SVN under a different name. Question closed. \$\endgroup\$ Apr 1, 2012 at 1:22
0
\$\begingroup\$

The problem was the library naming, as the standard Android project has the library names as "cocos2d" (my project had cocos2dx) and "cocosdenshion" (case sensitive into "CocosDenshion")

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .