我遇到了有关查询的问题, 我实际上正在尝试使用inflate视图,其中添加为朋友的人可以添加到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);
}
}
错误是:
引起:com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段“sahaj9917730102 @gmail”(类com.rana.sahaj.myyu.FriendsData),未标记为可忽略(5个已知属性:,“状态“,”sahaj“,”picurl“,”userNAME“,”emailPref“])
我试了很多soln因为电子邮件不一致所以我不能在FriendsData类中定义它 我试图让它可以忽略,但它显示我复制杰克逊文件的帽子
错误:任务':app:transformResourcesWithMergeJavaResForDebug'的执行失败。 com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在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数据截图
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中正在为非常个人用户进行更改,因此我在课堂上对其进行了硬编码
答案 0 :(得分:1)
这不是运行时java代码的问题,而是你的构建问题。请尝试在android
build.gradle
块中添加此内容
android {
// ... other stuff
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
答案 1 :(得分:1)
我正在查看您提供的快照。您有几个dispatch_async(dispatch_get_main_queue()) {
//code here
}
个用户。在它们中,它们具有键值对,键为dummy_n@gmail
。这是有道理的,因为你的错误说:
无法识别的字段“sahaj9917730102 @gmail”
在sahaj9917730102@gmail
对象中,您没有包含该名称的字段。但是,您确实拥有FriendsData
,status
,sahaj
,picurl
和userNAME
。您需要从仪表板中删除这些内容,或修改emailPref
对象以获得具有该名称的值
如果要将其添加为字段,请修改对象,如下所示:
FriendsData
我明白这不切实际,但我给了你解决方案,这样你才能理解问题。您需要更改它,以便不需要对值进行硬编码。我不确定值的目的,但我会推荐一个布尔列表?即:
public class FriendsData {
String picurl;
String userNAME;
String status;
String sahaj;
String sahaj9917730102@gmail; // this is the key NAME, not value.
//all your accessors
}
然后添加到它,你可以做到
public class FriendsData {
//others
Map<String, Boolean> emails = new HashMap<>();
///...
}