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 onContext
was added in API Level 21. Your tablet may be running an older version.The build tools should have complained about your use of
getDrawable()
here. Either raise yourminSdkVersion
to 21, or use something else, such as thegetDrawable()
method onResources
(and you can get aResources
by callinggetResources()
on your activity).