android – FATAL EXCEPTION: main java.lang.NullPointerException: Argument must not be null

I throw an error when I click on the cardview, all data is transferred well from the firebase database, but on the photo it throws an error. I store the photo as a link in the firebase.I wanted to send a photo via inten as other parameters, but it does not accept a glide and I wanted to do it in this form, but it also throws an error, as you can see

This is my adapter

public class CourseAdapter extends RecyclerView.Adapter<CourseAdapter.CourseViewHolder> {

    Context context;
    List<Course> courses;

    public CourseAdapter(Context context, List<Course> courses) {
        this.context = context;
        this.courses = courses;
    }

    @NonNull
    @Override
    public CourseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View courseItems = LayoutInflater.from(context).inflate(R.layout.course_item, parent, false);
        return new CourseAdapter.CourseViewHolder(courseItems);
    }

    @Override
    public void onBindViewHolder(@NonNull CourseViewHolder holder, @SuppressLint("RecyclerView") int position) {
        holder.courseBG.setBackgroundColor(Color.parseColor(courses.get(position).getColor()));
 
        Glide.with(context).load("https://firebasestorage.googleapis.com/v0/b/store-c5503.appspot.com/o/unity.jpg?alt=media&token=26049fb0-9a55-4a9e-a49f-335a2ee6173f").into(holder.courseImage);

        holder.courseTitle.setText(courses.get(position).getTitle());
        holder.courseDate.setText(courses.get(position).getDate());
        holder.courseLevel.setText(courses.get(position).getLevel());

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, CoursePage.class);

                ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
                        (Activity) context,
                        new Pair<View, String>(holder.courseImage, "courseImage")
                        );
                ImageView coursePageImage = view.findViewById(R.id.coursePageImage);

                intent.putExtra("coursePageBg", Color.parseColor(courses.get(position).getColor()));
                intent.putExtra("courseBg", Color.parseColor(courses.get(position).getColor()));
                intent.putExtra("courseTitle",courses.get(position).getTitle());
                Glide.with(context).load("https://firebasestorage.googleapis.com/v0/b/store-c5503.appspot.com/o/unity.jpg?alt=media&token=26049fb0-9a55-4a9e-a49f-335a2ee6173f").into(coursePageImage);
                intent.putExtra("courseDate",courses.get(position).getDate());
                intent.putExtra("courseLevel",courses.get(position).getLevel());
                intent.putExtra("courseText",courses.get(position).getText());


                context.startActivity(intent, options.toBundle());
            }
        });

    }

    @Override
    public int getItemCount() {
        return courses.size();
    }

    public static final class  CourseViewHolder extends RecyclerView.ViewHolder{
        LinearLayout courseBG;
        public ImageView courseImage, coursePageImage;
        TextView courseTitle, courseDate, courseLevel;
        public CourseViewHolder(@NonNull View itemView) {
            super(itemView);

            courseBG = itemView.findViewById(R.id.courseBG);
            courseImage = itemView.findViewById(R.id.courseImage);
            courseTitle = itemView.findViewById(R.id.courseTitle);
            courseDate = itemView.findViewById(R.id.courseDate);
            courseLevel = itemView.findViewById(R.id.courseLevel);
        }
    }
}

This is a CoursePage class:

package com.elcode.e_store;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.elcode.e_store.adapter.CourseAdapter;

public class CoursePage extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_course_page);

        LinearLayout coursePageBg = findViewById(R.id.courseBG);
        ConstraintLayout courseBg = findViewById(R.id.coursePageBg);
        ImageView courseImage = findViewById(R.id.coursePageImage);
        TextView courseTitle = findViewById(R.id.coursePageTitle);
        TextView courseDate = findViewById(R.id.coursePageDate);
        TextView courseLevel = findViewById(R.id.coursePageLevel);
        TextView courseText = findViewById(R.id.coursePageText);

        coursePageBg.setBackgroundColor(getIntent().getIntExtra("coursePageBg",0));
        courseBg.setBackgroundColor(getIntent().getIntExtra("courseBg", 0));
        courseImage.setImageResource(getIntent().getIntExtra("courseImage", 0));
        courseTitle.setText(getIntent().getStringExtra("courseTitle"));
        courseDate.setText(getIntent().getStringExtra("courseDate"));
        courseLevel.setText(getIntent().getStringExtra("courseLevel"));
        courseText.setText(getIntent().getStringExtra("courseText"));


    }
}

This is an error:

D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.elcode.e_store, PID: 31305
    java.lang.NullPointerException: Argument must not be null
        at com.bumptech.glide.util.Preconditions.checkNotNull(Preconditions.java:29)
        at com.bumptech.glide.util.Preconditions.checkNotNull(Preconditions.java:23)
        at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:841)
        at com.elcode.e_store.adapter.CourseAdapter$1.onClick(CourseAdapter.java:78)
        at android.view.View.performClick(View.java:6597)
        at android.view.View.performClickInternal(View.java:6574)
        at android.view.View.access$3100(View.java:778)
        at android.view.View$PerformClick.run(View.java:25885)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process: Sending signal. PID: 31305 SIG: 9

Leave a Comment