{"record":{"id":"bc3d24ac28408fcd","repo":"HarlonWang/AVLoadingIndicatorView","slug":"didn-t-find-your-class-check-the-name-again","errorCode":null,"errorMessage":"Didn't find your class , check the name again !","messagePattern":"Didn't find your class , check the name again !","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"library/src/main/java/com/wang/avi/AVLoadingIndicatorView.java","lineNumber":177,"sourceCode":"     */\n    public void setIndicator(String indicatorName){\n        if (TextUtils.isEmpty(indicatorName)){\n            return;\n        }\n        StringBuilder drawableClassName=new StringBuilder();\n        if (!indicatorName.contains(\".\")){\n            String defaultPackageName=getClass().getPackage().getName();\n            drawableClassName.append(defaultPackageName)\n                    .append(\".indicators\")\n                    .append(\".\");\n        }\n        drawableClassName.append(indicatorName);\n        try {\n            Class<?> drawableClass = Class.forName(drawableClassName.toString());\n            Indicator indicator = (Indicator) drawableClass.newInstance();\n            setIndicator(indicator);\n        } catch (ClassNotFoundException e) {\n            Log.e(TAG,\"Didn't find your class , check the name again !\");\n        } catch (InstantiationException e) {\n            e.printStackTrace();\n        } catch (IllegalAccessException e) {\n            e.printStackTrace();\n        }\n    }\n\n    public void smoothToShow(){\n        startAnimation(AnimationUtils.loadAnimation(getContext(),android.R.anim.fade_in));\n        setVisibility(VISIBLE);\n    }\n\n    public void smoothToHide(){\n        startAnimation(AnimationUtils.loadAnimation(getContext(),android.R.anim.fade_out));\n        setVisibility(GONE);\n    }\n\n    public void hide() {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/HarlonWang/AVLoadingIndicatorView/blob/841f98d230b14f0617e541a8b421f8dd96acd030/library/src/main/java/com/wang/avi/AVLoadingIndicatorView.java#L159-L195","documentation":"This is a log-catch (not an exception) emitted by AVLoadingIndicatorView.setIndicator(String name) when reflection fails to load an indicator class. The library builds a fully-qualified class name from the given indicator name and calls Class.forName; if no class matches, ClassNotFoundException is caught and this message is logged, leaving the previous indicator in place. It means the requested loading-indicator name does not correspond to any class in the com.wang.avi.indicators package.","triggerScenarios":"Calling setIndicator(\"BallPulse\") (or the XML attribute indicatorName) with a name that does not match an indicator class name exactly — e.g. wrong casing, a display-style name like \"ball-pulse\" when string lookup expects the class simple name, or a name from a style/enum list not present in the dependency version.","commonSituations":"Typo or wrong casing of the indicator name; using a kebab-case name from older docs/versions where the lookup expects the class simple name; the indicator class was removed/renamed in a newer version of the library; building the class-name string yourself and getting the package prefix wrong; ProGuard/R8 stripping indicator classes in a minified release build.","solutions":["Use the exact class simple name of an indicator in com.wang.avi.indicators, e.g. setIndicator(\"BallPulseIndicator\") or a valid name like \"BallGridPulse\", \"BallClipRotate\", etc.","Check the version of the library you depend on and confirm the indicator exists in com.wang.avi.indicators for that version (names changed across releases).","Prefer setIndicator(Indicator) with a direct instance (e.g. avi.setIndicator(new BallPulseIndicator())) to bypass reflection entirely.","If using XML, set app:indicatorName to a valid name and ensure the custom view class is com.wang.avi.AVLoadingIndicatorView.","Check logcat for the full ClassNotFoundException context and disable code shrinking or add a keep rule for com.wang.avi.** if minification stripped the class.","Switch to AVLoadingIndicatorView v2's enum-style approach ( avi.setIndicator(Indicator) or the updated name constants) if you upgraded from v1 naming conventions."],"exampleFix":"// before\n avi.setIndicator(\"ball-pulse\"); // logs 'Didn't find your class'\n// after\n avi.setIndicator(\"BallPulseIndicator\"); // or avi.setIndicator(new BallPulseIndicator());","handlingStrategy":"validation","validationCode":"// Validate the indicator name before calling setIndicator(String)\npublic static boolean isValidIndicator(String name) {\n    if (name == null || name.isEmpty()) return false;\n    try {\n        Class.forName(\"com.wang.avi.indicators.\" + name + \"Indicator\");\n        return true;\n    } catch (ClassNotFoundException e) {\n        return false;\n    }\n}\n// usage: if (isValidIndicator(\"BallPulse\")) avi.setIndicator(\"BallPulse\");","typeGuard":"// Prefer the typed API and let the compiler enforce validity\npublic static <T extends Indicator> T indicatorOrNull(Class<T> clazz) {\n    try {\n        return clazz.newInstance();\n    } catch (Exception e) {\n        return null;\n    }\n}\nIndicator ind = indicatorOrNull(BallPulseIndicator.class);\nif (ind != null) avi.setIndicator(ind);","tryCatchPattern":"// Since the library only logs, guard by checking before/after, or call the typed overload in try-catch\ntry {\n    avi.setIndicator(userProvidedName); // only logs on failure\n} catch (Exception e) {\n    // defensive: fall back to a known-good indicator\n    avi.setIndicator(new BallPulseIndicator());\n}\n// Always verify: if (avi.getIndicator() == null) avi.setIndicator(new BallPulseIndicator());","preventionTips":["Use setIndicator(Indicator) with direct class instances instead of reflective string lookup.","Keep an exhaustive list of valid indicator names (from com.wang.avi.indicators package) and validate user/remote-supplied names against it.","Copy indicator names exactly as class simple names (case-sensitive), not kebab-case style labels.","Pin and review library versions; check release notes for renamed/removed indicators before upgrading.","Add ProGuard/R8 keep rules for com.wang.avi.** in minified builds.","Never pass null or empty strings to setIndicator(String)."],"tags":["android","reflection","class-not-found","avloadingindicatorview","configuration"],"backgroundTag":"class-not-found","analyzedSha":"841f98d230b14f0617e541a8b421f8dd96acd030","analyzedAt":"2026-09-10T11:17:57.257Z","contentChangedAt":"2026-09-10T11:17:57.257Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}