{"record":{"id":"297334ed778bd611","repo":"material-components/material-components-android","slug":"cannot-set-framework-drawable-as-indeterminate-dra","errorCode":null,"errorMessage":"Cannot set framework drawable as indeterminate drawable.","messagePattern":"Cannot set framework drawable as indeterminate drawable\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/progressindicator/BaseProgressIndicator.java","lineNumber":431,"sourceCode":"      throw new IllegalArgumentException(\"Cannot set framework drawable as progress drawable.\");\n    }\n  }\n\n  /**\n   * Sets a new indeterminate drawable. It has to inherit from {@link IndeterminateDrawable}.\n   *\n   * @param drawable The new indeterminate drawable.\n   * @throws IllegalArgumentException if a framework drawable is passed in.\n   */\n  @Override\n  public void setIndeterminateDrawable(@Nullable Drawable drawable) {\n    if (drawable instanceof IndeterminateDrawable) {\n      ((DrawableWithAnimatedVisibilityChange) drawable).hideNow();\n      super.setIndeterminateDrawable(drawable);\n    } else if (!initialized) {\n      super.setIndeterminateDrawable(drawable);\n    } else {\n      throw new IllegalArgumentException(\n          \"Cannot set framework drawable as indeterminate drawable.\");\n    }\n  }\n\n  @Nullable\n  @Override\n  public DeterminateDrawable<S> getProgressDrawable() {\n    return (DeterminateDrawable<S>) super.getProgressDrawable();\n  }\n\n  @Nullable\n  @Override\n  public IndeterminateDrawable<S> getIndeterminateDrawable() {\n    return (IndeterminateDrawable<S>) super.getIndeterminateDrawable();\n  }\n\n  /**\n   * Returns whether or not this view is currently displayed in window, based on whether it is","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/progressindicator/BaseProgressIndicator.java#L413-L449","documentation":"BaseProgressIndicator.setIndeterminateDrawable requires an IndeterminateDrawable once the indicator is initialized; anything else throws IllegalArgumentException because Material's indeterminate animation delegates drive the drawable and a framework drawable cannot participate. The uninitialized branch exists only for the super constructor path.","triggerScenarios":"Calling setIndeterminateDrawable(drawable) with a framework AnimationDrawable or custom Drawable on an initialized LinearProgressIndicator/CircularProgressIndicator.","commonSituations":"Reusing code that customized android:indeterminateDrawable on ProgressBar; XML android:indeterminateDrawable with a non-Material drawable on a Material indicator.","solutions":["Remove custom indeterminate drawables; configure indeterminate appearance via indicator attributes (indicatorColor, indeterminateAnimationType, etc.)","If swapping drawables programmatically, only pass IndeterminateDrawable instances built for this indicator","Fall back to a standard ProgressBar when a custom indeterminate drawable is mandatory"],"exampleFix":"<!-- before -->\n<com.google.android.material.progressindicator.CircularProgressIndicator\n    android:indeterminateDrawable=\"@drawable/spin_animation\" ... />\n<!-- after -->\n<com.google.android.material.progressindicator.CircularProgressIndicator\n    app:indicatorColor=\"@color/brand\"\n    app:indeterminateAnimationType=\"contiguous\" ... />","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fun isSafeIndeterminateDrawable(d: Drawable?): Boolean = d is IndeterminateDrawable","tryCatchPattern":"catch (e: IllegalArgumentException) { Log.e(TAG, \"Rejected framework indeterminate drawable\", e) }","preventionTips":["Configure indeterminate looks via attributes, not drawables","Only pass IndeterminateDrawable instances created for this indicator","Avoid porting android:indeterminateDrawable overrides from ProgressBar"],"tags":["android","material-components","progressindicator","drawable"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}