Search code examples
androidandroidxandroid-glide

Cannot access fragmentclass file for android.support.v4.fragment not found


I am trying to do this in android studio:

Glide.with(getApplicationContext()).load(Uri.parse(url.get((int)(5)))).into(imageview6);

but it shows the following error

error: cannot access Fragment Glide.with(getApplicationContext()).load(Uri.parse(url.get((int)(5)))).into(imageview6);

Cannot access fragmentclass file for android.support.v4.fragment not found

I have tried Migrate to AndroidX but it simply says "no usage found".


Solution

  • Use getActivity() to get the context in Fragment class.

    Use getActivity() instead of getApplicationContext()

    Final the code will be

    Glide.with(getActivity()).load(Uri.parse(url.get((int)(5)))).into(imageview6);
    

    Hope this will work.