Can't launch AndroidStudio project: name 'default' not found

I created project using Cocos2d-x (http://www.cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android)
There was: name ‘default’ not found (1st screenshot). Then I changed SDK version in build.gradile, and there appeared another problem (2nd screenshot). What to do now ?


It seems :slight_smile: itself explaining - using wrong gradle version?:smiley: Also it’s not clear which gradle file build opened and why dependecies are empty in this case.

I created a new project, now I have this when trying to launch on AVD:

01-17 22:59:18.283 1394-1394/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xb50b6180)
01-17 22:59:18.293 1394-1394/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Couldn’t load cocos2dcpp: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:288)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:303)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

maybe your project not compiled thru console and you trying to launch it?

Ok, how should I create and prepare project to use it in AndroidStudio (what commands) ?

If using cocos console:

create project:
cocos new -l cpp -p com.test.studio TestStudio

compile & run project:
cocos run -p android -j 4 --android-studio

rm failed for -f, Read-only file system
Using AVD Android 4.0.3, build was successful.

I did something on Ubuntu:
sudo dpkg --add-architecture i386
and
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386

now I have the initial problem (name ‘default’ not found) - when trying to run imported project, and this problem (see screenshot) when trying to:
cocos run -p android -j 4 --android-studio

I can tell you straightaway from that screenshot that your android studio project hasn’t loaded correctly.

I would suggest the following steps:

  1. Create a brand new project using the (cocos new command)
  2. This step is important to do correctly. Open android studio and click “open an existing Android Studio Project”. Then browse to your project root and select the proj.android-studio folder. If you did this correctly then you should see a project with the project name you used. Under the projects list. e.g. SomeGame
  3. In console cd to the root of your project, for example Somegame/
  4. Compile the code (cocos compile -p android -m debug --android-studio)
  5. Open the build.gradle file that matches the name of your project. Set your target/minimum/compile android version etc. Make sure you have all the android sdk’s installed.
  6. Click the run button which will resync gradle and attempt to deploy the app to a target device.

After
cocos compile -p android -m debug --android-studio
I’ve got this:
.cocos-project.json is not found.

Navigate to project folder, it seems you trying to run compile outside project folder

I did:
~/AndroidStudioProjects/proj.android-studio$ cocos compile -p android -m debug --android-studio
/home/u990/AndroidStudioProjects/proj.android-studio/.cocos-project.json is not found.

no, one level up you should be. ~/AndroidStudioProjects/

The same thing

ok, then just create this file in root folder ~/AndroidStudioProjects/: .cocos-project.json and put inside

{
    "engine_version": "cocos2d-x-3.9", 
    "project_type": "cpp"
}

If you want I can try to help you thru teamviewer :slight_smile:

Something wrong with NDK, how to check if it binded with Cocos properly ?

$ cocos compile -p android -m debug --android-studio
Building mode: debug
Using Android Studio project : /home/u990/AndroidStudioProjects/proj.android-studio
Android platform not specified, searching a default one...
running: '/home/u990/Android/Sdk/tools/android update project -t android-10 -p /home/u990/AndroidStudioProjects/proj.android-studio/app'

Updated project.properties
Updated local.properties
No project name specified, using Activity name 'AppActivity'.
If you wish to change it, edit the first line of build.xml.
Added file /home/u990/AndroidStudioProjects/proj.android-studio/app/build.xml
Added file /home/u990/AndroidStudioProjects/proj.android-studio/app/proguard-project.txt
Building native...
NDK build mode: debug
NDK_TOOLCHAIN_VERSION: 4.9
running: '/home/u990/android-ndk-r10e/ndk-build -C /home/u990/AndroidStudioProjects/proj.android-studio/app -j2 NDK_MODULE_PATH=/home/u990/AndroidStudioProjects/proj.android-studio/../cocos2d:/home/u990/AndroidStudioProjects/proj.android-studio/../cocos2d/cocos:/home/u990/AndroidStudioProjects/proj.android-studio/../cocos2d/external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1'

*Android NDK: WARNING: Ignoring unknown import directory: /home/u990/AndroidStudioProjects/proj.android-studio/../cocos2d    
Android NDK: WARNING: Ignoring unknown import directory: /home/u990/AndroidStudioProjects/proj.android-studio/../cocos2d/cocos    
Android NDK: WARNING: Ignoring unknown import directory: /home/u990/AndroidStudioProjects/proj.android-studio/../cocos2d/external    
Android NDK: WARNING: Ignoring unknown import directory: jni/../../../cocos2d    
Android NDK: WARNING: Ignoring unknown import directory: jni/../../../cocos2d/external    
Android NDK: WARNING: Ignoring unknown import directory: jni/../../../cocos2d/cocos    
Android NDK: jni/Android.mk: Cannot find module with tag '.' in import path    
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?    
Android NDK: The following directories were searched:    
Android NDK:         
make: Entering directory `/home/u990/AndroidStudioProjects/proj.android-studio/app'
jni/Android.mk:30: *** Android NDK: Aborting.    .  Stop.
make: Leaving directory `/home/u990/AndroidStudioProjects/proj.android-studio/app'
Error running command, return code: 2.*

Have you configured your environment, ant, NDK, python and so on? http://www.cocos2d-x.org/wiki/How_to_set_up_the_android_cocos2d-x_development_environment_on_Windows_7

http://www.multigesture.net/articles/how-to-setup-cocos2d-x-windows-and-android/

I checked, they are ok:

$ ./setup.py

Setting up cocos2d-x…
->Check environment variable COCOS_CONSOLE_ROOT
->Search for environment variable COCOS_CONSOLE_ROOT…
->COCOS_CONSOLE_ROOT is found : /home/u990/cocos2d-x-3.9/tools/cocos2d-console/bin

->Check environment variable COCOS_TEMPLATES_ROOT
->Search for environment variable COCOS_TEMPLATES_ROOT…
->COCOS_TEMPLATES_ROOT is found : /home/u990/cocos2d-x-3.9/templates

->Configuration for Android platform only, you can also skip and manually edit “/home/u990/.bashrc”

->Check environment variable NDK_ROOT
->Search for environment variable NDK_ROOT…
->NDK_ROOT is found : /home/u990/android-ndk-r10e/

->Check environment variable ANDROID_SDK_ROOT
->Search for environment variable ANDROID_SDK_ROOT…
->ANDROID_SDK_ROOT is found : /home/u990/Android/Sdk/

->Check environment variable ANT_ROOT
->Search for environment variable ANT_ROOT…
->ANT_ROOT is found : /usr/share/ant/bin

Please execute command: “source /home/u990/.bashrc” to make added system variables take effect

u990@u990-Inspiron-3542:~/cocos2d-x-3.9$ source /home/u990/.bashrc

Why is proj.android-studio in /AndroidStudioProjects/?

What is the folder structure of this project. Can you print screen the folder window for /AndroidStudioProjects/

1 Like

xmm, what environment it is? Is it linux?

Please execute command: “source /home/u990/.bashrc” to make added system variables take effect