I'm trying to set-up a basic structure for my project, which is supposed to run on API-levels 8 - 16, uses google location services and ActionBarSherlock.
See my other question for the setup.
I generated a simple activity with Eclipse (Master-Detail-Flow). My project currently has just one Activity and one Fragment. All I did so far is replacing the super classes with their ABS counterparts:
public class CouponListActivity extends SherlockFragmentActivity implements CouponListFragment.Callbacks {
...
}
and
public class CouponListFragment extends SherlockListFragment {
...
}
This is the one and only layout-element I'm using
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:name="....activity.CouponListFragment"
android:id="#+id/coupon_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context=".CouponListActivity" />
This runs fine on an emulator on API 16, but fails on another emulator with API 8.
The problem is that I cannot interpret the stacktrace in any helpful way. My code does not the seem to get touched at all...
java.lang.NullPointerException
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
at android.widget.AbsListView.obtainView(AbsListView.java:1315)
at android.widget.ListView.makeAndAddView(ListView.java:1727)
at android.widget.ListView.fillDown(ListView.java:652)
at android.widget.ListView.fillFromTop(ListView.java:709)
at android.widget.ListView.layoutChildren(ListView.java:1580)
at android.widget.AbsListView.onLayout(AbsListView.java:1147)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
Where can I start looking for the problem? Let me know if I can provide more information.
Update: I have the exact same stacktrace if I rule out ABS and simply try to create a List-Activity / -Fragment combination that runs in API 8. Here is the project.
After reviewing your source code, you are using simple_list_item_activated_1 resource. Which was new to Android API level 11 So Solution for your problem is.
onCreate method should be something like this
#Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<DummyContent.DummyItem>(getActivity(), android.R.layout.simple_list_item_activated_1,android.R.id.text1, DummyContent.ITEMS));
}
Since this was new to API Level 11, You will get same error with or without ActionBarSherlock. If you want to use simple_list_item_activated_1 then you need to create a local copy of it. Sorry for being late
Related
I'm getting this strange error on the pre KitKat devices:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{me.bitfrom.whattowatch/me.bitfrom.whattowatch.ui.activities.MainActivity}: java.lang.ClassNotFoundException: me.bitfrom.whattowatch.ui.activities.MainActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: me.bitfrom.whattowatch.ui.activities.MainActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
On devices with API Level >= 19 everything OK. I thought that it could be dex limit, but this approach didn't help.
UPD: My MainActivity implements Transition.TransitionListener, but I'm using #SuppressLint("NewApi") annotation.
My MainActivity implements Transition.TransitionListener
That's probably your problem. That interface only exists on API Level 19 and higher. Older devices do not have that interface, and therefore cannot load your class.
but I'm using #SuppressLint("NewApi") annotation
All that does is prevent your IDE from complaining. It does not cause older devices to get Transition or Transition.TransitionListener.
Rather than implementing it on the activity, implement that interface on something else that you only use on API Level 19+ devices, such as an anonymous inner class instance.
I have a Task defined in a class.
Fatal exception "NoClassDefFoundError" is happening on following line
MyCuteTask myTask = new MyCuteTask(equations)
Here is the code
public class MyClass {
public void run() {
MyCuteTask myTask = new MyCuteTask(equations)
}
protected class MyCuteTask extends AsyncTask<String, Integer, String> {
...
}
}
Recently, I have strange bug reports.
Android throw an exception when I instantiate my task.
I have this bug with android 2.3.X only.
Do any of you got the same bug?
EDIT: Here is the stack Trace
java.lang.NoClassDefFoundError: com.mathssolver.main.k
at com.mathssolver.main.Logic.updateGraph(Logic.java:310)
at com.mathssolver.main.Graph.update(Graph.java:249)
at com.mathssolver.main.MathGraphFragment.plotFunction(MathGraphFragment.java:236)
at com.mathssolver.main.MathGraphFragment.plot(MathGraphFragment.java:158)
at com.mathssolver.main.MathGraphFragment.showExample(MathGraphFragment.java:141)
at com.mathssolver.main.MathGraphFragment.onStart(MathGraphFragment.java:109)
at android.support.v4.app.Fragment.performStart(Fragment.java:1810)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:977)
at android.support.v4.app.FragmentManagerImpl.performPendingDeferredStart(FragmentManager.java:842)
at android.support.v4.app.FragmentManagerImpl.startPendingDeferredFragments(FragmentManager.java:1150)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1506)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441)
at android.view.View.measure(View.java:8323)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
at android.view.View.measure(View.java:8323)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8323)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:453)
at android.view.View.measure(View.java:8323)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8323)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8323)
at android.view.ViewRoot.performTraversals(ViewRoot.java:842)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1862)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.ClassNotFoundException: com.mathssolver.main.k in loader dalvik.system.PathClassLoader[/data/app/com.shakti.mathssolver-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at com.mathssolver.main.Logic.updateGraph(Logic.java:310)
at com.mathssolver.main.Graph.update(Graph.java:249)
at com.mathssolver.main.MathGraphFragment.plotFunction(MathGraphFragment.java:236)
at com.mathssolver.main.MathGraphFragment.plot(MathGraphFragment.java:158)
at com.mathssolver.main.MathGraphFragment.showExample(MathGraphFragment.java:141)
at com.mathssolver.main.MathGraphFragment.onStart(MathGraphFragment.java:109)
at android.support.v4.app.Fragment.performStart(Fragment.java:1810)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:977)
at android.support.v4.app.FragmentManagerImpl.performPendingDeferredStart(FragmentManager.java:842)
at android.support.v4.app.FragmentManagerImpl.startPendingDeferredFragments(FragmentManager.java:1150)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1506)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441)
at android.view.View.measure(View.java:8323)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365)
at android.view.View.measure(View.java:8323)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8323)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:453)
at android.view.View.measure(View.java:8323)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8323)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
at android.view.View.measure(View.java:8323)
at android.view.ViewRoot.performTraversals(ViewRoot.java:842)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1862)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(NativeStart.java)
Line at com.mathssolver.main.Logic.updateGraph(Logic.java:310) is
MyCuteTask myTask = new MyCuteTask(equations)
Its an google play services issue. (https://code.google.com/p/android/issues/detail?id=81083)
Workaround to avoid this crash till Google fixes it:
Add following into your Application#onCreate() method
try {
Class.forName("android.os.AsyncTask");
}
catch(Throwable ignore) {
// ignored
}
Note its Application#onCreate() and not Activity#onCreate()
Update: I can verify that above changes fixed these crashes for me.
Asynctask was added in API level 3. Please verify one by checking the same code with API 3. If it disappears, there is your problem
This is an inner class please refer how to access the inner class object through outerclass else define your Myclass outside the Mainclass
I reported the same error here: Android: NoClassDefFoundError android.os.AsyncTask
Because it started happening without any app delivery it looks like yet another Google Play Services bug...
I'm having 83% of crashes on Android 2.3.x and 16% on crashes on 4.0.3 & 4.0.4
I had the same problem and I have copied source code of the AsyncTask as MyAsyncTask into my project and extended from that class, now it works.
I have android app in market so I get this error but I don't know why.
Exception class java.lang.NoClassDefFoundError
Source method MainActivity.onCreate()
java.lang.NoClassDefFoundError: android.app.DownloadManager
at com.example.viewpagerexample.MainActivity.onCreate(MainActivity.java:182)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
at android.app.ActivityThread.access$2300(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
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)
DownloadManager was added on API level 9 (aka Gingerbread).
My guess you declared minSDK as lower than 9 in your AndroidManifest.xml
If that is the case, you need to devise a workaround for users using older Android version.
You can check on which version your app is running by using the following code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
// Use DownloadManager
}
else {
// Workaround
}
I am working on Mapview.I am getting error but i have no idea why i can getting this.I debug all of the item .I didnt see it before.
Can anybody see this error?I now it is null exception but can anybody see PixelConverter?
ERROR/AndroidRuntime(1382): FATAL EXCEPTION: main
java.lang.NullPointerException
at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:71)
at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:61)
at com.google.android.maps.MapView.onLayout(MapView.java:681)
at android.view.View.layout(View.java:7035)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
at android.view.View.layout(View.java:7035)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
There is an error in my Android application that happens quite often, based on the crash report on the Developer Console.
java.lang.NullPointerException
at android.widget.AbsListView.obtainView(AbsListView.java:1304)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1198)
at android.widget.ListView.onMeasure(ListView.java:1109)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
at android.view.View.measure(View.java:8171)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
at android.view.View.measure(View.java:8171)
at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
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:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
Unfortunately, I can't replicate that error on my Android phone.
I dont' know where to start: in the trace there isn't any reference to my code.
Can somebody give me some suggestions on how to identify the root of the problem, please?
Thanks,
Dan
The most obvious things I can think of:
AbsListView.obtainView() I believe is communicating with the Adopter to populate the list view. Make sure there is never a case where you could return a null back to the list view.
There may be a bug in some version of the platform. Unfortunately the developer console does not currently show you the platform version the error reports came from. Hopefully this will be added in the future to help diagnose such a situation.
It is possible someone is running a non-standard or custom build of the platform that has bugs. You might be able to determine this by looking at the "platforms" section for the different devices the error is coming from.
I would try creating a virtual device and load it in the emulator, start with the smallest resolution.
I am suspecting that it has to do with screen size and somehow you are trying to draw in a pixel that doesn't exist.