NoClassDefFoundError - Android 2.3.X - android

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.

Related

How to skip splash screen Activity on low memory Android devices?

In an app with minSdkLevel=9 a splash screen is displayed by the following code:
public class SplashActivity extends Activity {
private static final int DELAY = 3000;
#Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.activity_splash);
} catch (OutOfMemoryError e) {
// ignore
}
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
final Intent intent = new Intent(
SplashActivity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
finish();
}
}, DELAY);
Utils.init(this);
}
#Override
public void onBackPressed() {
// protect from exiting the application when splash screen is shown
}
}
The activity_splash.xml layout file consists mainly of an ImageView:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:contentDescription="#string/app_name"
android:scaleType="centerInside"
android:src="#drawable/splash" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:text="#string/copyright" />
</FrameLayout>
Unfortunately, on Nexus 1 the app crashes with out of memory error:
There are 2 variants of splash.png - for mdpi (280 KByte) and xxhdpi:
Surely the splash image could be scaled down more and more variants of it could be provided (ldpi, xhdpi, ...) - but why does not the try/catch in above Java code help here?
And is there maybe a better way to handle this - maybe some directive for AndroidManifest.xml to skip SplashActivity and load MainActivity on low-memory devices?
Here the full crash trace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{XXX/XXX.SplashActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
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:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1657)
at XXX.SplashActivity.onCreate(SplashActivity.java:16)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3683)
            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:839)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.view.LayoutInflater.createView(LayoutInflater.java:505)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
            at android.app.Activity.setContentView(Activity.java:1657)
            at XXX.SplashActivity.onCreate(SplashActivity.java:16)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3683)
            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:839)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1709)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.ImageView.<init>(ImageView.java:118)
at android.widget.ImageView.<init>(ImageView.java:108)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
            at android.view.LayoutInflater.createView(LayoutInflater.java:505)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
            at android.app.Activity.setContentView(Activity.java:1657)
            at XXX.SplashActivity.onCreate(SplashActivity.java:16)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3683)
            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:839)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
            at dalvik.system.NativeStart.main(Native Method)
This is the relavant bit of the stack that tells me it's an InflateException:
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1657)
at XXX.SplashActivity.onCreate(SplashActivity.java:16)
^ your method is here
The other "Caused by:s" below are the inner exceptions.
java.lang.RuntimeException: Unable to start activity ComponentInfo{XXX/XXX.SplashActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
Try to re-size the Image from .png to .jpg format. This will decrease the size at nearly half scale. Then use a largeHeap tag in your Activities manifest file,
<application
....
android:largeHeap="true">
Also remember to make a try catch block so that you can bypass showing the Splash screen and redirect to the main activity.
While( ! success ) {
try {
// load resources
} catch (OutOfMemoryError E) {
// do something to use less memory and try again
}
}
First of all, why would you even show this Splash screen? It's not good practice, it's code doesn't do anything other than just waiting for 3 seconds to pass, it's clearly causing problems yet you insist on fixing it rather than getting rid of it altogether. Silly!
Second of all, devices like N1 that came many years ago do not have the RAM capabilities like modern devices do. With just one bitmap you're exhausting it's resources. Either optimize your bitmap usage or get rid of it altogether and find an alternative if you have to have a Splash screen.

java.lang.IllegalStateException: ActionBarView can only be used with android:layout_width="match_parent"

Background
I use ActionBarSherlock since I wish to handle old Android versions, and since the official Google's library for old Android devices doesn't have some important classes (like the PreferenceActivity or PreferenceFragment, so that they will have an actionBar).
The problem
Recently I got this weird exception:
java.lang.IllegalStateException: ActionBarView can only be used with
android:layout_width="match_parent" (or fill_parent) at
com.actionbarsherlock.internal.widget.ActionBarView.onMeasure(SourceFile:772)
at android.view.View.measure(View.java:8322) at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at
android.widget.FrameLayout.onMeasure(FrameLayout.java:250) at
com.actionbarsherlock.internal.widget.ActionBarContainer.onMeasure(SourceFile:181)
at android.view.View.measure(View.java:8322) at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:309) at
android.view.View.measure(View.java:8322) at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at
android.widget.FrameLayout.onMeasure(FrameLayout.java:250) at
android.view.View.measure(View.java:8322) at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at
android.widget.FrameLayout.onMeasure(FrameLayout.java:250) at
android.view.View.measure(View.java:8322) at
android.view.ViewRoot.performTraversals(ViewRoot.java:876) at
android.view.ViewRoot.handleMessage(ViewRoot.java:1911) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:130) at
android.app.ActivityThread.main(ActivityThread.java:3821) 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:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at
dalvik.system.NativeStart.main(Native Method)
And I can't find out why it occurs, as only a single user has reported it even though my app works fine on older Android versions (that I've tried).
What I've tried
I've found this post, and they say they don't know how to fix it other than just ditching old Android versions...
The question
Is it possible to fix this issue in some way? If so, how?
Will going to the official Google's library fix it somehow?

