Firebase app crash while uploading image
<p>My app needs to upload image to firebase storage and display it in a recyclerView. My first two images displays well on the list. But, as I try to upload the third image, the app crashes and also can't store the image on firebase. Each image size varies from 500KB to 700KB. I also have used android:largeHeap="true" in my manifest. What to do?</p>

<p>//Here's the code:</p>

<pre><code>public class PostActivity extends Activity {


private EditText postTitle;
private EditText postDescription;
private Button submitButton;
private Uri imageUri=null;
private StorageReference storage;
private ProgressDialog progressDialogue;
private DatabaseReference database;
public  String titleVal;
public String descriptionVal;
private ImageView mImageView;
private static final int GALLERY_REQUEST=1;


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

    storage= FirebaseStorage.getInstance().getReference();
    database= FirebaseDatabase.getInstance().getReference().child("Posts");





    mImageView=(ImageView) findViewById(R.id.imageView);

    postTitle=(EditText) findViewById(R.id.titleField);
    postDescription=(EditText)findViewById(R.id.descriptionField);
    submitButton=(Button) findViewById(R.id.submitPost);
    progressDialogue=new ProgressDialog(this);


    imageUri = Uri.parse(getIntent().getStringExtra("imageUri"));
    ImageView img = (ImageView) findViewById(R.id.imageView);
    img.setImageURI(imageUri);
</code></pre>

<p>//What happens after post is SUBMITED.</p>

<pre><code>    submitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startPosting();

        }
    });
}

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString("titleVal", titleVal);
    outState.putString("descriptionVal",descriptionVal );

}


private void startPosting() {


    titleVal=postTitle.getText().toString().trim();
    descriptionVal=postDescription.getText().toString().trim();



    if(!TextUtils.isEmpty(titleVal) &amp;&amp; !TextUtils.isEmpty(descriptionVal) &amp;&amp; imageUri!=null){
        progressDialogue.setMessage("আপলোড হচ্ছে......");
        progressDialogue.show();

        StorageReference filePath=storage.child("post_images").child(imageUri.getLastPathSegment());
        filePath.putFile(imageUri).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Uri downloadUrl=taskSnapshot.getDownloadUrl();
                Picasso.with(PostActivity.this).load(downloadUrl).into(mImageView);
                DatabaseReference newPost=database.push();
                newPost.child("title").setValue(titleVal);
                newPost.child("description").setValue(descriptionVal);
                newPost.child("image").setValue(downloadUrl.toString());





                progressDialogue.dismiss();
                Toast.makeText(getApplicationContext(), "Successfully Uploaded", Toast.LENGTH_LONG).show();

                startActivity(new Intent(PostActivity.this,HomeActivity.class));
            }
        });

    }else{
        Toast.makeText(getApplicationContext(), "Please provide a Title", Toast.LENGTH_LONG).show();
    }


    }

}
</code></pre>