gpt4 book ai didi

java - Firebase RecyclerView : Not able to Query

转载 作者:行者123 更新时间:2023-12-02 03:48:07 24 4
gpt4 key购买 nike

我有一个关于查询的问题,我实际上是在尝试膨胀 View ,其中可以将添加为 friend 的人添加到 recyclerView 中。

@Override
public void onStart(){
super.onStart();
if(EmailPref!=null){

Log.e("SahajLOG", " EmailPref " +EmailPref);
FriendsData er=new FriendsData();
er.setEmailPref("sahaj9917730102@gmail");
final Firebase mFirebaseRef = new Firebase(constants.FIREBASE_URL+"rootssahaj/authGplus");
Query ref = mFirebaseRef.orderByChild("sahaj9917730102@gmail").equalTo("yes");


ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.e("SahajLOG", " dataSnapshot " + dataSnapshot);
}

@Override
public void onCancelled(FirebaseError firebaseError) {

}
});



FirebaseRecyclerAdapter<FriendsData,FriendsViewHolder> adapter=new FirebaseRecyclerAdapter<FriendsData, FriendsViewHolder>(
FriendsData.class,
R.layout.chat_view_list,
FriendsViewHolder.class,
ref

) {
@Override
protected void populateViewHolder(FriendsViewHolder friendsViewHolder, FriendsData s, int i) {
friendsViewHolder.mName.setText(s.getUserNAME());
friendsViewHolder.mStatus.setText(s.getStatus());
Picasso.with(context).load(s.getPicurl()).transform(new CircleTransform()).into(friendsViewHolder.mImageProfile);
}
};

recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
alphaAdapter.setDuration(500);
alphaAdapter.setInterpolator(new OvershootInterpolator(.5f));
alphaAdapter.setFirstOnly(false);
recyclerView.setAdapter(new ScaleInAnimationAdapter(alphaAdapter));


}



}

public static class FriendsViewHolder extends RecyclerView.ViewHolder{
ImageView mImageProfile;
android.widget.TextView mName;
android.widget.TextView mStatus;

public FriendsViewHolder(View itemView) {
super(itemView);
mImageProfile=(ImageView)itemView.findViewById(R.id.profilePICC);
mName=(android.widget.TextView)itemView.findViewById(R.id.NameUSER);
mStatus=(android.widget.TextView)itemView.findViewById(R.id.Status);

}


}

错误是:

Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "sahaj9917730102@gmail" (class com.rana.sahaj.myyu.FriendsData), not marked as ignorable (5 known properties: , "status", "sahaj", "picurl", "userNAME", "emailPref"])

我尝试了很多解决方案,因为电子邮件不一致,所以我无法在 FriendsData 类中定义它我试图让它被忽略,但它表明我正在复制 jackson 文件

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/ASL2.0 File1: C:\Users\Sahaj.gradle\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-mapper-asl\1.9.13\1ee2f2bed0e5dd29d1cb155a166e6f8d50bbddb7\jackson-mapper-asl-1.9.13.jar File2: C:\Users\Sahaj.gradle\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-core-asl\1.9.13\3c304d70f42f832e0a86d45bd437f692129299a4\jackson-core-asl-1.9.13.jar`

那我该怎么办,有什么解决办法吗?

我的 Firebase 数据屏幕截图

ScreenShot here

GRADLE 文件

  apply plugin: 'com.android.application'



android {
compileSdkVersion 23
buildToolsVersion '23.0.2'

dataBinding {
enabled = true
}

defaultConfig {
applicationId "com.rana.sahaj.myyu"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
renderscriptTargetApi 20
renderscriptSupportModeEnabled true

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.github.afollestad.material-dialogs:core:0.8.5.4@aar') {
transitive = true
}
compile('com.github.coyarzun89:fabtransitionactivity:0.1.1') {
exclude module: 'CircularReveal'
}
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'org.lucasr.dspec:dspec:0.1.1'
compile 'com.firebase:firebase-client-android:2.5.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.github.greenfrvr:rubber-loader:1.1.2@aar'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.koushikdutta.ion:ion:2.1.7'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'jp.wasabeef:blurry:1.0.5'
compile 'in.workarounds.typography:typography:0.0.8'
compile 'konifar:fab-transformation:1.0.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.github.dmytrodanylyk:android-morphing-button:98a4986e56'
compile 'jp.wasabeef:recyclerview-animators:2.2.1'
compile 'net.sjava:advancedasynctask:1.0.1'
compile 'com.firebaseui:firebase-ui:0.3.1'
// compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'

}

编辑:添加 FriendsData 类

public class FriendsData {
String picurl;
String userNAME;
String status;
String sahaj;
String EmailPref="sahaj9917730102@gmail";


public String getSahaj() {
return sahaj;
}

public void setSahaj(String sahaj) {
this.sahaj = sahaj;
}

public String getEmailPref() {
return EmailPref;
}

public void setEmailPref(String emailPref) {
EmailPref = emailPref;
}




public FriendsData(){

}

public String getPicurl() {
return picurl;
}

public void setPicurl(String picurl) {
this.picurl = picurl;
}

public String getUserNAME() {
return userNAME;
}

public void setUserNAME(String userNAME) {
this.userNAME = userNAME;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}



}

在此 EmailPref 正在针对非常个人用户进行更改,因此我不会在类中对其进行硬编码

最佳答案

这不是运行时 java 代码的问题,而是构建的问题。尝试将其添加到 build.gradle

android block 中
android {

// ... other stuff

packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}

关于java - Firebase RecyclerView : Not able to Query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36143837/

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