gpt4 book ai didi

android - 从 Google Play 但不是从 Android Studio 运行时出现 NullPointerException

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:09:42 34 4
gpt4 key购买 nike

我遇到了一个大问题,我不知道发生了什么,我已经将应用程序上传到 Play 商店,因为当我在模拟器或什至在我的真实设备上运行它时它没有崩溃,但现在当我从 Google Play 下载它时,它说:

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)

这个问题已经好几天了,我找不到,你能帮帮我吗?

这是我的build.gradle 实现

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'

编辑

我已经在 Google Play 上更新了我的应用程序,但没有任何反应,仍然在同一个 Activity 上崩溃,我现在知道如何调试它,问题是当我从Google Play,在模拟器上(即使在新的模拟器设备上也不会崩溃)和我的真实设备上。

作为@Marcos Vascondelos说,我做了 Build > Genereate Signed APK > get the app-release.apk install it on my device and the problem is that I can't login it is going to this method :

 @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<GoogleSignInAccount> 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
}
}
}

如果您想查看我如何登录才能不在这个问题上添加更多代码,我将在这个 GitHubGist 上添加

我读到它可能是 SHA-1 的问题,但我不知道为什么在模拟器上没问题,设备没问题,谷歌播放没问题,但如果我直接安装 .apk,它说 null。

最后编辑

我看到问题不在 Firebase 调用上,而是在填充列表上,我的意思是产品被正确捕获,但是当我尝试放入列表时它崩溃了

我的 FirebaseRecyclerOptions 适配器看起来像

 final FirebaseRecyclerOptions< CardPOJO > options =
new FirebaseRecyclerOptions.Builder< CardPOJO >()
.setQuery(products_ref, CardPOJO.class)
.build();



adapter = new FirebaseRecyclerAdapter< CardPOJO, CardHolder>(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());

最佳答案

记住,总是检查组件是否为空。比执行你的代码。示例:

if ("your_component" != null){
//your code
}

关于android - 从 Google Play 但不是从 Android Studio 运行时出现 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50022813/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com