java.lang.RuntimeException:java.lang.NoSuchMethodException:<init> [class android.view.View] RecyclerAdapter

时间:2018-09-05 10:15:46

标签: java android

有人可以帮忙吗?我已经在这工作了好几天了,我已经尝试了几乎所有关于如何解决此问题的建议,但仍然无法解决。 这是我的保镖规则。

-dontwarn org.**
-dontwarn com.**
-dontwarn java.**
-dontwarn javax.**
-dontwarn sun.**



##  _______________________________________________________________________________________________________________

-keepattributes Signature
-keepattributes *Annotation*
-keepattributes EnclosingMethod
-keepattributes InnerClasses
-keep class android.support.v7.internal.** { *; }
-keep interface android.support.v7.internal.** { *; }
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-keep class android.support.v4.** { *; }
-keep class android.support.** { *; }

-keep interface android.support.** { *; }



-keep class com.google.firebase.quickstart.database.viewholder.** {
    *;
}

-keepclassmembers class com.google.firebase.quickstart.database.models.** {
    *;
}

-keep class com.google.firebase.database.** { *; }
-keep class com.firebase.ui.database.** { *; }
-keep class com.firebase.ui.database.FirebaseRecyclerAdapter
-keepclassmembers class com.firebase.ui.database.FirebaseRecyclerAdapter { *; }
-keep class com.xclusive.hypechat.ViewHolder.** { *; }
-keepclassmembers  class com.xclusive.hypechat.ViewHolder.** { *; }
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# If you want to enable optimization, you should include the
# following:
# -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
# -optimizationpasses 5
# -allowaccessmodification
#
# Note that you cannot just include these flags in your own
# configuration file; if you are including this file, optimization
# will be turned off. You'll need to either edit this file, or
# duplicate the contents of this file and remove the include of this
# file from your project's proguard.config path property.
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgent
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
    public static <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.** 

这是我的ViewHolder类。

public class ViewHolder
{
    public static class PostsViewHolder extends RecyclerView.ViewHolder
    {
        ImageView heartWhite, heartRed, comments;
        TextView likeString, viewComments;
        DatabaseReference Likesref, postRef, friendsRef;
        String online_User_Id;
        StringBuilder mUsers;
        String mLikesString;
        int countLikes, countComments;
        View mView;
        private final String post_key = null;
        Allusers mAllusers;
        Boolean LikedByCurrentUser;
        public PostsViewHolder(View itemView)
        {
            super(itemView);
            mView = itemView;
            comments = (ImageView) mView.findViewById(R.id.image_comment);
            heartWhite = (ImageView) mView.findViewById(R.id.post_heart_white);
            heartRed = (ImageView) mView.findViewById(R.id.post_heart_red);
            likeString = (TextView) mView.findViewById(R.id.id_like);
            viewComments = (TextView) mView.findViewById(R.id.view_comments);
            // ViewTime = (TextView) mView.findViewById(R.id.all_post_time);
            Likesref = FirebaseDatabase.getInstance().getReference().child("Likes");
            online_User_Id = FirebaseAuth.getInstance().getCurrentUser().getUid();
            friendsRef = FirebaseDatabase.getInstance().getReference().child("Friends").child(online_User_Id);
            postRef = FirebaseDatabase.getInstance().getReference().child("post").child(online_User_Id);

        }