Butterknife library not working with HoloEverywhere/Android bootstrap

I am currently coding on the Android Bootstrap app, I want to have the new DataPickers en make use of new widgets without worrying about porting back to 2.1+
so I use the HoloEveryWhere Library. I also use the Android Bootstrap with Butterknife library
When I debug I get this exception
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.webridge.whtsnxt.debug/nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity}: butterknife.ButterKnife$UnableToInjectException: Unable to inject views for nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity#40619210
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
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:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: butterknife.ButterKnife$UnableToInjectException: Unable to inject views for nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity#40619210
at butterknife.ButterKnife.inject(ButterKnife.java:176)
at butterknife.ButterKnife.inject(ButterKnife.java:104)
at nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity.onCreate(BootstrapAuthenticatorActivity.java:140)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            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:867)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at butterknife.ButterKnife.inject(ButterKnife.java:171)
            at butterknife.ButterKnife.inject(ButterKnife.java:104)
            at nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity.onCreate(BootstrapAuthenticatorActivity.java:140)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            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:867)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: org.holoeverywhere.widget.AutoCompleteTextView
at nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity$$ViewInjector.inject(BootstrapAuthenticatorActivity$$ViewInjector.java:14)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
I think there's a problem with the HoloEverywhere activity I use in my app.
For example I use the import org.holoeverywhere.app.Activity; in all my Activity classes.
But the Butterknife use android.app.Activity; The problem is, I can't change code in the Butterknife to use the Activity from HoloEverywhere.
Please tell me your thoughts on this I use the latest version of Butterknife and HoloEveryWhere.
Try to set up in your AndroidManifest.xml the holo theme:
<application
android:theme="#style/Holo.Theme.NoActionBar.Fullscreen"
or maybe only the in activity that is happening your problem (also in the manifest)
<activity
android:theme="#style/Holo.Theme.NoActionBar.Fullscreen"
Of course in your java class, if the component is defined as a holo component in the xml layout, in your java class you have to import that component from the holo library like you are doing:
import org.holoeverywhere.app.Activity
or
import org.holoeverywhere. whatever (like button, switch, whatever)
Check if your #InjectViews has correct type.
I've used ImageView instead of LinearLayout.
Also check if you are not using other ButterKnife's injection annotations incorrectly. I've used #OnItemClick annotation for RecyclerView, which was causing RuntimeException.

Android project working on Motodev but crashes on Eclipse

I made an android project on Motodev (which is an eclipse plugin itself). But now when I am trying to run the same project on eclipse, the emulator gives me an error the following error:
FATAL EXCEPTION: main E/AndroidRuntime(4711): java.lang.VerifyError: com.tenpearls.namecalling.Activities.SearchContactsActivity
E/AndroidRuntime(4711): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(4711): at java.lang.Class.newInstance(Class.java:1429)
E/AndroidRuntime(4711): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(4711): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
E/AndroidRuntime(4711): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(4711): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(4711): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(4711): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(4711): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(4711): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(4711): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(4711): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(4711): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(4711): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(4711): at dalvik.system.NativeStart.main(Native Method)
That can be the result when you have compiled against a different library than you are using at runtime.
A good explanation can be had here.
Another possibility is having a duplicate class in the classpath somewhere, such as in a library jar.

Layout inflater error when loading app

I have a Galaxy Samsung tab 10.1" Model GT-P7510 OS Version 3.2. I tried to load app on it and it's giving me Layout inflater error. Why is this? Here is what logcat says:
android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:596)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:245)
at android.app.Activity.setContentView(Activity.java:1786)
at com.businessplan.BusinessPlannerActivity.onCreate(BusinessPlannerActivity.java:64)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1782)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1834)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1027)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4126)
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:844)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:416)
at android.view.LayoutInflater.createView(LayoutInflater.java:576)
android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020022 a=-1 r=0x7f020022}
at android.content.res.Resources.loadDrawable(Resources.java:1890)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:2462)
at android.view.ViewGroup.<init>(ViewGroup.java:365)
at android.widget.LinearLayout.<init>(LinearLayout.java:156)
at android.widget.LinearLayout.<init>(LinearLayout.java:152)
Probably you have an error in the layout file called here:
android.app.Activity.setContentView(Activity.java:1786) at com.businessplan.BusinessPlannerActivity.onCreate(BusinessPlannerActivity.java:64) at
Please check it yourself, or post it here.
I removed Gen folder and then again clean and build project and the error has gone.
Same, error went away after a clean project and do a rebuild.

Categories

Resources