cocos2dx Android Studio crash in System.loadLibrary(libName) - android

I want to use cocos2dx Android Studio in mac.
I downloaded:
android-ndk-r9d, android studio 2.1.1 and apache-ant-1.9.7. cocos2dx 3.11.1
Now I am successfully creating a project by using command:
cocos new TEST -p com.your_company.test -l cpp -d /Users/mac-corei5-1/Desktop/Sayem/cocos2dx/Project
Now when I am trying to run project in Android Studio in emulator or android device it is crashing in System.loadLibrary(libName); where libName=MyGame
I got this crash log in logcat
06-30 04:46:15.291 4866-4866/com.your_company.test E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.your_company.test, PID: 4866
java.lang.UnsatisfiedLinkError: Couldn't load MyGame from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.your_company.test-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.your_company.test-2, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:246)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:260)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)

Even thought Cocos2d-x 3.10+ has bought in android studio support and gradle build support it still very much buggy. The reasom your build crashes is because you haven't actually created the .so file by using the Android-Studio build option. Try running
cocos compile -p android --android-studio
Via a CLI so that it correctly generates the files.
Then you can run the project via Android-studio, but remember any time you change the source of your game you have to run the CLI command. Proper workaround yet to be found.

Related

MobileFirst 8 and ionic v.1.x application breaks when started on Android 4.4 (release version)

I have an application developed with ionic v.1.x and it is integrated with Mobile First 8.
When I install the debug version, it is all OK, but I generated the released version, install it and it crashes.
I have the following error:
Process: {APP_ID}, PID: 20565
java.lang.RuntimeException: Unable to create application com.ibm.MFPApplication: java.lang.IllegalStateException: Unable to extract the trust manager on a.a.f.a#42a0f068, sslSocketFactory is class com.worklight.wlclient.f
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4715)
at android.app.ActivityThread.access$1600(ActivityThread.java:173)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5579)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Unable to extract the trust manager on a.a.f.a#42a0f068, sslSocketFactory is class com.worklight.wlclient.f
at a.v$a.a(SourceFile:599)
at com.worklight.wlclient.c.<init>(SourceFile:76)
at com.worklight.wlclient.c.a(SourceFile:246)
at com.worklight.wlclient.a.f.a(SourceFile:181)
at com.worklight.common.a.a(SourceFile:545)
at com.worklight.androidgap.b.a.<init>(SourceFile:54)
at com.worklight.androidgap.b.a.a(SourceFile:85)
at com.ibm.MFPApplication.onCreate(SourceFile:21)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4712)
... 10 more
Force finishing activity {APP_ID}/.MainActivity
I saw that another guy had the same problem, but his solution was install 6.2 Cordova version... I tried that and I get the following error:
Error: cordovaProject.projectConfig.getFileResources is not a function
Add below rules in your proguard-project.txt or proguard-rules.pro file
-keepclassmembers class * implements javax.net.ssl.SSLSocketFactory {
private javax.net.ssl.SSLSocketFactory delegate;
}
For more info :
Obfuscating Android code using Proguard in MobileFirst Foundation 8.0

How to build and use PJSIP for different architectures than armeabi?

I succesfully compiled PJSIP library for Android. Sample project works without any problems when I build for default architecture armeabi. Now I tried to compile library for arch such as armeabi-v7a and arm64-v8a. Unfortunately when I add libraries to project in appropriate folders (jnLibs/armeabi-v7a and jniLibs/arm64-v8a) application is not starting...
To setup build for different archs I use this command:
NDK_TOOLCHAIN_VERSION=4.9 TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags
I have this error on app launch:
07-04 12:28:46.079 15317-15317/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.futuremind.omili, PID: 15317
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "getifaddrs" referenced by "/data/app/com.futuremind.omili-1/lib/arm/libpjsua2.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:372)
at java.lang.System.loadLibrary(System.java:1076)
at com.futuremind.omili.MyApp.<clinit>(MyApp.java:293)
at com.futuremind.omili.MainActivity.onCreate(MainActivity.java:87)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
at android.app.ActivityThread.access$900(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5497)
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)
Thanks for any help! :)
I was able to fix this error by updating the AndroidManifest.xml in "pjsip-apps/src/swig/java/android/app/src/main" to match my android target -- in my case to "23". Then "make clean" and another "make" in "pjsip-apps/src/swig", and rebuilding my app.

Android: Couldn't load mupdf

