I tried to build the Cocos2D-x testCpp sample project (Cocos2D-x 2.2.2) on my Android device using the command line interface as described in the Readme.md file:
$ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/
$ export NDK_ROOT=/path/to/ndk
$ ./build_native.sh
$ ant debug install
If the last command results in sdk.dir missing error then do:
$ android list target
$ android update project -p . -t (id from step 6)
$ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6)
I can install the app on my device (Galaxy S4) but the application crashes immediately after the launch telling me the application was stopped.
Any idea what I can do to fix that problem?
I am not sure how to use logcat within the CLI, so I startet the sample application using eclipse (the error here is the same: application crashes after launch) and post the logcat info shown by eclipse:
03-19 10:49:22.785: W/dalvikvm(6591): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/cocos2dx/hellocpp/HelloCpp;
03-19 10:49:22.785: W/dalvikvm(6591): Class init failed in newInstance call (Lorg/cocos2dx/hellocpp/HelloCpp;)
03-19 10:49:22.785: D/AndroidRuntime(6591): Shutting down VM
03-19 10:49:22.785: W/dalvikvm(6591): threadid=1: thread exiting with uncaught exception (group=0x4195f898)
03-19 10:49:22.785: E/AndroidRuntime(6591): FATAL EXCEPTION: main
03-19 10:49:22.785: E/AndroidRuntime(6591): java.lang.UnsatisfiedLinkError: Couldn't load hellocpp from loader dalvik.system.PathClassLoader[dexPath=/data/app/org.cocos2dx.hellocpp-1.apk,libraryPath=/data/app-lib/org.cocos2dx.hellocpp-1]: findLibrary returned null
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Runtime.loadLibrary(Runtime.java:355)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.System.loadLibrary(System.java:525)
03-19 10:49:22.785: E/AndroidRuntime(6591): at org.cocos2dx.hellocpp.HelloCpp.(HelloCpp.java:37)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Class.newInstanceImpl(Native Method)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Class.newInstance(Class.java:1130)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.access$700(ActivityThread.java:159)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.os.Looper.loop(Looper.java:137)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.main(ActivityThread.java:5419)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.reflect.Method.invoke(Method.java:525)
03-19 10:49:22.785: E/AndroidRuntime(6591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
03-19 10:49:22.785: E/AndroidRuntime(6591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
03-19 10:49:22.785: E/AndroidRuntime(6591): at dalvik.system.NativeStart.main(Native Method)
seems that your building is not successful according to the log. no hellocpp.so is generated. so it crashes when you call the method
loadLibrary();
you can check this under youPath/proj.android/libs/armeabi , see if there's a libxxx.so file.
Every time this has happened to me it has always been because I forgot to run ./build_native.sh in the "proj.android" folder of the project in question. #Lorin actually noted the symptom that reminded me. A reason that a libxxx.so file would be missing is the ./build_native.sh script has yet to be run
When you run eclipse to build it is happening in the background. When you compile from command line you need to remember to to have run the script at least once (and every time (if) you ever make a change to the cocos2dx framework itself.) I frequently forget to do that for EVERY project thereafter.
Related
I get a project from other developer to fix minor issues in app, when I'm running my app on device I'm getting an error:
15142-15142/com.etripconcept E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.crashlytics.android.answers.Answers
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:224)
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:207)
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:202)
at com.etripconcept.SplashScreenActivity.onCreate(SplashScreenActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5163)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
I'm new in Android development, so it may be stupid question, but Google doesn't say anything about it. I use Android Studio 1.2.2 on Win 8.1
I am wondering if this is some bug in Android Studio or I am simply lack od knowladge but straight to the point.
I am writing simple client-server via bluetooth app on android. At some point I encoured following problem:
07-11 18:59:20.553 10364-10364/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not find a method parujUrzadzenia(View) in the activity class com.example.pc.klient_serwerbluetooth.Klient for onClick handler on view class android.widget.Button with id 'button6'
at android.view.View$1.onClick(View.java:3775)
at android.view.View.performClick(View.java:4421)
at android.view.View$PerformClick.run(View.java:18190)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoSuchMethodException: parujUrzadzenia [class android.view.View]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getMethod(Class.java:915)
at android.view.View$1.onClick(View.java:3768)
at android.view.View.performClick(View.java:4421)
at android.view.View$PerformClick.run(View.java:18190)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
07-11 19:34:00.498 449-522/? E/ActivityManager﹕ The package com.example.pc.klient_serwerbluetooth is not found. Failure starting process com.example.pc.klient_serwerbluetooth
For what I understand Android Studio can't find method parujUrzadzenia(View) that is marked in button6's properties as onClick method...the funny thing is i deleted this button in my way of solving this problem.
I can't post picture of my project due to low reputation but like I said. I've deleted the reference to method from .xml and method from .java file and got an error saying that there is no required onClick method. So I deleted this whole button and still got this error.
Any advices will be greatly appreciated.
i have this problem:
when i try start my emulator in eclipse i wait 15 minutes and it is not started.
I try reinstall eclipse but emulator still dont working.
03-19 15:26:38.960: E/Installer(438): connection failed
03-19 15:26:39.530: E/System(438): ******************************************
03-19 15:26:39.530: E/System(438): ************ Failure starting bootstrap service
03-19 15:26:39.530: E/System(438): java.lang.NullPointerException
03-19 15:26:39.530: E/System(438): at com.android.server.firewall.IntentFirewall.readRulesDir(IntentFirewall.java:271)
03-19 15:26:39.530: E/System(438): at com.android.server.firewall.IntentFirewall.<init>(IntentFirewall.java:114)
03-19 15:26:39.530: E/System(438): at com.android.server.am.ActivityManagerService.main(ActivityManagerService.java:1804)
03-19 15:26:39.530: E/System(438): at com.android.server.ServerThread.initAndLoop(SystemServer.java:196)
03-19 15:26:39.530: E/System(438): at com.android.server.SystemServer.main(SystemServer.java:1179)
03-19 15:26:39.530: E/System(438): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 15:26:39.530: E/System(438): at java.lang.reflect.Method.invoke(Method.java:515)
03-19 15:26:39.530: E/System(438): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-19 15:26:39.530: E/System(438): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-19 15:26:39.530: E/System(438): at dalvik.system.NativeStart.main(Native Method)
03-19 15:26:39.630: E/AndroidRuntime(438): *** FATAL EXCEPTION IN SYSTEM PROCESS: WindowManager
03-19 15:26:39.630: E/AndroidRuntime(438): java.lang.NullPointerException
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.LocalDisplayAdapter$LocalDisplayDevice.getDisplayDeviceInfoLocked(LocalDisplayAdapter.java:147)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayManagerService.handleDisplayDeviceAddedLocked(DisplayManagerService.java:852)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayManagerService.handleDisplayDeviceAdded(DisplayManagerService.java:841)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayManagerService.access$1100(DisplayManagerService.java:96)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayManagerService$DisplayAdapterListener.onDisplayDeviceEvent(DisplayManagerService.java:1281)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayAdapter$1.run(DisplayAdapter.java:108)
03-19 15:26:39.630: E/AndroidRuntime(438): at android.os.Handler.handleCallback(Handler.java:733)
03-19 15:26:39.630: E/AndroidRuntime(438): at android.os.Handler.dispatchMessage(Handler.java:95)
03-19 15:26:39.630: E/AndroidRuntime(438): at android.os.Looper.loop(Looper.java:136)
03-19 15:26:39.630: E/AndroidRuntime(438): at android.os.HandlerThread.run(HandlerThread.java:61)
03-19 15:26:39.640: E/AndroidRuntime(438): Error reporting crash
03-19 15:26:39.640: E/AndroidRuntime(438): java.lang.NullPointerException
03-19 15:26:39.640: E/AndroidRuntime(438): at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:84)
03-19 15:26:39.640: E/AndroidRuntime(438): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-19 15:26:39.640: E/AndroidRuntime(438): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-19 15:27:46.600: E/Installer(796): connection failed
03-19 15:27:47.120: E/System(796): ******************************************
03-19 15:27:47.120: E/System(796): ************ Failure starting bootstrap service
03-19 15:27:47.120: E/System(796): java.lang.NullPointerException
03-19 15:27:47.120: E/System(796): at com.android.server.firewall.IntentFirewall.readRulesDir(IntentFirewall.java:271)
03-19 15:27:47.120: E/System(796): at com.android.server.firewall.IntentFirewall.<init>(IntentFirewall.java:114)
03-19 15:27:47.120: E/System(796): at com.android.server.am.ActivityManagerService.main(ActivityManagerService.java:1804)
03-19 15:27:47.120: E/System(796): at com.android.server.ServerThread.initAndLoop(SystemServer.java:196)
03-19 15:27:47.120: E/System(796): at com.android.server.SystemServer.main(SystemServer.java:1179)
03-19 15:27:47.120: E/System(796): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 15:27:47.120: E/System(796): at java.lang.reflect.Method.invoke(Method.java:515)
03-19 15:27:47.120: E/System(796): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-19 15:27:47.120: E/System(796): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-19 15:27:47.120: E/System(796): at dalvik.system.NativeStart.main(Native Method)
I install eclipse with adt with sdk for android and i can not start emulator.
Thank you for help.
Try opening emulator with less device screen size like 3.2'and wait for emulator to launch,on first occasion it might take some time.
Emulator with high config and screen size takes ages to open and sometimes does not even launch no matter what.
I had the same problem and i opened emulator using small screen resolution and boom it worked. :) Try it.
I am new to android, as my study project I made an application. Which is syncing data from webservice and fetching in my application.
Everything working fine.
But in this scenario
Launch the application
Check for internet connection
Get content from server
Fetch data in application
5. When we turn off Mobile Data / WiFi , then press any button in application suddenly application crashes.
There is any way to handle this issue ?
Thanks in advance
Error message
08-14 21:28:57.670: E/AndroidRuntime(7466): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.tvc/com.myapp.tvc.SingleActivity}: java.lang.NullPointerException
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.os.Looper.loop(Looper.java:137)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.main(ActivityThread.java:4895)
08-14 21:28:57.670: E/AndroidRuntime(7466): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 21:28:57.670: E/AndroidRuntime(7466): at java.lang.reflect.Method.invoke(Method.java:511)
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
08-14 21:28:57.670: E/AndroidRuntime(7466): at dalvik.system.NativeStart.main(Native Method)
08-14 21:28:57.670: E/AndroidRuntime(7466): Caused by: java.lang.NullPointerException
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.myapp.tvc.SingleActivity.onCreate(SingleActivity.java:76)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.Activity.performCreate(Activity.java:5163)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
08-14 21:28:57.670: E/AndroidRuntime(7466): ... 11 more
whatever is at line 76 of SingleActivity is null, since you did not provide code the best we can say is find out what and why is null at that line
My most common error is something is nulll. Maybe the handler is defined inline and your using a variable that is null
Based on what you're describing and without seeing your code it sounds like you're just trying to connect to the internet when no internet connection exists. To fix this problem you can create a network checker/listener that can check network availability before you try to do anything that requires an internet connection. If no connection is available you just don't run the task that gets stuff from the server. A more involved set up could be designed using a BroadcastReceiver (e.g. so you know when connectivity becomes available again) but try this for now and see if that's your issue.
I have downloaded the sample code for location from
https://code.google.com/p/android-protips-location/
I am trying to run it to see but it always crashes after app launch.
I have checked the manifest but I didnt find anything wrong. Has any one faced similar problem with the above sample code.
Here is the crash log.
03-19 12:06:05.456: D/AndroidRuntime(9185): Shutting down VM 03-19
12:06:05.456: W/dalvikvm(9185): threadid=1: thread exiting with
uncaught exception (group=0x414e62a0) 03-19 12:06:05.503:
E/AndroidRuntime(9185): FATAL EXCEPTION: main 03-19 12:06:05.503:
E/AndroidRuntime(9185): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{com.radioactiveyak.location_best_practices/com.radioactiveyak.location_best_practices.UI.PlaceActivity}:
java.lang.ClassNotFoundException:
com.radioactiveyak.location_best_practices.UI.PlaceActivity 03-19
12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2021)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread.access$600(ActivityThread.java:140) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
android.os.Handler.dispatchMessage(Handler.java:99) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
android.os.Looper.loop(Looper.java:137) 03-19 12:06:05.503:
E/AndroidRuntime(9185): at
android.app.ActivityThread.main(ActivityThread.java:4895) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
java.lang.reflect.Method.invokeNative(Native Method) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
java.lang.reflect.Method.invoke(Method.java:511) 03-19 12:06:05.503:
E/AndroidRuntime(9185): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
dalvik.system.NativeStart.main(Native Method) 03-19 12:06:05.503:
E/AndroidRuntime(9185): Caused by: java.lang.ClassNotFoundException:
com.radioactiveyak.location_best_practices.UI.PlaceActivity 03-19
12:06:05.503: E/AndroidRuntime(9185): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
android.app.Instrumentation.newActivity(Instrumentation.java:1068)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2012)
03-19 12:06:05.503: E/AndroidRuntime(9185): ... 11 more
Did you try project -> Clean? Do you have to add the permision in manifest of location?
I had the same issue.
I solved it by going to: Project Properties -> Java Build Path -> Order and Export Tab
And then ive put the checkmark on the "android-support-v4.jar"