I'm having a force close problem whenever I try to launch the settings for my live wallpaper. I don't really have anything there, so I'm not sure what could possibly be causing the problem... Here is the logCat
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): FATAL EXCEPTION: main
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): java.lang.IllegalStateException: Could not execute method of the activity
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.view.View$1.onClick(View.java:2072)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.view.View.performClick(View.java:2408)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.view.View$PerformClick.run(View.java:8818)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Handler.handleCallback(Handler.java:587)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Handler.dispatchMessage(Handler.java:92)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Looper.loop(Looper.java:143)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.ActivityThread.main(ActivityThread.java:4701)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at java.lang.reflect.Method.invokeNative(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at java.lang.reflect.Method.invoke(Method.java:521)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at dalvik.system.NativeStart.main(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): Caused by: java.lang.reflect.InvocationTargetException
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at java.lang.reflect.Method.invokeNative(Native Method)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at java.lang.reflect.Method.invoke(Method.java:521)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.view.View$1.onClick(View.java:2067)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): ... 11 more
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.SSTSoft.BallInABox/.BallInABoxSettings (has extras) } from ProcessRecord{45b9eb18 12429:com.android.wallpaper.livepicker/10050} (pid=12429, uid=10050) requires null
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Parcel.readException(Parcel.java:1247)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.os.Parcel.readException(Parcel.java:1235)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): at android.app.Activity.startActivity(Activity.java:2923)
03-17 02:13:55.262: ERROR/AndroidRuntime(12429): ... 15 more
I think it's that permission denial line, but I have no clue what could be causing it... Is there some hidden permission I need to set? This is my first liveWallpaper.
Thanks!
Ugh, I found the problem... It turns out I needed the preference activity in the manifest have exported set to "true". There's an hour I'll never get back!
While the accepted answer definitely works, it's not the correct way to do it. Setting export to true just means the activity can be launched outside of your application. However, the way this should be done is to declare the activity like this:
<activity android:name="com.example.SettingsActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
Yes, you need to set the SET_WALLPAPER permission in Android manifest file. You can use the following line inside the <manifest></manifest> element;
<uses-permission android:name="android.permission.SET_WALLPAPER" />
Update:
Reference: <uses-permission> element.
Related
I have a question how to update a ListView, which uses a custom adapter, I try to do a thread while (true). Start() to always listen to the server (not work).
I want to update the list (status (offine, online ..), image, etc..). For example, in my ListView:
User 1 offine
User 2, offine
- Waiting, after 3 seconds
User 1 online
User 2, offline
I have read that this can be done with handler:
android listview update/refresh data without closing the app
https://stackoverflow.com/questions/18030607/update-list-view-in-android
But there is a way to refresh the data from the server without handler?
I load list (how do I get always actualize?) :
listAdapter1 = getListData();
customListAdapter = new CustomListAdapter(getApplicationContext(), listAdapter1);
user_list.setAdapter(customListAdapter);
egisterForContextMenu(user_list);
My full log cat:
03-17 22:46:07.439: E/AndroidRuntime(6026): FATAL EXCEPTION: main
03-17 22:46:07.439: E/AndroidRuntime(6026): java.lang.IllegalStateException: Observer android.widget.AbsListView$AdapterDataSetObserver#4e9c7894 was not registered.
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.database.Observable.unregisterObserver(Observable.java:69)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.widget.BaseAdapter.unregisterDataSetObserver(BaseAdapter.java:42)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.widget.AbsListView.onDetachedFromWindow(AbsListView.java:2638)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.View.dispatchDetachedFromWindow(View.java:12160)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2570)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2568)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2568)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2568)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2568)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2820)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5162)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.ViewRootImpl.die(ViewRootImpl.java:5145)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:359)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:309)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3535)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.app.ActivityThread.access$1200(ActivityThread.java:141)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.os.Handler.dispatchMessage(Handler.java:99)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.os.Looper.loop(Looper.java:137)
03-17 22:46:07.439: E/AndroidRuntime(6026): at android.app.ActivityThread.main(ActivityThread.java:5103)
03-17 22:46:07.439: E/AndroidRuntime(6026): at java.lang.reflect.Method.invokeNative(Native Method)
03-17 22:46:07.439: E/AndroidRuntime(6026): at java.lang.reflect.Method.invoke(Method.java:525)
03-17 22:46:07.439: E/AndroidRuntime(6026): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-17 22:46:07.439: E/AndroidRuntime(6026): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-17 22:46:07.439: E/AndroidRuntime(6026): at dalvik.system.NativeStart.main(Native Method)
Actually there is a way to implement above functionality. See below points so you will get idea/logic of this.
You need alarmmanager, broadcastreceiver & service for this.
AlarmManager will help you to check for updates after every 3 seconds.
BroadcastReceiver & Service will help to handle newly coming notification & updating UI.
You need to use "notifyDataSetChanged()" method to show updated listview.
These 4 steps are enough to implement above logic. Still in case if you have any doubts you can discuss with me.
I know that this question was probably asked, yet I couldn't find a case matches to mine after some searching.
I've made it to show my first app on the AVD by adding
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
to the manifest, something that google's tutorial was not telling you to do directly (shame on you, google)
yet now, on running the application, the AVD alerts that "Test App has stopped".
Now the thing is, the AVD alerted that it could follow up on the errors(?), I just gave it to it's job. the error list is long, so I won't paste it, but I would like if you could check the manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name=".MainActivity" android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
sorry for the trouble, and thanks.
a little edit: I did google research, but came up with nothing to match those errors.
Due to request, Following Errors:
03-17 16:40:59.432: E/AndroidRuntime(1400): FATAL EXCEPTION: main
03-17 16:40:59.432: E/AndroidRuntime(1400): Process:
com.example.testapp, PID: 1400
03-17 16:40:59.432: E/AndroidRuntime(1400):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.testapp/com.example.testapp.Main}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.Main" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.app.ActivityThread.access$800(ActivityThread.java:135)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.os.Handler.dispatchMessage(Handler.java:102)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.os.Looper.loop(Looper.java:136)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.app.ActivityThread.main(ActivityThread.java:5017)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
java.lang.reflect.Method.invoke(Method.java:515)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
dalvik.system.NativeStart.main(Native Method)
03-17 16:40:59.432: E/AndroidRuntime(1400): Caused by:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.Main" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:40:59.432: E/AndroidRuntime(1400): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-17 16:40:59.432: E/AndroidRuntime(1400): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
03-17 16:49:13.332: E/AndroidRuntime(1423): FATAL EXCEPTION: main
03-17 16:49:13.332: E/AndroidRuntime(1423): Process:
com.example.testapp, PID: 1423
03-17 16:49:13.332: E/AndroidRuntime(1423):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.testapp/com.example.testapp.Main}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.Main" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.app.ActivityThread.access$800(ActivityThread.java:135)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.os.Handler.dispatchMessage(Handler.java:102)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.os.Looper.loop(Looper.java:136)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.app.ActivityThread.main(ActivityThread.java:5017)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
java.lang.reflect.Method.invoke(Method.java:515)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
dalvik.system.NativeStart.main(Native Method)
03-17 16:49:13.332: E/AndroidRuntime(1423): Caused by:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.Main" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:49:13.332: E/AndroidRuntime(1423): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-17 16:49:13.332: E/AndroidRuntime(1423): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
03-17 16:49:32.312: E/AndroidRuntime(1446): FATAL EXCEPTION: main
03-17 16:49:32.312: E/AndroidRuntime(1446): Process:
com.example.testapp, PID: 1446
03-17 16:49:32.312: E/AndroidRuntime(1446):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.testapp/com.example.testapp.Main}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.Main" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.app.ActivityThread.access$800(ActivityThread.java:135)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.os.Handler.dispatchMessage(Handler.java:102)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.os.Looper.loop(Looper.java:136)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.app.ActivityThread.main(ActivityThread.java:5017)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
java.lang.reflect.Method.invoke(Method.java:515)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
dalvik.system.NativeStart.main(Native Method)
03-17 16:49:32.312: E/AndroidRuntime(1446): Caused by:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.Main" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:49:32.312: E/AndroidRuntime(1446): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-17 16:49:32.312: E/AndroidRuntime(1446): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
03-17 16:53:30.202: E/AndroidRuntime(1580): FATAL EXCEPTION: main
03-17 16:53:30.202: E/AndroidRuntime(1580): Process:
com.example.testapp, PID: 1580
03-17 16:53:30.202: E/AndroidRuntime(1580):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.testapp/com.example.testapp.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.MainActivity" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.app.ActivityThread.access$800(ActivityThread.java:135)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.os.Handler.dispatchMessage(Handler.java:102)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.os.Looper.loop(Looper.java:136)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.app.ActivityThread.main(ActivityThread.java:5017)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
java.lang.reflect.Method.invoke(Method.java:515)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
dalvik.system.NativeStart.main(Native Method)
03-17 16:53:30.202: E/AndroidRuntime(1580): Caused by:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.MainActivity" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:53:30.202: E/AndroidRuntime(1580): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-17 16:53:30.202: E/AndroidRuntime(1580): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
03-17 16:54:42.542: E/AndroidRuntime(1721): FATAL EXCEPTION: main
03-17 16:54:42.542: E/AndroidRuntime(1721): Process:
com.example.testapp, PID: 1721
03-17 16:54:42.542: E/AndroidRuntime(1721):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.testapp/com.example.testapp.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.MainActivity" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.app.ActivityThread.access$800(ActivityThread.java:135)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.os.Handler.dispatchMessage(Handler.java:102)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.os.Looper.loop(Looper.java:136)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.app.ActivityThread.main(ActivityThread.java:5017)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
java.lang.reflect.Method.invoke(Method.java:515)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
dalvik.system.NativeStart.main(Native Method)
03-17 16:54:42.542: E/AndroidRuntime(1721): Caused by:
java.lang.ClassNotFoundException: Didn't find class
"com.example.testapp.MainActivity" on path: DexPathList[[zip file
"/data/app/com.example.testapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testapp-2, /system/lib]]
03-17 16:54:42.542: E/AndroidRuntime(1721): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-17 16:54:42.542: E/AndroidRuntime(1721): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
I have used ZBAR library to scan bar code in my Application.
And I got this error log while opening camera on Samsung Galaxy S3 :
java.lang.RuntimeException: startPreview failed
at android.hardware.Camera.startPreview(Native Method)
at com.SGID.MainApp.ScanningFragment.engageCamera(ScanningFragment.java:184)
at com.SGID.MainApp.ScanningFragment.access$10(ScanningFragment.java:154)
at com.SGID.MainApp.ScanningFragment$4.run(ScanningFragment.java:111)
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:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.SGID.MainApp/com.SGID.MainApp.AllTabsActivity}
: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.SGID.MainApp.ParametersFragment.onCreateView(ParametersFragment.java:78)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1877)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1167)
at android.app.Activity.performStart(Activity.java:5216)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
... 11 more
EDIT :
Getting error at this line :
CameraPreview mPreview = new CameraPreview(getActivity(), mCamera, previewCb,
autoFocusCB);
Can Anyone help me to resolve this error??
Thanks in advance..
I can't find following error in my code. It looks like the problem is in the asynctask onpostexecute.
java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:672)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:368)
at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:160)
at android.app.Dialog.dismissDialog(Dialog.java:319)
at android.app.Dialog.dismiss(Dialog.java:302)
at www.mobilezar.mn.Advertisements$InitialLoading.onPostExecute(Advertisements.java:216)
at www.mobilezar.mn.Advertisements$InitialLoading.onPostExecute(Advertisements.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
I've started to learn Android Development and I got this snippit off of google android development site, it keeps on crashing.
My specs are:
Android 4.0.3
API 15
Code:
package lewes.android.hello;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
I get...
Unfortenualy, HelloAndroid is not responding.
Please help me!
MY MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloWorld"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
LogCat:
03-17 11:35:19.835: D/AndroidRuntime(562): Shutting down VM
03-17 11:35:19.835: W/dalvikvm(562): threadid=1: thread exiting with uncaught
exception (group=0x409c01f8)
03-17 11:35:19.914: E/AndroidRuntime(562): FATAL EXCEPTION: main
03-17 11:35:19.914: E/AndroidRuntime(562): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{lewes.android.hello/lewes.android.hello.HelloWorld}:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.access$600(ActivityThread.java:123)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.os.Handler.dispatchMessage(Handler.java:99)
03-17 11:35:19.914: E/AndroidRuntime(562): at android.os.Looper.loop(Looper.java:137)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.main(ActivityThread.java:4424)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.reflect.Method.invoke(Method.java:511)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-17 11:35:19.914: E/AndroidRuntime(562): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-17 11:35:19.914: E/AndroidRuntime(562): at dalvik.system.NativeStart.main(Native
Method)
03-17 11:35:19.914: E/AndroidRuntime(562): Caused by:
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-17 11:35:19.914: E/AndroidRuntime(562): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-17 11:35:19.914: E/AndroidRuntime(562): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
03-17 11:35:19.914: E/AndroidRuntime(562): ... 11 more
03-17 11:40:20.114: I/Process(562): Sending signal. PID: 562 SIG: 9
Delete one of the application sections from your manifest.
Keep the one where the activity corresponds to the name of your class.
make your manifest look exactly like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lewes.android.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".HelloAndroid"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Change
<activity
android:name=".HelloAndroidActivity"
to
<activity
android:name=".HelloAndroid"
SDK does not mention about this. But as my experience, activity (this) can not be used inside onCreate(Bundle) to initialize new objects. To be used as a parameter for constructors, this is nothing within onCreate().
You can follow this hello world. It uses static xml layout.
Hope this helps you :-)