I have developed an android application. This application runs perfectly in my device but crashes in emulator.
Since in my college we have to present the application in emulator, this error is creating a lot of problem.
Logcat
03-30 10:52:52.633: E/AndroidRuntime(257): Uncaught handler: thread main exiting due to uncaught exception
03-30 10:52:52.653: E/AndroidRuntime(257): java.lang.NoSuchMethodError: com.example.festipedia_logo.main.getActionBar
03-30 10:52:52.653: E/AndroidRuntime(257): at com.example.festipedia_logo.main.onCreate(main.java:51)
03-30 10:52:52.653: E/AndroidRuntime(257): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-30 10:52:52.653: E/AndroidRuntime(257): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-30 10:52:52.653: E/AndroidRuntime(257): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-30 10:52:52.653: E/AndroidRuntime(257): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-30 10:52:52.653: E/AndroidRuntime(257): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-30 10:52:52.653: E/AndroidRuntime(257): at android.os.Handler.dispatchMessage(Handler.java:99)
03-30 10:52:52.653: E/AndroidRuntime(257): at android.os.Looper.loop(Looper.java:123)
03-30 10:52:52.653: E/AndroidRuntime(257): at android.app.ActivityThread.main(ActivityThread.java:4363)
03-30 10:52:52.653: E/AndroidRuntime(257): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 10:52:52.653: E/AndroidRuntime(257): at java.lang.reflect.Method.invoke(Method.java:521)
03-30 10:52:52.653: E/AndroidRuntime(257): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-30 10:52:52.653: E/AndroidRuntime(257): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-30 10:52:52.653: E/AndroidRuntime(257): at dalvik.system.NativeStart.main(Native Method)
03-30 10:52:52.693: E/dalvikvm(257): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
It is because your emaluator is not supporting action bar. Try either of these
1 - use action bar sherlock instead of action bar. Google it for its implementation.
2 - try increasing the android version of emaluator to ICS or more.
I recommend using action bar sherlock
From official documentation, try following it and see if the error is gone.
The ActionBar APIs were first added in Android 3.0 (API level 11) but
they are also available in the Support Library for compatibility with
Android 2.1 (API level 7) and above.
This guide focuses on how to use the support library's action bar, but
if your app supports only Android 3.0 or higher, you should use the
ActionBar APIs in the framework. Most of the APIs are the same—but
reside in a different package namespace—with a few exceptions to
method names or signatures that are noted in the sections below.
Caution: Be certain you import the ActionBar class (and related APIs)
from the appropriate package:
If supporting API levels lower than 11:
import android.support.v7.app.ActionBar
If supporting only API level 11 and higher:
import android.app.ActionBar
More At: http://developer.android.com/guide/topics/ui/actionbar.html
You can also check http://actionbarsherlock.com/
Just tell your emulator to support the same API level as your device and the problem should magically vanish. It's a configuration setting in the emulator.
Related
I am using GA to tracking my applications. I have noticed that there is a weird exception reported sometimes on every release. The reported calling stack shows that it seems to be the Android issue of the user's device(I can never reproduce this issue). I tried hard but still cannot find a clue, is there anyone have some experience with this problem?
Thread: main, Exception: java.lang.ArithmeticException: divide by zero
at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2937)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
My apps are force closing on few devices(samsung & sony) after implementing interstitial ads and the stack traces from developer console is as follows.
java.lang.NullPointerException
at com.google.ads.a.f$a.run(SourceFile:128)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
I don't understand why it is happening. Can someone help?
Use the new Google Play Services library which now include the Admob classes.
The Admob package has changed so your imports will need to be adjusted to
import com.google.android.gms.ads.*;
Decided to use Scandit SDK to get the barcode scanning feature in my app. Unfortunately, since I'm relatively new to Android development and Java in general I've run into a few issues that I can't seem to work out. The demo that Scandit provided doesn't give any errors(runs fine) but crashes when I try to start it up (pressing a button from one activity is meant to start it up). I've tried reading the logcat and googling a solution to the problems but I'm not getting the right solutions. Does anyone have an idea of what I'm doing wrong?
Logcat is provided below:
10-08 23:30:00.807 21563-21563/com.kwesimbia.management D/AndroidRuntime? Shutting down VM
10-08 23:30:00.807 21563-21563/com.kwesimbia.management W/dalvikvm? threadid=1: thread exiting with uncaught exception (group=0x40aa4228)
10-08 23:30:00.817 21563-21563/com.kwesimbia.management E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3082)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3077)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.kwesimbia.management.ScanditSDKDemoSimple
at com.kwesimbia.management.Activity_D.initiateCodeScan(Activity_D.java:63)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3077)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger? App crashed!
Process: com.kwesimbia.management
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger? App crashed!
Package: com.kwesimbia.management v1 (1.0)
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger?
Application Label: firstapp
10-08 23:30:00.827 32726-587/? W/ActivityManager?
Force finishing activity com.kwesimbia.management/.Activity_D
I came across this problem as well, my solution was to extract the library files and put them as their files in the lib folder
The library basically isn't being exported with it
EDIT
So I checked out my project, basically I did these things:
In the libs folder I have a new folder called armeabi and inside that I have libscanditsdk-android-3.3.1.so
Then in my build path I have also referenced the jar file that they provide:
<classpathentry exported="true" kind="lib" path="C:/GIT/Android/FwayScannerProject/FwayScanner/libs/scanditsdk-barcodepicker-android-3.3.1.jar"/>
I am following this guide and based on here, it says
Don't bother using older versions of Android. Use the highest SDK
target available. Phonegap will take care of backwards compatibility
for you.
So I use these targets:
Build target
Android 2.3.3
and
minimum SDK 4
and use
cordova-1.9.0.jar
but gives following error when I try to run it on Android 1.6
E/dalvikvm(200): Could not find method android.webkit.WebView.<init>, referenced from method org.apache.cordova.CordovaWebView.<init>
W/dalvikvm(200): VFY: unable to resolve direct method 285: Landroid/webkit/WebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
W/dalvikvm(200): VFY: rejecting opcode 0x70 at 0x0001
W/dalvikvm(200): VFY: rejected Lorg/apache/cordova/CordovaWebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
W/dalvikvm(200): Verifier rejected class Lorg/apache/cordova/CordovaWebView;
D/AndroidRuntime(200): Shutting down VM
W/dalvikvm(200): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
E/AndroidRuntime(200): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(200): java.lang.VerifyError: org.apache.cordova.CordovaWebView
E/AndroidRuntime(200): at org.apache.cordova.DroidGap.init(DroidGap.java:297)
E/AndroidRuntime(200): at org.apache.cordova.DroidGap.loadUrl(DroidGap.java:343)
E/AndroidRuntime(200): at phone.gap.test.PhonegapTestActivity.onCreate(PhonegapTestActivity.java:13)
E/AndroidRuntime(200): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
E/AndroidRuntime(200): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
E/AndroidRuntime(200): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
E/AndroidRuntime(200): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
E/AndroidRuntime(200): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
E/AndroidRuntime(200): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(200): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(200): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime(200): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(200): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(200): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime(200): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AndroidRuntime(200): at dalvik.system.NativeStart.main(Native Method)
However it runs well when I run it on Android 2.3.3.
Does Phonegap not support Android 1.6?
PhoneGap 1.0 removed support for Android releases before 2.1. You could use one of the 0.9.x releases with Android 1.6.
Since you are using PhoneGap 1.9, have a look at this: http://docs.phonegap.com/en/1.9.0/guide_cordova-webview_android.md.html#Embedding%20Cordova%20WebView%20on%20Android
While it would be ideal to support back to 1.6, you're only giving up <1% of your potential market reach if you move up to 2.1. Previous answers on this topic have also suggested using 2.1 (minSdkLevel="7") as your bottom end.
Two days ago, when my android project in eclipse still worked, I added "android SDK 4.0.3" to my SDKs (in addition to android SDK 2.1).
From that moment on, I have a trouble with slf4j-android library; here's the exception:
Uncaught handler: thread main exiting due to uncaught exception
java.lang.ExceptionInInitializerError
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1479)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at it.cefriel.swa.urbanopoly.client.game.UrbanopolyActivity.<clinit>(UrbanopolyActivity.java:11)
The JAR I use is slf4j-android-1.5.8.jar. The build path seems correctly setted. I also tried to create another project using slf4j and I got the same error..
Any Ideas?
Thanks in advance
Try adding the slf4j-api-1.5.8.jar or latest version as well with the current slf4j-android-1.5.8.jar