title: NullPointerException when running from Google Play but not from Android Studio
body: <p>I'm having a big issue, I do not know what's happening, I've uploaded an app to Play Store because when I was running it on an Emulator or even on my real device it wasn't crashing, but now when I download it from Google Play it says : </p>
  
  <pre><code>java.lang.NullPointerException: 
    at com..onBindViewHolder (ChooseCard.java)
    or                     .onCreateViewHolder (ChooseCard.java)
    at com..onBindViewHolder (ChooseCard.java)
    or                     .onCreateViewHolder (ChooseCard.java)
    at com.firebase.ui.database.FirebaseRecyclerAdapter.getItemCount (FirebaseRecyclerAdapter.java)
    or                     .onBindViewHolder (FirebaseRecyclerAdapter.java)
    or                     .onChildChanged (FirebaseRecyclerAdapter.java)
    or                     .onError (FirebaseRecyclerAdapter.java)
    at com.yarolegovich.discretescrollview.InfiniteScrollAdapter.access$100 (InfiniteScrollAdapter.java)
    or                     .getItemCount (InfiniteScrollAdapter.java)
    or                     .getItemViewType (InfiniteScrollAdapter.java)
    or                     .onAttachedToRecyclerView (InfiniteScrollAdapter.java)
    or                     .onBindViewHolder (InfiniteScrollAdapter.java)
    or                     .onCreateViewHolder (InfiniteScrollAdapter.java)
    or                     .wrap (InfiniteScrollAdapter.java)
  </code></pre>
  
  <p>It's been days with this issue and I can't find it out, could you give me a hand please?</p>
  
  <p>There's my <code>build.gradle</code> implementations</p>
  
  <pre><code>implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation 'com.android.support:appcompat-v7:27.1.1'
  implementation 'com.android.support.constraint:constraint-layout:1.1.0'
  implementation 'com.android.support:design:27.1.1'
  implementation 'com.intuit.sdp:sdp-android:1.0.4'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.1'
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  implementation 'com.android.support:cardview-v7:27.1.1'
  implementation 'com.google.firebase:firebase-core:15.0.0'
  implementation 'com.google.firebase:firebase-auth:15.0.0'
  implementation 'com.google.android.gms:play-services-auth:15.0.0'
  implementation 'com.google.firebase:firebase-database:15.0.0'
  implementation 'com.anjlab.android.iab.v3:library:1.0.44'
  implementation 'com.firebaseui:firebase-ui-database:3.3.1'
  implementation 'com.onesignal:OneSignal:3.7.1'
  implementation 'com.yarolegovich:discrete-scrollview:1.3.2'
  implementation 'com.pranavpandey.android:dynamic-toasts:0.9.0'
  implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.11'
  implementation 'com.google.android.gms:play-services-analytics:15.0.0'
  .....
   dependencies {
          classpath 'com.android.tools.build:gradle:3.1.2'
          classpath 'com.google.gms:google-services:3.2.1'
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>I've updated my app on Google Play and nothing happens, still crashing on the same <code>Activity</code>, I do now know what to do to debug this, the problem is when I download the app from Google Play, on Emulator (even in a new emulator device is not crashing) and on my real device.</p>
  
  <p>As <a href="https://stackoverflow.com/users/558433/marcos-vasconcelos">@Marcos Vascondelos</a> said, I did Build > Genereate Signed APK > get the app-release.apk install it on my device and the problem is that I can not login it is going to this method : </p>
  
  <pre><code> @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
          if (requestCode == RC_SIGN_IN) {
              Task&lt;GoogleSignInAccount&gt; task = GoogleSignIn.getSignedInAccountFromIntent(data);
              try {
                  // Google Sign In was successful, authenticate with Firebase
                  GoogleSignInAccount account = task.getResult(ApiException.class);
                  firebaseAuthWithGoogle(account);
              } catch (ApiException e) {
                  // Google Sign In failed, update UI appropriately
                  Log.w(TAG, "Google sign in failed", e.getCause());
                  Toast with e.getCause is null
              }
          }
      }
  </code></pre>
  
  <p>If you want to see how do I login to not put more code on this question I put on this <a href="https://gist.github.com/joancolmenerodev/8bd1c0e9e4fe7ffcd951a9c4a0c05c2f#file-login-firebase-with-google" rel="noreferrer">GitHubGist</a></p>
  
  <p>I've read that it could be problems with SHA-1, but I don't know why on emulator is ok, device is ok, Google play is ok, but if I install the .apk directly it says null.</p>
  
  <h2>LAST EDIT</h2>
  
  <p>I see the problem is not on the <code>Firebase</code> call, is on the populate the list, I mean the products are caught correctly, but when I try to put into the list is where it crashes</p>
  
  <p>My <code>FirebaseRecyclerOptions</code> adapter looks like </p>
  
  <pre><code> final FirebaseRecyclerOptions&lt; CardPOJO &gt; options =
                      new FirebaseRecyclerOptions.Builder&lt; CardPOJO &gt;()
                              .setQuery(products_ref, CardPOJO.class)
                              .build();
  
  
  
              adapter = new   FirebaseRecyclerAdapter&lt; CardPOJO, CardHolder&gt;(options) {
                  @Override
                  public CardHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                      //inflate the single recycler view layout(item)
                      View view = LayoutInflater.from(parent.getContext())
                              .inflate(R.layout.card_product, parent, false);
                      final CardHolder cardViewHolder = new CardHolder(view);
                      return cardViewHolder;
                  }
  
  
  
                  @Override
                  public void onDataChanged() {
                      super.onDataChanged();
                      if(progressDialog!=null)progressDialog.dismiss();initViews();
                  }
  
  
                  @Override
                  protected void onBindViewHolder(final CardHolder holder, int position, final CardPOJO model) {
                      holder.itemView.setSelected(0== position); ////where you are in the list
                      holder.getLayoutPosition();
                      switch (model.getState()){
                          case "free":
                              holder.card_image.setImageResource();
                              break;
                          case "not_free":
                              if(userOwnsProduct(model.getProduct_id())){
                                  holder.card_image.setImageResource();
                              }
                              else{
                                  holder.card_image.setImageResource();
                              }
  
                              break;
                          default:
                              break;
                      }
                      holder.view.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                              if(model.getState().equals("free")){
                                  //normal stuff1
  
                              }
                              else{
                                  if (!readyToPurchase) {
                                      DynamicToast.makeError(mContext,"Problems with Google Play",Toast.LENGTH_SHORT).show();
                                      return;
                                  }
                                  root_ref.child("PurchasedProducts").child(currentUser).addValueEventListener(new ValueEventListener() {
                                      @Override
                                      public void onDataChange(DataSnapshot dataSnapshot) {
                                          if(dataSnapshot.hasChild(model.getProduct_id())){
                                              //Normal stuff
                                          }
                                          else{
                                              bp.purchase((Activity) mContext,model.getProduct_id());
                                          }
                                      }
  
                                      @Override
                                      public void onCancelled(DatabaseError databaseError) {
  
                                      }
                                  });
  
                              }
  
                          }
                      });
  
  
                  }
  
              };
              adapter.startListening();
  
  
  
              infiniteAdapter = InfiniteScrollAdapter.wrap(adapter);
              itemPicker.setAdapter(infiniteAdapter);
              //.setItemTransitionTimeMillis(DiscreteScrollViewOptions.getTransitionTime());
              itemPicker.setItemTransformer(new ScaleTransformer.Builder()
                      .setMinScale(0.5f)
                      .build());
  </code></pre>