title: Firebase App is crashing
body: <p>I'm following this tutorial:- <a href="https://www.youtube.com/watch?v=x0ScnHJi8WY" rel="nofollow noreferrer">https://www.youtube.com/watch?v=x0ScnHJi8WY</a>
  and I don't know, why my app is crashing</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.vks_apps.blogs.MainActivity"&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>package com.vks_apps.blogs;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  
  public class MainActivity extends AppCompatActivity
  {
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu)
      {
          getMenuInflater().inflate(R.menu.main_menu,menu);
          return super.onCreateOptionsMenu(menu);
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item)
      {
          if(item.getItemId()==R.id.action_add)
          {
              startActivity(new Intent(MainActivity.this,PostActivity.class));
          }
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p><strong>activity_post.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.vks_apps.blogs.PostActivity"&gt;
  
      &lt;ImageButton
          android:id="@+id/imageSelect"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:adjustViewBounds="true"
          android:background="#00ffffff"
          android:scaleType="centerCrop"
          android:src="@mipmap/add_btn" /&gt;
  
      &lt;EditText
          android:id="@+id/titleField"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/imageSelect"
          android:layout_centerHorizontal="true"
          android:layout_marginLeft="20dp"
          android:layout_marginRight="20dp"
          android:layout_marginTop="20dp"
          android:background="@drawable/input_outline"
          android:hint="Post Title..."
          android:paddingBottom="15dp"
          android:paddingLeft="15dp"
          android:paddingRight="15dp"
          android:paddingTop="15dp"
          android:singleLine="true" /&gt;
  
      &lt;EditText
          android:id="@+id/descField"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/titleField"
          android:layout_centerHorizontal="true"
          android:layout_marginLeft="20dp"
          android:layout_marginRight="20dp"
          android:layout_marginTop="20dp"
          android:background="@drawable/input_outline"
          android:ems="10"
          android:hint="Post Description..."
          android:inputType="textMultiLine"
          android:paddingBottom="15dp"
          android:paddingLeft="15dp"
          android:paddingRight="15dp"
          android:paddingTop="15dp" /&gt;
  
      &lt;Button
          android:id="@+id/submitBtn"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:background="@color/colorPrimary"
          android:text="Submit Post"
          android:textColor="#ffffff" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>PostActivity.java</strong></p>
  
  <pre><code>package com.vks_apps.blogs;
  
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.net.Uri;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.text.TextUtils;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ImageButton;
  
  import com.google.android.gms.tasks.OnSuccessListener;
  import com.google.firebase.storage.FirebaseStorage;
  import com.google.firebase.storage.StorageReference;
  import com.google.firebase.storage.UploadTask;
  
  public class PostActivity extends AppCompatActivity
  {
      private ImageButton mSelectImage;
      public static final int GALLERY_REQUEST = 1;
      private Uri mImageUri = null;
      private EditText mPostTitle, mPostDesc;
      private Button mSubmitBtn;
      private StorageReference mStorage;
      private ProgressDialog mProgress;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_post);
  
          mSelectImage = (ImageButton)findViewById(R.id.imageSelect);
          mPostTitle = (EditText)findViewById(R.id.titleField);
          mPostDesc = (EditText)findViewById(R.id.descField);
          mSubmitBtn = (Button) findViewById(R.id.submitBtn);
          mProgress = new ProgressDialog(this);
  
          mStorage = FirebaseStorage.getInstance().getReference();
  
          mSelectImage.setOnClickListener(new View.OnClickListener()
          {
              @Override
              public void onClick(View view)
              {
                  Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
                  galleryIntent.setType("image/*");
                  startActivityForResult(galleryIntent,GALLERY_REQUEST);
              }
          });
  
          mSubmitBtn.setOnClickListener(new View.OnClickListener()
          {
              @Override
              public void onClick(View view)
              {
                  startPosting();
              }
          });
      }
  
      private void startPosting()
      {
          mProgress.setMessage("Posting to Blog...");
          mProgress.show();
  
          String title_val = mPostTitle.getText().toString().trim();
          String desc_val = mPostDesc.getText().toString().trim();
  
          if((!TextUtils.isEmpty(title_val)) &amp;&amp; (!TextUtils.isEmpty(desc_val)) &amp;&amp; (mImageUri != null))
          {
              StorageReference filepath = mStorage.child("Blog_Images").child(mImageUri.getLastPathSegment());
              filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;()
              {
                  @Override
                  public void onSuccess(UploadTask.TaskSnapshot taskSnapshot)
                  {
                      @SuppressWarnings("VisibleForTests") Uri downloadUri = taskSnapshot.getDownloadUrl();
                      mProgress.dismiss();
                  }
              });
          }
      }
  
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data)
      {
          super.onActivityResult(requestCode, resultCode, data);
          if(requestCode==GALLERY_REQUEST &amp;&amp; resultCode==RESULT_OK)
          {
              mImageUri = data.getData();
              mSelectImage.setImageURI(mImageUri);
          }
      }
  }
  </code></pre>
  
  <p><strong>app/build.gradle</strong></p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 26
      buildToolsVersion "26.0.0"
      defaultConfig {
          applicationId "com.vks_apps.blogs"
          minSdkVersion 19
          targetSdkVersion 26
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
      compile 'com.android.support:appcompat-v7:26.+'
      compile 'com.android.support:recyclerview-v7:26.+'
      compile 'com.android.support:cardview-v7:26.+'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
      compile 'com.google.firebase:firebase-database:10.0.1'
      compile 'com.google.firebase:firebase-storage:10.0.1'
      compile 'com.google.firebase:firebase-auth:10.0.1'
      compile 'com.firebaseui:firebase-ui-database:2.1.0'
  
      testCompile 'junit:junit:4.12'
  }
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  
  <p><strong>project/build.gradle</strong></p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      repositories {
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.3.3'
          classpath 'com.google.gms:google-services:3.1.0'
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          jcenter()
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.vks_apps.blogs"&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".PostActivity"&gt;&lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>res/drawable/input_outline.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;stroke android:color="@color/greyColor" android:width="1dp"/&gt;
      &lt;corners android:radius="5dp"/&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p><strong>res/values/colors.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;color name="colorPrimary"&gt;#0488d1&lt;/color&gt;
      &lt;color name="colorPrimaryDark"&gt;#0477bd&lt;/color&gt;
      &lt;color name="colorAccent"&gt;#FF4081&lt;/color&gt;
      &lt;color name="greyColor"&gt;#c2c2c2&lt;/color&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p><strong>LOGCAT</strong></p>
  
  <pre><code>07-23 23:22:31.904 6461-6461/com.vks_apps.blogs D/AndroidRuntime: Shutting down VM
  
  
                                                                    --------- beginning of crash
  07-23 23:22:31.904 6461-6461/com.vks_apps.blogs E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: com.vks_apps.blogs, PID: 6461
                                                                    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzac;
                                                                        at com.google.firebase.storage.FirebaseStorage.getInstance(Unknown Source)
                                                                        at com.vks_apps.blogs.PostActivity.onCreate(PostActivity.java:42)
                                                                        at android.app.Activity.performCreate(Activity.java:6662)
                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                        at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:154)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
                                                                     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzac" on path: DexPathList[[zip file "/data/app/com.vks_apps.blogs-2/base.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.vks_apps.blogs-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.vks_apps.blogs-2/lib/x86, /system/lib, /vendor/lib]]
                                                                        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                        at com.google.firebase.storage.FirebaseStorage.getInstance(Unknown Source) 
                                                                        at com.vks_apps.blogs.PostActivity.onCreate(PostActivity.java:42) 
                                                                        at android.app.Activity.performCreate(Activity.java:6662) 
                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) 
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
                                                                        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                        at android.os.Looper.loop(Looper.java:154) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6077) 
                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 
  </code></pre>
  
  <p>PS: Don't mark this question as duplicate, as I've already tried all the other methods. Here I've written the original code without any modification. Also I've uploaded the video of my app's crashing - You can see it: <a href="http://www.mediafire.com/file/xb61s4k0wojxy2z/app.mp4" rel="nofollow noreferrer">http://www.mediafire.com/file/xb61s4k0wojxy2z/app.mp4</a></p>
  
  <p>also I think it's happening because of this line :</p>
  
  <pre><code>mStorage = FirebaseStorage.getInstance().getReference();
  </code></pre>
  
  <p>because when i remove this line, my app is working fine, but i need this line to upload the file</p>