Open minjisong7334 opened 7 years ago
I got some similar errors when building just now from a clean repo clone, but I was able to resolve it by making sure all my libraries were up to date. The easiest way to do this would be to open up the SDK manager (if you have Android Studio installed can go to Tools > Android > SDK Manager), and then click SDK Tools and update whatever updates you need to install, and try building again. If that doesn't resolve the issue for you let me know and I can dig around a little more.
I updated every tool thru SDK Manager but still compiling via cmd shows the same issue. Also, when I tried to run it in Android studio, the building process seems fine but it crashes in the app with this log.
08-04 10:13:00.155 3045-3045/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.cocos2dx.hellocpp, PID: 3045
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.cocos2dx.hellocpp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.cocos2dx.hellocpp-1/lib/x86, /vendor/lib, /system/lib]]] couldn't find "libMyGame.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:264)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
You're probably getting that error because your C++ code isn't compiling.
Doing some quick searching, I found this person who had the same issue. Try following those directions and seeing that resolves the issue.
I checked that page too and did the way they said. Like the person replied, it doesn't work.
I guess it's a compatibility issue and I tried many other things but none of them work. So, I will just downgrade NDK, cocos2d, Android studio all things to make the environment that ppl posted worked well in their laptops.
Thanks for helping.
malloc
and free
needs <stdio.h>
header;
therefore please add
#include <stdlib.h>
to AudioDecoder.cpp
and rebuild again.
I wish it works.
libMyGame.so was not creating for me. I updated build.gradle this way
import org.apache.tools.ant.taskdefs.condition.Os //added
apply plugin: 'com.android.application'
android { compileSdkVersion 25 buildToolsVersion "26.0.1"
defaultConfig {
applicationId "org.cocos2dx.hellocpp"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
externalNativeBuild { //added this block
ndkBuild {
if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
// skip the NDK Build step if PROP_NDK_MODE is none
targets 'MyGame'
arguments 'NDK_TOOLCHAIN_VERSION=4.9'
arguments 'APP_PLATFORM=android-'+PROP_TARGET_SDK_VERSION
def module_paths = [project.file("../../cocos2d").absolutePath,
project.file("../../cocos2d/cocos").absolutePath,
project.file("../../cocos2d/external").absolutePath]
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// should use '/'
module_paths = module_paths.collect {it.replaceAll('\\\\', '/')}
arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
}
else {
arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
}
arguments '-j' + Runtime.runtime.availableProcessors()
abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
}
}
}
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDir "libs"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "assets"
}
externalNativeBuild {//added this block
ndkBuild {
if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
// skip the NDK Build step if PROP_NDK_MODE is none
path "jni/Android.mk"
}
}
}
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
externalNativeBuild {//added this block
ndkBuild {
arguments 'NDK_DEBUG=0'
}
}
}
debug {
externalNativeBuild {//added this block
ndkBuild {
arguments 'NDK_DEBUG=1'
}
}
}
}
}
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':libcocos2dx') compile 'com.google.firebase:firebase-auth:11.8.0' compile 'com.google.firebase:firebase-storage:11.8.0' compile 'com.google.android.gms:play-services-base:11.8.0' }
apply plugin: 'com.google.gms.google-services'
task cleanAssets(type: Delete) { delete 'assets' } task copyAssets(type: Copy) { from '../../Resources' into 'assets' }
clean.dependsOn cleanAssets preBuild.dependsOn copyAssets
//**** Also added following 2 lines on gradle.properties
PROP_TARGET_SDK_VERSION=13 PROP_APP_ABI=armeabi
Then I was able to create .so file but it was throwing no such method error from firebase. So I updated firebase and play service versions to 11.8.0 from 11.0.0 (above code already has 11.8.0).
Then again I started getting, "java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "rand"... On lower versions(kitkat)
I used android-19 for compilation: cocos compile -p android --ap android-19 --android-studio --app-abi armeabi-v7a
Now the firebase app started working.
Tried to build AdMob project in Android.
After typing this cmd "python setup_firebase_sample.py AdMob" I moved to sample_project folder and tried to build it but encoutnering this error. I'm using NDK version 15. Python 2.7.10 cocos2d-x-3.15 Cocos Console 2.3 Complie version 22
Any solution for this?