Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have five tabs in my application say A,B,C,D and E.My problem is that application stopped while changing the tab from B to any other tabs and rotating the device into landscape mode or portrait mode.
Error log is
08-22 11:27:22.835: E/AndroidRuntime(5992): FATAL EXCEPTION: main
08-22 11:27:22.835: E/AndroidRuntime(5992): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nv.netmdapp1/com.nv.netmdapp1.Home}: java.lang.NullPointerException
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3351)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.access$700(ActivityThread.java:123)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.os.Looper.loop(Looper.java:137)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-22 11:27:22.835: E/AndroidRuntime(5992): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 11:27:22.835: E/AndroidRuntime(5992): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 11:27:22.835: E/AndroidRuntime(5992): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-22 11:27:22.835: E/AndroidRuntime(5992): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-22 11:27:22.835: E/AndroidRuntime(5992): at dalvik.system.NativeStart.main(Native Method)
08-22 11:27:22.835: E/AndroidRuntime(5992): Caused by: java.lang.NullPointerException
08-22 11:27:22.835: E/AndroidRuntime(5992): at com.nv.netmdapp1.ScheduleDailyView.onActivityCreated(ScheduleDailyView.java:89)
08-22 11:27:22.835: E/AndroidRuntime(5992): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1468)
Java code given below.
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
dailyFragment = (SherlockFragment) Fragment.instantiate(appContext, AppointmentDailyView.class.getName(),arguments);
weeklyFragment=(SherlockFragment) Fragment.instantiate(appContext, AppointmentWeeklyView.class.getName(),arguments);
FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment lastFrag = getFragmentManager().findFragmentByTag("appointmentFrag");
if(lastFrag!=null)
ft.remove(lastFrag);
ft.replace(R.id.ll_appointment_layout, dailyFragment);
ft.commit();
}
#Override
public void onClick(View view)
{
FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment lastFrag = getFragmentManager().findFragmentByTag("appointmentFrag");
if(lastFrag!=null)
ft.remove(lastFrag);
if(view==btnDaily)
ft.replace(R.id.ll_appointment_layout, dailyFragment);
else
ft.replace(R.id.ll_appointment_layout, weeklyFragment);
ft.commit();
}
When clicking Tab C this part is executed.But while rotating the device control goes to onActivityCreated() of Tab B.
Here null pointer exception occurring line ScheduleDailyView.java:89 is associated with Tab B.But while rotating the device control goes from tab C and D to this file.What is the reason?
Add the android:configChanges="orientation" in the android manifest, it handles the orientation change event in application.
Manifest:
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:configChanges="orientation"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Hope helpful to you..
Rotating the Device restarts your app again:
OnActivityCreated Method is called and you are getting a null pointer exception here:
Caused by: java.lang.NullPointerException
08-20 16:54:43.319: E/AndroidRuntime(5646): at com.nv.netmdapp1.ScheduleDailyView.onActivityCreated(ScheduleDailyView.java:89)
Check what is null here, also you can avoid restarting your activity on rotation by handling configuration changes.
Related
Hi I have been trying to develop a simple game in Eclipse I'm at the stage of trying to add the background image however when I try to run the app I get the "unfortunately has stopped working" looking at the log cat my best guess is that something is wrong with the bitmap factory line below:
background = new Background(BitmapFactory.decodeResource(getResources(), R.drawable.underwater), ScreenWidth, this);
Here is the Log Cat I am recieving:
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:376)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:406)
at com.example.deepseadiver.GamePanel.<init>(GamePanel.java:21)
at com.example.deepseadiver.Game.onCreate(Game.java:69)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
at android.app.ActivityThread.access$600(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4931)
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:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
Any help or suggestions for how to fix this are much appreciated.
Update you manifest file,inside application tag set large heap -
.
.
<application
android:largeHeap="true"
. .
>
....
</application>
I am facing a very weird problem while configuring Tesseract in Android. Following all required steps described here and SO like this and this i have imported tess-two library in eclipse. NDK-build and ant release was also successfull. I have used latest ndk version and android sdk v19(4.4.2).
Next, i had imported a sample project in eclipse written in above blog. All were build successfully. But, when i run the project in a real device, it gives me such a weird error in onPhotoTaken event that possible google search can't answer me nothing!
Logcat says:
08-22 15:04:44.812: V/SimpleAndroidOCR.java(16578): Before baseApi
08-22 15:04:44.812: D/dalvikvm(16578): Trying to load lib /data/app-lib/com.datumdroid.android.ocr.simple-1/liblept.so 0x41e56b50
08-22 15:04:44.822: D/dalvikvm(16578): GC_CONCURRENT freed 1K, 14% free 4989K/5788K, paused 2ms+2ms, total 18ms
08-22 15:04:44.822: E/dalvikvm(16578): dlopen("/data/app-lib/com.datumdroid.android.ocr.simple-1/liblept.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...
08-22 15:04:44.832: W/dalvikvm(16578): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/googlecode/tesseract/android/TessBaseAPI;
08-22 15:04:44.832: D/AndroidRuntime(16578): Shutting down VM
08-22 15:04:44.832: W/dalvikvm(16578): threadid=1: thread exiting with uncaught exception (group=0x41be0930)
08-22 15:04:44.832: E/AndroidRuntime(16578): FATAL EXCEPTION: main
08-22 15:04:44.832: E/AndroidRuntime(16578): java.lang.ExceptionInInitializerError
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onPhotoTaken(SimpleAndroidOCRActivity.java:211)
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onActivityResult(SimpleAndroidOCRActivity.java:135)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.Activity.dispatchActivityResult(Activity.java:5302)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2729)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.os.Looper.loop(Looper.java:137)
08-22 15:04:44.832: E/AndroidRuntime(16578): at android.app.ActivityThread.main(ActivityThread.java:5041)
08-22 15:04:44.832: E/AndroidRuntime(16578): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 15:04:44.832: E/AndroidRuntime(16578): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
08-22 15:04:44.832: E/AndroidRuntime(16578): at dalvik.system.NativeStart.main(Native Method)
08-22 15:04:44.832: E/AndroidRuntime(16578): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...
08-22 15:04:44.832: E/AndroidRuntime(16578): at java.lang.Runtime.loadLibrary(Runtime.java:371)
08-22 15:04:44.832: E/AndroidRuntime(16578): at java.lang.System.loadLibrary(System.java:535)
08-22 15:04:44.832: E/AndroidRuntime(16578): at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:44)
08-22 15:04:44.832: E/AndroidRuntime(16578): ... 17 more
Probably the most important part of this error message is:
08-22 15:04:44.832: E/AndroidRuntime(16578): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "rand" referenced by "liblept.so"...
I checked liblept.so is inside the libs folder of library project that i referenced in my sample project.
Can anyone point me the solution or suggestion of this time-killing problem? Thanks in advance.
There seems to be a problem with the NDK toolchain version 4.9.
Try pulling the latest version of the tess-two library code, which includes the following in its Application.mk:
NDK_TOOLCHAIN_VERSION := 4.8
You will need to use the "ndk32" version of the NDK for 32-bit targets.
I've made my Android app tablet optimized and I followed the tutorial here:
Everything is great, but I am trying to select an item (say, the 1st item) with a button in the ActionBar.
I tried this answer to use performItemClick but on I've got error reports of java.lang.IllegalStateException
in android.support.v4.app.ListFragment.ensureList, java.lang.IllegalStateException: Content view not yet created, and java.lang.NullPointerException
in android.content.ComponentName.<init>
I've tried checking if the ListView is null and still get the error reports on the Play Store. How do I properly select an item in my list programmatically?
Update to add logcat and the code is virtually identical to the tutorials in the links:
Logcat A:
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:69)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2606)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1045)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:592)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:149)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17273)
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)
Logcat B:
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2874)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:86)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3701)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:779)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:861)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Update 2
And here is the code that is causing the problem:
if (mListFragment.listView != null) {
mListFragment.listView.performItemClick(mListFragment.listView.getAdapter().getView(position, null, null), position, mListFragment.listView.getAdapter().getItemId(position));
}
I'm seeing a weird exception in Android Support Library - the stack trace is below. Any ideas what could be causing this? I'm unable to reproduce the exception on any of my devices, but there seem to be quite a few visible in the Google Play DevConsole.
java.lang.NullPointerException
at android.support.v4.app.FragmentManagerImpl.makeInactive(FragmentManager.java:1133)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1044)
at android.support.v4.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1171)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:582)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
at android.os.Handler.handleCallback(Handler.java:608)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:5045)
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)
try check stack fragments in time rotate screen for example in onResume.
08-22 15:28:41.848: E/Trace(678): error opening trace file: No such file or directory (2)
08-22 15:28:42.387: D/AndroidRuntime(678): Shutting down VM
08-22 15:28:42.387: W/dalvikvm(678): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-22 15:28:42.407: E/AndroidRuntime(678): FATAL EXCEPTION: main
08-22 15:28:42.407: E/AndroidRuntime(678): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vikram.custummenuactivity/com.vikram.custummenuactivity.CustumMenuActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.os.Looper.loop(Looper.java:137)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-22 15:28:42.407: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 15:28:42.407: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 15:28:42.407: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-22 15:28:42.407: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-22 15:28:42.407: E/AndroidRuntime(678): at dalvik.system.NativeStart.main(Native Method)
08-22 15:28:42.407: E/AndroidRuntime(678): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ListActivity.onContentChanged(ListActivity.java:243)
08-22 15:28:42.407: E/AndroidRuntime(678): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:259)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.Activity.setContentView(Activity.java:1867)
08-22 15:28:42.407: E/AndroidRuntime(678): at com.vikram.custummenuactivity.CustumMenuActivity.onCreate(CustumMenuActivity.java:24)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.Activity.performCreate(Activity.java:5008)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-22 15:28:42.407: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-22 15:28:42.407: E/AndroidRuntime(678): ... 11 more
08-22 15:33:42.558: I/Process(678): Sending signal. PID: 678 SIG: 9
So problem shouldn't be tricky. Your problem is:
Caused by: java.lang.RuntimeException: Your content must have a
ListView whose id attribute is 'android.R.id.list'
It means that you ListView should have id attibute android.R.id.list
<ListView
android:id="#android:id/list"
...
/>
Similar topic:
runtime exception ListView whose id attribute is
'android.R.id.list'
From your stack trace:
"Your content must have a ListView whose id attribute is 'android.R.id.list". Add this id to the appropriate element in your XML layout file, for example: