构建gradle时出现以下错误。我不知道该怎么做请大家帮助我,但这个问题是在将工作室从2.3更新到3.0.1之后才提前工作正常,但现在它失败了。
我使用工作室2.3未检测到错误但更新后出现此错误。当我同步项目时没有在任何依赖项中检测到错误但是当我去运行/构建时出现以下错误:
类FirebaseRecyclerAdapter中的构造函数FirebaseRecyclerAdapter无法应用于给定类型; 必需:FirebaseRecyclerOptions found:Class,int,Class,DatabaseReference 原因:实际和正式的参数列表长度不同 其中T,VH是类型变量: T扩展了类FirebaseRecyclerAdapter中声明的Object VH扩展了FirebaseRecyclerAdapter类中声明的ViewHolder 错误:(74,11)错误:不是抽象的,并且不会覆盖FirebaseRecyclerAdapter中的抽象方法onBindViewHolder(InstaViewHolder,int,Insta) 错误:(81,13)错误:方法不会覆盖或实现超类型的方法 错误:任务':app:compileDebugJavaWithJavac'执行失败。
我的主要activity.java代码如下:
package com.example.dunia_technology.suaforum;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity {
private RecyclerView mInstaList;
private DatabaseReference mDatabase;
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mInstaList=(RecyclerView)findViewById(R.id.insta_list);
mInstaList.setHasFixedSize(true);
mInstaList.setLayoutManager(new LinearLayoutManager(this));
mDatabase=FirebaseDatabase.getInstance().getReference().child("InstaApp");
mAuth=FirebaseAuth.getInstance();
mAuthListener =new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
if(firebaseAuth.getCurrentUser()==null){
Intent loginIntent=new Intent(MainActivity.this,RegisterActivity.class);
loginIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(loginIntent);
}
}
};
}
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
@Override
protected void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
FirebaseRecyclerAdapter<Insta,InstaViewHolder> FBRA=new FirebaseRecyclerAdapter<Insta,InstaViewHolder> (
Insta.class,
R.layout.insta_row,
InstaViewHolder.class,
mDatabase
) {
@Override
protected void populateViewHolder(InstaViewHolder viewHolder, Insta model, int position) {
viewHolder.setTitle(model.getTitle());
viewHolder.setDesc(model.getDesc());
viewHolder.setImage(getApplicationContext(),model.getImage());
}
};
mInstaList.setAdapter(FBRA);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
public static class InstaViewHolder extends RecyclerView.ViewHolder{
public InstaViewHolder(View itemView){
super(itemView);
View mView=itemView;
}
public void setTitle(String title){
TextView post_title=(TextView) itemView.findViewById(R.id.textTitle);
post_title.setText(title);
}
public void setDesc(String desc){
TextView post_desc=(TextView) itemView.findViewById(R.id.textDescription);
post_desc.setText(desc);
}
public void setImage(Context ctx,String image){
ImageView post_image=(ImageView)itemView.findViewById(R.id.post_image);
//picasso.with(ctx).load(image).into(post_image);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
else if(id==R.id.addIcon){
Intent intent=new Intent(MainActivity.this,postActivity.class);
startActivity(intent);
enter code here
}
else if (id==R.id.logout){
mAuth.signOut();
}
return super.onOptionsItemSelected(item);
}
}