gpt4 book ai didi

android - NoClassDefFoundError - Android 2.3.X

转载 作者:行者123 更新时间:2023-11-30 02:32:15 26 4
gpt4 key购买 nike

我在一个类中定义了一个任务。下一行发生致命异常“NoClassDefFoundError”

MyCuteTask myTask = new MyCuteTask(equations)

这是代码

public class MyClass  {

public void run() {
MyCuteTask myTask = new MyCuteTask(equations)
}

protected class MyCuteTask extends AsyncTask<String, Integer, String> {
...
}
}

最近,我收到了一些奇怪的错误报告。当我实例化我的任务时,Android 抛出异常。我只有 android 2.3.X 有这个错误。

你们有没有同样的错误?

编辑:这是堆栈跟踪

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)

com.mathssolver.main.Logic.updateGraph(Logic.java:310) 的行是

 MyCuteTask myTask = new MyCuteTask(equations)

最佳答案

这是一个 google play 服务问题。 ( https://code.google.com/p/android/issues/detail?id=81083 )

在 Google 修复它之前避免此崩溃的解决方法:

将以下内容添加到您的 Application#onCreate() 方法中

try {
Class.forName("android.os.AsyncTask");
}
catch(Throwable ignore) {
// ignored
}

注意它的 Application#onCreate() 而不是 Activity#onCreate()

更新:我可以验证以上更改是否为我修复了这些崩溃。

关于android - NoClassDefFoundError - Android 2.3.X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27167525/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com