I am having an (Android Studio - Gradle) Cordova (3.6.4) project.
In my app there can be a list of pdf files which should be shown with mupdf.
But I always get the following error message:
06-10 15:04:38.365 5940-5940/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: de.dil.DSM, PID: 5940
java.lang.UnsatisfiedLinkError: Couldn't load mupdf from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/de.dil.DSM-2.apk"],nativeLibraryDirectories=[/data/app-lib/de.dil.DSM-2, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.artifex.mupdfdemo.MuPDFCore.<clinit>(MuPDFCore.java:14)
at de.dil.DSM.DSM.loadFile(DSM.java:216)
at de.dil.DSM.xviewer$6.run(xviewer.java:102)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
The java files from mupdf seems to be correctly imported.
It seems to be, that it is "just" the "libmupdf.so" which isn't correctly imported.
The libmupdf.so files are in the following directories:
libs/armeabi/libmupdf.so
libs/armeabi-v7a/libmupdf.so
There is also a c mupdf file here: jni/mupdf.c
Is there anything which I especially need to configure in the settings.gradle or in the build.gradle?
Thanks ahead!!!!
Put your .so files in a jniLibs folder
>src
>main
>jniLibs
>armeabi
|libmupdf.so
>armeabi-v7a
|libmupdf.so
The solution was to add this:
jniLibs.srcDirs = ['libs']
To the existing sourceSets in the build.gradle!

Clockwork package installer stopped

Recently, I've been coding an APP which could work for an Android Device and an Android Wearable.
Today, I finished developments, and I've created a production APK following http://developer.android.com/training/wearables/apps/packaging.html tutorial.
However, when I install APK on a device, it works, but it doesn't get pushed to device.
Device crashes with message:
This is the stacktrace returned by Wearable:
08-04 21:53:47.957 914-914/com.google.android.clockwork.packageinstaller E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.google.android.clockwork.packageinstaller, PID: 914
java.lang.NullPointerException
at java.util.jar.Manifest.read(Manifest.java:187)
at java.util.jar.Manifest.<init>(Manifest.java:106)
at java.util.jar.StrictJarFile.<init>(StrictJarFile.java:65)
at android.content.pm.PackageParser.collectManifestDigest(PackageParser.java:594)
at com.google.android.clockwork.packageinstaller.PackageUtil.getPackageInfo(PackageUtil.java:76)
at com.google.android.clockwork.packageinstaller.PackageInstallerService.installPackage(PackageInstallerService.java:144)
at com.google.android.clockwork.packageinstaller.PackageInstallerService.access$000(PackageInstallerService.java:29)
at com.google.android.clockwork.packageinstaller.PackageInstallerService$1.handleMessage(PackageInstallerService.java:55)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5026)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
I don't really know how to debug this.
APP works perfectly when pushed via ADB.
Tell me if you do need any further info.
Thanks.
Well... Today it worked.
What did I do:
Clean
Removed old APK generated (.....\mobile\build\outputs\apk)
Compile via gradle via script "assembleRelease"
Now it works.

Sinch Android Messaging Tutorial App crashes upon login and client isn't started

The android tutorial app keeps crashing once a user has been logged in. Client also doesn't start.
Logcat Says
08-03 12:45:16.183 1322-1322/com.example.messagingtutorialskeleton W/linker﹕ libhoudini.so has
text relocations. This is wasting memory and is a security risk. Please fix.
08-03 12:45:16.655 1322-1322/com.example.messagingtutorialskeleton A/libc﹕ Fatal signal 11
(SIGSEGV) at 0x000000b4 (code=1), thread 1322 (utorialskeleton)
This occurs when using a Genymotion emulator.
When using the standard android virtual device, the logcat reads:
08-03 08:45:00.705 2406-2406/com.example.messagingtutorialskeleton E/AndroidRuntime﹕ FATAL
EXCEPTION: main
Process: com.example.messagingtutorialskeleton, PID: 2406
java.lang.UnsatisfiedLinkError: Couldn't load sinch-android-rtc from loader
dalvik.system.PathClassLoader[DexPathList[[zip file
"/data/app/com.example.messagingtutorialskeleton-2.apk"],nativeLibraryDirectories=[/data/app-
lib/com.example.messagingtutorialskeleton-2, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.sinch.android.rtc.internal.natives.jni.UserAgentFactory.<clinit>
(UserAgentFactory.java:9)
at
com.sinch.android.rtc.internal.client.ServiceFactory.createUserAgent(ServiceFactory.java:43)
at com.sinch.android.rtc.internal.client.DefaultSinchClient.<init>
(DefaultSinchClient.java:144)
at
com.sinch.android.rtc.internal.client.InternalSinchClientFactory.createSinchClient(InternalSinchClie ntFactory.java:13)
at
com.sinch.android.rtc.DefaultSinchClientBuilder.build(DefaultSinchClientBuilder.java:95)
at
com.sinch.messagingtutorialskeleton.MessageService.startSinchClient(MessageService.java:58)
at
com.sinch.messagingtutorialskeleton.MessageService.onStartCommand(MessageService.java:42)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2702)
at android.app.ActivityThread.access$2100(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Whats the problem? Thanks.
Yup i got the fix!...you just need to store all your Sinch architecture files into jniLibs folder as indicated in the tutorial.
The folder hence will include three folders which come along with the SDK namely;
1. Armeabi
2 Armeabi-v7a
3. X86
The error that you're getting is due to the missing x86 folder. Hence Do the needful and if you get stuck then please ask! 😊
The Sinch SDK isn't tested on the Genymotion emulator because it doesn't yet support x86. Here is a full explanation: https://github.com/sinch/android-messaging-tutorial/issues/1#issuecomment-50063315
Have you tried testing the app on a physical device?

Categories

Resources