I'm new in Android development, and my English is awfull.
I have an application with a homescreen widget.
When I start application, in main activity, I can select options for widget (these options are saved to a DB).
Then, I add a Widget, that it have an ImageButton on it, to the homescreen. The click on ImageButton works fine.
If I kill the application activity with some Task Manager, delete the widget, and add it again. The click on ImageButton crash.
Is this normally?
Here you have the error:
java.lang.RuntimeException: Unable to start service cat.aat.quoteswidget.Widget$UpdateService#45d1b188 with Intent { cmp=cat.aat.quoteswidget/.Widget$UpdateService }: java.lang.NullPointerException
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3282)
at android.app.ActivityThread.access$3600(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2211)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at cat.aat.quoteswidget.Widget$UpdateService.buildUpdate(Widget.java:130)
at cat.aat.quoteswidget.Widget$UpdateService.onStart(Widget.java:90)
at android.app.Service.onStartCommand(Service.java:420)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3267)
... 10 more
Thanks!
You have a NullPointerException on line 130 of your Widget.java file, in the buildUpdate() method of your UpdateService.
Related
I have a main activity and I call a second "demo from android studio" activity when I click on a button of the first activity like this :
public void createNetworkButtonClicked (View view) {
Intent intent = new Intent(this, WiFiDirectActivity.class); // that works
startActivity(intent); // that does not work
}
I get this error :
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3698)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17337)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
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)
Caused by: java.lang.reflect.InvocationTargetException
Thanks for your help
There can be possibly two reasons for it.
1) Check your method name in onClick attribute of XML file. It should match with the name of the method in java.
2) Create an activity instead of creating individual XML file and Java file for the second class. You can create Activity by right clicking on app folder-->new-->activity-->empty activity.
In my Activity, I try to launch a particular video:
Intent intent = YouTubeStandalonePlayer.createVideoIntent(this, key, videoId);
startActivity(intent);
The video id is LT5YThKAsic, but right after the standalone player activity shows up (I can just briefly see my video there), I get a Force Close with the following stack trace which I don't think is all that helpful.
FATAL EXCEPTION: main
java.lang.IllegalArgumentException
at com.google.android.youtube.core.utils.s.a(SourceFile:112)
at com.google.android.youtube.core.async.GDataRequestFactory.a(SourceFile:395)
at com.google.android.youtube.api.ab.a(SourceFile:141)
at com.google.android.youtube.core.async.a.d.a(SourceFile:101)
at com.google.android.youtube.core.async.a.d.a(SourceFile:73)
at com.google.android.youtube.core.player.Director.v(SourceFile:530)
at com.google.android.youtube.core.player.Director.a(SourceFile:398)
at com.google.android.youtube.core.player.Director.a(SourceFile:412)
at com.google.android.youtube.core.player.Director.a(SourceFile:425)
at com.google.android.youtube.api.ApiPlayer.a(SourceFile:195)
at com.google.android.youtube.api.service.a.d.run(SourceFile:167)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4134)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Force finishing activity com.google.android.youtube/.api.StandalonePlayerActivity
Any idea why it's crashing?
Does anyone know what this could possibly mean? Apparently someone else's app caused mine to crash? And it happens to be an app that directly competes with mine:
java.lang.RuntimeException: Unable to create BackupAgent com.MY_COMPEITOR'S_APP.backup.BackupAgent: java.lang.NullPointerException
at android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:2905)
at android.app.ActivityThread.access$4000(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2128)
at android.os.Handler.dispatchMessage(Handler.java:99)
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)
Caused by: java.lang.NullPointerException
at android.app.ActivityThread$PackageInfo.initializeJavaContextClassLoader(ActivityThread.java:529)
at android.app.ActivityThread$PackageInfo.getClassLoader(ActivityThread.java:474)
at android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:2873)
... 10 more
TenFour I would bet since you are talking about a competing App that there must be some INtent Handling going on that led to this. Maybe the Competitor app was actually trying to do something at the same time your app was trying to do something and they clashed. Without knowing more it's hard to provide a more detailed answer
I followed the advice given on the internet regarding working with Application classes in android.
I also added a field "android:name=.Session" to my Application object in the manifest.
The application is called "Session".
What do you think is the error? This is happening even before the my App starts.
This is the error stack:
**java.lang.RuntimeException: Unable to instantiate application com.appfire.Session: java.lang.InstantiationException: com.appfire.Session**
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:523)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3996)
at android.app.ActivityThread.access$2900(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1901)
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.InstantiationException: com.appfire.Session**
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1479)
at android.app.Instrumentation.newApplication(Instrumentation.java:957)
at android.app.Instrumentation.newApplication(Instrumentation.java:942)
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:518)
Make sure your Session class is public, is not static, and does not have a default constructor.
public class Session extends Application {}
In the Manifest application tag, make sure you include the fully-qualified class name of your custom Application object:
<application
android:name="com.mycompany.myapp.Session"
.... />
The Android docs do say the class name must be fully qualified:
http://developer.android.com/guide/topics/manifest/application-element.html#nm
(This is not the case for Activity class names that are included in the activity tag of the Manifest. Those can be relative, preceded with a '.').
My solution was to delete the whole project from Eclipse and load it again from SVN. Now it works
One or two of my users experience the above class not found run time exception when trying to run my app.
How can that happen and how can I fix it? Is it a bad install?
Thanks
Paul
Stack trace received through Android Publishers site. I cannot replicate this myself.
(com.android.app.app.app) is the name of the app/activity as defined in the manifest.
java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{my,app.app.app/com.android.app.app.app}:
java.lang.ClassNotFoundException:
com.android.app.app.app in loader
dalvik.system.PathClassLoader[/mnt/asec/my,app.app.app-1/pkg.apk]
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2753)
at
android.app.ActivityThread.access$2500(ActivityThread.java:129)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2107)
at
android.os.Handler.dispatchMessage(Handler.java:99)
at
android.os.Looper.loop(Looper.java:143)
at
android.app.ActivityThread.main(ActivityThread.java:4701)
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:868)
at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at
dalvik.system.NativeStart.main(Native
Method) Caused by:
java.lang.ClassNotFoundException:
com.android.app.app.app in loader
dalvik.system.PathClassLoader[/mnt/asec/my,app.app.app-1/pkg.apk]
at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2651)
... 11 more
I'd check to see if these users are installing the app on an SD card: if the app is installed the app icon might be visible in the application list (since that is stored on-device) but if the SD card is unavailable (removed or maybe mounted for reading by a PC over USB) when the user taps the application icon the attempts to load will fail. You will notice:
ComponentInfo{my,app.app.app/com.android.app.app.app}: java.lang.ClassNotFoundException: com.android.app.app.app in loader dalvik.system.PathClassLoader[/mnt/asec/my,app.app.app-1/pkg.apk] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659) at
in your stack trace above: is /mnt/asec the SD card storage path on the device?