        public void setUpWidget(final String post_key )
        {
            Likesref.addValueEventListener(new ValueEventListener()
            {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot)
                {
                    countLikes = (int) dataSnapshot.child(post_key).getChildrenCount();
                    if (dataSnapshot.child(post_key).hasChild(online_User_Id))
                    {
                        if (countLikes == 1)
                        {
                            //getLikesString();
                            countLikes = (int) dataSnapshot.child(post_key).getChildrenCount();
                            heartRed.setVisibility(View.VISIBLE);
                            heartWhite.setVisibility(View.INVISIBLE);
                            likeString.setText(("You Liked this "));
                        }
                        else if (countLikes > 1)
                        {
                            //getLikesString();
                            countLikes = (int) dataSnapshot.child(post_key).getChildrenCount();
                            heartRed.setVisibility(View.VISIBLE);
                            heartWhite.setVisibility(View.INVISIBLE);
                            likeString.setText(("You and ") + (Integer.toString(countLikes)) + (" others liked this"));
                        }

                    }
                    else if(countLikes == 0)
                    {
                        countLikes = (int) dataSnapshot.child(post_key).getChildrenCount();
                        heartWhite.setVisibility(View.VISIBLE);
                        heartRed.setVisibility(View.INVISIBLE);
                        likeString.setText(Integer.toString(countLikes) + (" Persons Liked this"));

                    }
                    else if(countLikes == 1)
                    {
                        // countLikes = (int) dataSnapshot.child(post_key).getChildrenCount();
                        heartWhite.setVisibility(View.VISIBLE);
                        heartRed.setVisibility(View.INVISIBLE);
                        likeString.setText(Integer.toString(countLikes) + (" Person Liked this"));

                    }
                    else if(countLikes > 1)
                    {
                        // countLikes = (int) dataSnapshot.child(post_key).getChildrenCount();
                        heartWhite.setVisibility(View.VISIBLE);
                        heartRed.setVisibility(View.INVISIBLE);
                        likeString.setText(Integer.toString(countLikes) + (" People Liked this"));
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });

        }


        public void setUser_name(String user_name)
        {
            TextView username = (TextView) mView.findViewById(R.id.all_post_username);
            username.setText(user_name);
        }
        public void setPostProfileImage(final Context ctx, final String postProfileImage)
        {
            final CircleImageView image = (CircleImageView) mView.findViewById(R.id.all_post_profile_image);

            Picasso.with(ctx).load(postProfileImage).fit().centerCrop().networkPolicy(NetworkPolicy.OFFLINE).placeholder(R.drawable.default_profile)
                    .into(image, new Callback() {
                        @Override
                        public void onSuccess() {

                        }

                        @Override
                        public void onError()
                        {
                            Picasso.with(ctx).load(postProfileImage).fit().centerCrop().placeholder(R.drawable.default_profile).into(image);

                        }
                    });
        }
        public void setTime(String time)
        {
            // TextView postTime = (TextView) mView.findViewById(R.id.all_post_time);
            //postTime.setText(" " + time);
        }
        public void setDate(String date)
        {
            TextView postdate = (TextView) mView.findViewById(R.id.all_post_date);
            postdate.setText("" + date);
        }
        public void setDescription(String description)
        {
            TextView postdescription = (TextView) mView.findViewById(R.id.post_description);
            postdescription.setText(description);
        }
        public void  setPostImage(Context ctx, String post_image)
        {
            ImageView newImage = (ImageView) mView.findViewById(R.id.display_post_image);
            Picasso.with(ctx).load(post_image).fit().centerCrop().into(newImage);

        }

        public void countComments(String post_key)
        {
            postRef.child(post_key).child("comments")
                    .addValueEventListener(new ValueEventListener() {
                        @Override
                        public void onDataChange(DataSnapshot dataSnapshot)
                        {
                            countComments = (int) dataSnapshot.getChildrenCount();
                            if(countComments ==0)
                            {
                                viewComments.setText(Integer.toString(countComments) + (" People commented on this"));
                            }
                            else if(countComments == 1)
                            {
                                viewComments.setText(Integer.toString(countComments) + (" Person commented on this"));
                            }
                            else if(countComments == 2)
                            {
                                viewComments.setText(Integer.toString(countComments) + (" People commented on this"));
                            }
                            else if(countComments > 2)
                            {
                                viewComments.setText(("View all ") + Integer.toString(countComments) + (" comments"));
                            }

                        }

                        @Override
                        public void onCancelled(DatabaseError databaseError) {

                        }
                    });
        }
    }
}

这是Fragment类。

@Override
public void onStart()
{
    super.onStart();
    Query postRefQuery = postRef.limitToLast(60);
                FirebaseRecyclerAdapter<Posts, ViewHolder.PostsViewHolder> firebaseRecyclerAdapter =
                        new FirebaseRecyclerAdapter<Posts, ViewHolder.PostsViewHolder>
                                (
                                        Posts.class,
                                        R.layout.all_post_layout,
                                        ViewHolder.PostsViewHolder.class,
                                        postRefQuery
                                ) {
                            @Override
                            protected void populateViewHolder(final ViewHolder.PostsViewHolder viewHolder, Posts model, int position) {}

如果有人可以看到我哪里出了问题,请帮忙指出,谢谢

0 个答案:

没有答案