Unfortunately hellocpp has stopped

Desperate.

I tried compiling from the command line and (apparently) it looks OK, but when I load the APK to my phone (Android 4.3) it fails again.


D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.android>ant debug install
Buildfile: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.android\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 22.3.0
 [checkenv] Installed at D:\Android\sdk

-setup:
     [echo] Project Name: HelloWorld
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.2
     [echo] Resolving Build Target for HelloWorld...
[gettarget] Project Target:   Android 2.3.3
[gettarget] API level:        10
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.android
\bin\rsObj
    [mkdir] Created dir: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.android
\bin\rsLibs
    [mkdir] Created dir: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.android
\bin\dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for HelloWorld...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
[dependency] API<=15: Adding annotations.jar to the classpath.
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 2 source files to D:\cocos2d-x-3.0beta2\samples\Cpp\HelloC
pp\proj.android\bin\classes

-post-compile:

-obfuscate:

-dex:
      [dex] input: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.android\bin\c
lasses
      [dex] input: D:\Android\sdk\tools\support\annotations.jar
      [dex] Pre-Dexing D:\Android\sdk\tools\support\annotations.jar -> annotatio
ns-9b8748c2df4ef1fdc806cadcfb06edb0.jar
      [dex] Converting compiled files and external libraries into D:\cocos2d-x-3
.0beta2\samples\Cpp\HelloCpp\proj.android\bin\classes.dex...
       [dx] Merged dex A (6 defs/1,8KiB) with dex B (2 defs/1,1KiB). Result is 8
 defs/2,8KiB. Took 0,0s

-crunch:
   [crunch] Crunching PNG Files in source dir: D:\cocos2d-x-3.0beta2\samples\Cpp
\HelloCpp\proj.android\res
   [crunch] To destination dir: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.
android\bin\res
   [crunch] Processing image to cache: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCp
p\proj.android\res\drawable-hdpi\icon.png => D:\cocos2d-x-3.0beta2\samples\Cpp\H
elloCpp\proj.android\bin\res\drawable-hdpi\icon.png
   [crunch]   (processed image to cache entry D:\cocos2d-x-3.0beta2\samples\Cpp\
HelloCpp\proj.android\bin\res\drawable-hdpi\icon.png: 67% size of source)
   [crunch] Processing image to cache: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCp
p\proj.android\res\drawable-ldpi\icon.png => D:\cocos2d-x-3.0beta2\samples\Cpp\H
elloCpp\proj.android\bin\res\drawable-ldpi\icon.png
   [crunch]   (processed image to cache entry D:\cocos2d-x-3.0beta2\samples\Cpp\
HelloCpp\proj.android\bin\res\drawable-ldpi\icon.png: 0% size of source)
   [crunch] Processing image to cache: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCp
p\proj.android\res\drawable-mdpi\icon.png => D:\cocos2d-x-3.0beta2\samples\Cpp\H
elloCpp\proj.android\bin\res\drawable-mdpi\icon.png
   [crunch]   (processed image to cache entry D:\cocos2d-x-3.0beta2\samples\Cpp\
HelloCpp\proj.android\bin\res\drawable-mdpi\icon.png: 53% size of source)
   [crunch] Crunched 3 PNG files to update cache

-package-resources:
     [aapt] Creating full resource package...
     [aapt]     (skipping file '.gitignore' due to ANDROID_AAPT_IGNORE pattern '
.*')

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuil
der run.
[apkbuilder] Creating HelloWorld-debug-unaligned.apk and signing it with a debug
 key...

-post-package:

-do-debug:
 [zipalign] Running zip align on final apk...
     [echo] Debug Package: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.andro
id\bin\HelloWorld-debug.apk
[propertyfile] Creating new property file: D:\cocos2d-x-3.0beta2\samples\Cpp\Hel
loCpp\proj.android\bin\build.prop
[propertyfile] Updating property file: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCp
p\proj.android\bin\build.prop
[propertyfile] Updating property file: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCp
p\proj.android\bin\build.prop
[propertyfile] Updating property file: D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCp
p\proj.android\bin\build.prop

-post-build:

debug:

install:
     [echo] Installing D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.android\b
in\HelloWorld-debug.apk onto default emulator or device...
     [exec]     pkg: /data/local/tmp/HelloWorld-debug.apk
     [exec] Success
     [exec] 231 KB/s (1137168 bytes in 4.799s)

BUILD SUCCESSFUL
Total time: 12 seconds

D:\cocos2d-x-3.0beta2\samples\Cpp\HelloCpp\proj.android>

@ptolomeo
You can run build/android-build.py to generate .so or .apk directly.
Please refer to the script for more detail information.

1 Like

@zhangxm wrote:

@ptolomeo
You can run build/android-build.py to generate .so or .apk directly.
Please refer to the script for more detail information.

I launch android-build.py and ends OK,

user@W8 /cygdrive/d/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.android
$ ./build_native.sh
NDK_ROOT = /cygdrive/d/Android/android-ndk-r9c
COCOS2DX_ROOT = /cygdrive/d/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.android/..
/../../..
APP_ROOT = /cygdrive/d/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.android/..
APP_ANDROID_ROOT = /cygdrive/d/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.android

Using prebuilt externals
++ /cygdrive/d/Android/android-ndk-r9c/ndk-build -C /cygdrive/d/cocos2d-x-2.2.2/
samples/Cpp/HelloCpp/proj.android NDK_MODULE_PATH=/cygdrive/d/cocos2d-x-2.2.2/sa
mples/Cpp/HelloCpp/proj.android/../../../..:/cygdrive/d/cocos2d-x-2.2.2/samples/
Cpp/HelloCpp/proj.android/../../../../cocos2dx/platform/third_party/android/preb
uilt
make: Entering directory '/cygdrive/d/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.
android'
Android NDK: WARNING: APP_PLATFORM android-9 is larger than android:minSdkVersio
n 8 in ./AndroidManifest.xml
Android NDK: WARNING:/cygdrive/d/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.andro
id/../../../../cocos2dx/Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignor
ed for static libraries
[armeabi] Install        : libhellocpp.so => libs/armeabi/libhellocpp.so
make: Leaving directory '/cygdrive/d/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.a
ndroid'

user@W8 /cygdrive/d/cocos2d-x-2.2.2/samples/Cpp/HelloCpp/proj.android
$

I get now a different error:

03-04 14:49:46.968: W/dalvikvm(373): threadid=9: thread exiting with uncaught exception (group=0x40015560)
03-04 14:49:46.988: E/AndroidRuntime(373): FATAL EXCEPTION: GLThread 10
03-04 14:49:46.988: E/AndroidRuntime(373): java.lang.IllegalArgumentException: No configs match configSpec
03-04 14:49:46.988: E/AndroidRuntime(373): 	at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:763)
03-04 14:49:46.988: E/AndroidRuntime(373): 	at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:919)
03-04 14:49:46.988: E/AndroidRuntime(373): 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1264)
03-04 14:49:46.988: E/AndroidRuntime(373): 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
03-04 14:49:50.448: I/Process(373): Sending signal. PID: 373 SIG: 9

FINALLY, IT WORKED

The last error was it seems that the emulator didn’t have openGL support, but I installed the resulting APK on my mobile and it worked OK.
I think I am going to erase everything and start a new installation documenting it step by step for future newbies.

Thank you all for your help and support. Now I will try other samples and even the Cocos2d-x v.3.beta and now that it works I will take a look at the code.

I suggest not using simulator on Android.

It works for me after a week! Thank you!