java.lang.NoClassDefFoundError: java.util.Objects[],but i don't know how to solve it,please help me!!!!
java.lang.NoClassDefFoundError: java.util.Objects[]
at com.yingshibao.gsee.fragments.DuoBeiClassFragment1.newInstance(DuoBeiClassFragment1.java)
onCreateLoader(DuoBeiClassFragment1.java)
onLoadFinished(DuoBeiClassFragment1.java)
getDownloadClassRoom(DuoBeiClassFragment1.java)
onLoaderReset(DuoBeiClassFragment1.java)
onLoadFinished(DuoBeiClassFragment1.java)
lambda$initSchedule$179(DuoBeiClassFragment1.java)
access$000(DuoBeiClassFragment1.java)
access$200(DuoBeiClassFragment1.java)
at com.yingshibao.gsee.fragments.DuoBeiClassFragment1$$Lambda$1.onClick(DuoBeiClassFragment1.java)
at android.view.View.performClick(View.java:4240)
at android.view.View$PerformClick.run(View.java:17729)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5166)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:768)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(NativeStart.java)
Take a look at this post maybe it will help you ....
java.lang.NoClassDefFoundError: java.util.Objects
The exception is thrown because all static methods of java.util.Objects are available above API 19 (Android 4.4.+).
in API 10 (Android 2.3.+) that method doesn't exist in that Android version and NoClassDefFoundError is thrown.
If you want to check api level programmatically you can do:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// your code available only above api 19
} else {
// compatibility code
}
Related
The class WebViewClassic throws a NullPointerException when it invokes addJavascriptInterface method on Android 4.3. I don't find the NullPointerException from the system source of android 4.3. addJavascriptInterface method
I think it should be a system bug. Help me please. thanks.
java.lang.NullPointerException
at android.webkit.WebViewClassic.addJavascriptInterface(WebViewClassic.java:4314)
at android.webkit.WebView.addJavascriptInterface(WebView.java:1533)
at com.browser.webview_checkmode.BrowserWebViewFactory$1.run(BrowserWebViewFactory.java:71)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5166)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
View.startDrag throws NPE and this is happening to me for Android API 15 but not API 22.
This issue is very easy to reproduce. Open Android Studio, create a template project with one blank activity using API 15. Adding the following logic to the floating action button:
fab.setOnLongClickListener(
new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
v.startDrag(ClipData.newPlainText("", ""), new View.DragShadowBuilder(v), null, 0);
return true;
}
}
);
The stacktrace for the error is the following:
E/View: Unable to initiate drag
java.lang.NullPointerException
at android.view.Surface.lockCanvas(Surface.java:77)
at android.view.View.startDrag(View.java:13869)
at test.dragdroptest.MainActivity$2.onLongClick(MainActivity.java:59)
at android.view.View.performLongClick(View.java:3827)
at android.view.View$CheckForLongPress.run(View.java:14571)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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)
Not sure what I did wrong here. I have been fighting this issue for two days and there is not much resource online about this. I cannot believe no one else had ran into the same issue...
Apparently, it only happens on the device I used for testing but not from emulator with the same API level. I guess there is no way I can get away from this issue :(
I am using a custom progress bar and it works on my physical phone just fine. However, I am created a tablet layout of my app and tried it on an emulator and it gives me this error message - NoSuchMethodError
Here is the piece of code where I am setting my custom progress bar:
line 34 is where I am setting the interterminateDrawable.
The minimum sdks version is 14
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mProgressBar.setVisibility(View.INVISIBLE);
mProgressBar.setIndeterminateDrawable(getDrawable(R.drawable.progress));
Here is the log:
java.lang.NoSuchMethodError: koemdzhiev.com.blinkmessage.LoginActivity.getDrawable
at koemdzhiev.com.blinkmessage.LoginActivity.onCreate(LoginActivity.java:34)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
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)
The getDrawable() convenience method on Context was added in API Level 21. Your tablet may be running an older version.
The minimum sdks version is 14
The build tools should have complained about your use of getDrawable() here. Either raise your minSdkVersion to 21, or use something else, such as the getDrawable() method on Resources (and you can get a Resources by calling getResources() on your activity).
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
seekBar.setProgressTintList(ColorStateList.valueOf(ContextCompat.getColor(main_activity, R.color.your_color)));
}
else
{
seekBar.getProgressDrawable().setColorFilter(main_activity.getResources().getColor(R.color.your_color), PorterDuff.Mode.MULTIPLY);
}
I am seeing this crash on android 4.0.3 version. All above versions are working fine. How to solve this crash ?
java.lang.NoSuchMethodError: android.view.View.setHasTransientState
at com.techmash.playo.fragments.AddFavAreaFragment$AreaAdapter$ViewHolder.onClick(AddFavAreaFragment.java:338)
at android.view.View.performClick(View.java:3524)
at android.view.View$PerformClick.run(View.java:14194)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4476)
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:816)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:583)
at dalvik.system.NativeStart.main(Native Method)
This method available in SDK starting API level 16. You can use ViewCompat from support library for previous versions.
ViewCompat.setHasTransientState(view, true);
I keep getting the bellow exception from some users:
java.lang.NullPointerException
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1414)
at android.app.Activity.startActivityForResult(Activity.java:2880)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
at android.app.Activity.startActivity(Activity.java:2986)
at com.google.android.gms.internal.bb$5.onClick(Unknown Source)
at android.view.View.performClick(View.java:2535)
at android.view.View$PerformClick.run(View.java:9130)
at android.os.Handler.handleCallback(Handler.java:618)
at android.os.Handler.dispatchMessage(Handler.java:123)
at android.os.Looper.loop(SourceFile:351)
at android.app.ActivityThread.main(ActivityThread.java:3826)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
at dalvik.system.NativeStart.main(Native Method)
I've found a similar problem here but it's not taken care of since April. All I know is that it was reproduced on a Samsung Galaxy Y (GT-S5360) and I'm using Google Maps Android API v2.
Do you have any idea how can I make a workaround for this?
I have the same error, I also use Google Maps API. It seems to happen on all Android versions and phones. Just to mention few:
AN10DG3, GT-I8190, F815, GT-I9300, GOOPHONE, HTC One, KFTT, MID8127, KFAPWI, AN10DG3
java.lang.NullPointerException
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1409)
at android.app.Activity.startActivityForResult(Activity.java:3351)
at android.app.Activity.startActivityForResult(Activity.java:3312)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
at android.app.Activity.startActivity(Activity.java:3522)
at android.app.Activity.startActivity(Activity.java:3490)
at com.google.android.gms.dynamic.a$5.onClick(Unknown Source)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
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: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)
as I read somewhere, solution is:
Above mentioned problem can occur if you have emulator or device in which google play services are not installed. I don't have perfect solution but I figured out some work around to save your app from crashing. In this case you have to follow simple steps
Override startActivityForResult(intent, requestcode)
In startActivityForResult add super call super.startActivityForResult in try catch and catch the NullPointerException
Easy its done Now you can trap the nullpointerexception here and add your error handling in catch
#Override
public void startActivityForResult(Intent intent, int requestCode) {
try {
super.startActivityForResult(intent, requestCode);
} catch (Exception e) {
// fixes Google Maps bug: http://stackoverflow.com/a/20905954/2075875
}
}
in my case crash in Instrumentation.java
line 1581,
android.util.SeempLog.record_str(377, intent.toString());
intent is null then NPE
not sure how to fix this