Cocos2d-x android can't resolved coscos2dx library
Asked Answered
P

4

12

i am starting by macOSX xcode4.5 .
i tried to tutorials.

Using cocos2dx, it completes building of macOSX,
The problem occurred in android sources.

No contents of cocos2dxActivity are described.
so, org.cocos2dx.lib is not other files.

android is not running.

i use ndk-r8. What will be a problem?

Problematic answered 29/9, 2012 at 15:38 Comment(0)
J
29

In cocos2d-x 2.0.3 ...Cocos2d-x Lib java files has been considered as a different project only So import that project in the eclipse

Lets make it Simple

  1. First Import the project in eclipse from this path - cocos2d-2.0-x-2.0.3/cocos2dx/platform/android/java

You will see libcocos2dx project in eclipse ...Keep this project open always otherwise your projects will give error on the syntax of library

  1. Run create-android-project

  2. Now Import the project which you have created and just Run (If you know the concept of isLibrary then that's how they are maintaining it now ..)

Also additional information to run build-native.sh from eclipse only , Right Click Project ->C/C++ Build Uncheck Use Default Build COmmand and add following bash ${workspace_loc:/YourProjName}/build_native.sh NDK_DEBUG=1 V=1

Good Luck ..If any question please feel free to ask

Jamille answered 5/10, 2012 at 9:40 Comment(4)
I tried this, everything is fine, no error but I don't see any libgame.so file n other files generated in libs folder and when I run the project, its giving error as there is no library found in libs folder...Francklin
@Francklin - Try using command prompt ... ./build-native.sh of your project and tell me what error you gettingJamille
oops... sorry, forgot to run build_native.sh... now its working fine... thank uFrancklin
@Francklin : I have edited the answer so that If you run from the eclipse you will be able to build from eclipse only ..If you feel the answer is right please free to Vote for itJamille
P
10

Change

import org.cocos2dx.lib.Cocos2dxActivity;

to

import android.app.Activity;

and change

extends Cocos2dxActivity

to

extends Activity
Princess answered 15/10, 2012 at 8:36 Comment(3)
It actually works, and yet, how can it work?? If the main activity is not a Cocos2dxActivity anymore, and onCreate() does nothing more than super.onCreate(), how is the Cocos2dxActivity created? It looks like (black) magic. Can you explain? Thanks.Destructive
Also interested in that. Does anybody has answer?Interdisciplinary
Looks like hack but has a lot of potential. I was able to build my project on android using the above selected answer though. +1 still.Misquote
J
2

You can copy the folder (cocos2d-2.0-x-2.0.3/cocos2dx/platform/android/java) beside the proj.android folder of your game folder, then import it with the game in eclipse.After importing these 2 projects, open Properties of the game and then add libcocos2dx as library and click apply and build.

i have tries these and works for me

Jolyn answered 29/12, 2012 at 23:12 Comment(0)
P
0

i figure out by myself..

Using cocos2dx 2.0.3 (2012-09-26),
eclipse source:org.cocos2dx.lib is not created.
(org.cocos2dx.lib is created cocos2dxActivity only.
and cocos2dxActivitiy is no contents described.

cocos2dxActivity:
package org.cocos2dx.lib;
mport android.app.Activity;
public class Cocos2dxActivity extends Activity{
}
)

therefore,
Using cocos2dx 2.0.2 (2012-08-30), eclipse build ok.

i can't understand what is problem...

Problematic answered 30/9, 2012 at 23:19 Comment(3)
Same problem here! I'm trying to figure out what the problem with v2.0.3 is. However, v2.0.2 seems to work well.Maniemanifest
anyway, trying to manually add "link source" folder to "%COCOS2DX_ROOT%\cocos2dx\platform\android\java\src" should solve the problem though it is not to be added automatically when execute create-android-project.batManiemanifest
where can i download the cocos2dx 2.0.2, i found new version only on the siteJolyn

© 2022 - 2024 — McMap. All rights reserved.