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);
}
Related
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
}
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 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);
Anybody experienced with libgdx and genymotion?
I'm trying to get a libgdx game running on genymotion android emulator - http://www.genymotion.com/
Everytime I try to run on genymotion I get the following exception:
java.lang.ExceptionInInitializerError
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
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)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx' for target: Linux, 32-bit
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:113)
at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:34)
at com.badlogic.gdx.backends.android.AndroidApplication.<clinit>(AndroidApplication.java:61)
... 15 more
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load gdx: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:109)
... 17 more
Any Ideas?
Works fine with AVD
Android API 16
libgdx 0.9.9
Genymotion 1.1.0
You should try to add the x86 native libraries to your libs folder as mentioned in this post
To use the x86 natives, simply copy the x86/ folder from the nightlies to your Android project’s libs/ folder (next to the armeabi and armeabi-v7a folder). The setup-ui will not add those libraries for you automatically. I opted to do it this way for the time being as x86 Android devices are super rare, and you’d just blow up the size of your APK unnecessarily.
I am using ActionBarShelock and some time get force close with this error cant find how to handle it .
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sps/com.sps.ui.activities.HomeActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
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.NullPointerException
at android.support.v4.app._ActionBarSherlockTrojanHorse.onCreatePanelMenu(_ActionBarSherlockTrojanHorse.java:52)
at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:556)
at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60)
at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:154)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393)
at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747)
at com.android.internal.policy.impl.PhoneWindow.restorePanelState(PhoneWindow.java:1677)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1627)
at android.app.Activity.onRestoreInstanceState(Activity.java:928)
at android.app.Activity.performRestoreInstanceState(Activity.java:900)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2037)
... 11 more
In the r7 support library, the version on which the current release (4.1.0) of ActionBarSherlock is based, the FragmentManager class checked if mActive != null before dispatching menu events to the fragments contained in the mAdded list. This code was copied into ActionBarSherlock since it uses its own MenuItem type and does its own dispatching.
In a subsequent release of the support library, it was found that this check was no longer representative of whether or not mAdded had been instantiated with a list or not. Commit 464b6f3c changed the conditional check to mAdded != null.
ActionBarSherlock has not had a release since this fix was made. However, it was updated on the dev branch in commit 69fe6fd to be included in the next release.