Cocos2dx: dlopen failed: cannot find the "atof" character referenced by "libcocos2dcpp.so"

I'm trying to run my cocos2d-x game on Android devices, it works fine on Android 2.5 (candy), but crashes on lower versions of Android. I get the following error:

02-25 10: 41: 09.787: E / ResourceType (18090): 0x5ad385b8: Failed to execute ResTable :: remove () cookie = 0x3, and not the last table. mHeaders.size () = 4. Warning about spontaneous crashes when starting the garbage collector. 02-25 10: 41: 09.797: E / asset (18090): error deleting runtime resource (cookie 0x3) 02-25 10: 41: 09.797: I / asset (18090): problem with deleting all runtime resources 02- 25 10: 41: 09.817: D / dalvikvm (18090): trying to download lib / data / app-lib / com.example.game-2 / libcocos2dcpp.so 0x418c9ce8 02-25 10: 41: 09.817: E / dalvikvm (18090 ): dlopen ("/data/app-lib/com.example.game-2/libcocos2dcpp.so") failed: dlopen failed: could not find the symbol "atof" referenced by "libcocos2dcpp.so" .. . 02-25 10: 41: 09.817: W / dalvikvm (18090): Ljava / lang / UnsatisfiedLinkError exception; throws when initializing Lcom / example / game / game; 02-25 10: 41: 09.817: W / dalvikvm (18090): init class failed in a call to newInstance (Lcom / example / game / game;) 02-25 10: 41: 09.817: D / AndroidRuntime (18090): turning off the virtual machines 02-25 10: 41: 09.817: W / dalvikvm (18090): threadid = 1: exit the thread with an uncaught exception (group = 0x415af8b0) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): FATAL EXCEPTION : main 02-25 10: 41: 09.827: E / AndroidRuntime (18090): java.lang.UnsatisfiedLinkError: dlopen failed: could not find the "atof" symbol referenced by "libcocos2dcpp.so" ... 02-25 10 : 41: 09.827: E / AndroidRuntime (18090): as an example java.lang.Runtime.loadLibrary (Runtime.java{61) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): in java.lang.System .loadLibrary (System.javaโˆ—25) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at com.example.game.game. (Game.java:126) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): on java.lang.Class.newInstanceImpl (native method) 02-25 10: 41: 09.827: E / AndroidRuntime (18090) : at java.lang.Class.newInstance (Class.java:1130) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at android.app.Instrumentation.newActivity (Instrumentation.java:1061) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2178) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at android.app.ActivityThread .handleLaunchActivity (ActivityThread.java:2311) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at android.app.ActivityThread.access $ 600 (ActivityThread.java:149) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1293) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): on android.os.Handler.dispatchMessage (Handler .java: 99) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): on andr oid.os.Looper.loop (Looper.java:137) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at android.app.ActivityThread.main (ActivityThread.java:5214) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at java.lang.reflect.Method.invokeNative (native method) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): in java.lang.reflect.Method. invoke (Method.javaPoint25) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:739) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java<55) 02-25 10: 41: 09.827: E / AndroidRuntime (18090): in dalvik.system .NativeStart.main (native method).

I am using cocos2d-x v2.2.6, Eclipse-Luna and android NDK r10d.

+5
source share
5 answers

Try to add

APP_PLATFORM := android-19 

as the first line in your Appication.mk application

+5
source

Try using Android NDK r9d.For cocos2dx, Android NDK r9d is good for working.

+1
source

(I know this duplicates the previous answer of m0mus in the proposed solution, but I think a more complete explanation helps.)

Google has moved some of the standard C library functions, such as atof (), from built-in functions to header files for regular functions. Recent NDKs will by default create .so, which is only compatible with the latest Android devices that have the atof () function in the deviceโ€™s standard C library (libc.so). This means that if you run the library on an older device that has an older version of the C library, you will get an error loading the dll, since the expected atof () function will not exist.

You tried to install this in your Application.mk application:

 APP_PLATFORM := android-9 

This will force the ndk compiler to create code compatible with older versions of Android.

You can also try downgrading the NDK installation to version 10b (this version precedes the change when atof was moved from the built-in libc part to avoid the problem completely).

+1
source

I understood correctly, my current env is cocos2d-x 3.3, NDKr10d, ADT package (update24)

  log("This is A TEst for ATOF ,%f ", std::atof("1.0")); 

Try to include the characters _GXX_EXPERIMENTAL_CXX0X_ in the characters, leave the values โ€‹โ€‹empty

0
source

In Android Studio, you must manually configure the NDK. Go to the local.properties file of your application and configure the ndk.dir value in the ndk directory.

0
source

Source: https://habr.com/ru/post/1214134/


All Articles