【问题标题】:I want to add firebase dependency我想添加firebase依赖
【发布时间】:2020-01-17 07:30:01
【问题描述】:

请哪个 firebase 依赖项允许我使用 firebase 方法 mFireBaseRef = new Firebase("https://MonAirtelEtMoi.firebaseio.com");,只有 firebase 会抛出错误 not resolved

public class AddTodo extends AppCompatActivity {
    private FirebaseRecyclerOptions<DataSetFire> options;
    private FirebaseRecyclerAdapter<DataSetFire, FirebaseViewHolder> adapter;
    DatabaseReference rootRef,demoRef;
    ListView listView;
    Firebase mRef;

    mRef = new Firebase("https://<myURL>..");
    private ArrayList<DataSetFire> arrayList;
//Important in Viewing data

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_todo);
        listView= (ListView) findViewById(R.id.listViewfortodo);


        FloatingActionButton fab = findViewById(R.id.floatingActionButton);
        rootRef= FirebaseDatabase.getInstance().getReference().child("ToDo");
        rootRef.keepSynced(true);
        String title= getIntent().getStringExtra("title");
        String description = getIntent().getStringExtra("description");

        fab.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                Intent intent= new Intent(view.getContext(), TodoContent.class);
                startActivity(intent);
            }
        });


listView.setAdapter(new FirebaseListAdapter<com.example.guide.Populate>(this,com.example.guide.Populate.class, android.R.layout.two_line_list_item,rootRef) {
    // Populate view as needed
    @Override
    protected void populateView(View view, Populate populate, int position) {
        ((TextView) view.findViewById(android.R.id.text1)).setText(populate.getTitle());
        ((TextView) view.findViewById(android.R.id.text2)).setText(populate.getDescription());
    }
});
    }

}

请哪个 firebase 依赖项允许我使用 firebase 方法mFireBaseRef = new Firebase("https://MonAirtelEtMoi.firebaseio.com"); 只有 firebase 抛出错误未解决。

【问题讨论】:

  • 你在 Gradle 文件中添加依赖了吗?
  • 你想要什么firebase实时数据库???
  • 在代码中 mRef 抛出错误..
  • Firebase 带有红色下划线
  • 请出示您的 App Gradle 文件。并提供他人所需的信息,以便我们为您提供帮助

标签: android firebase android-layout firebase-realtime-database


【解决方案1】:

在您的根级(项目级)Gradle 文件 (build.gradle) 中,添加规则以包含 Google Services Gradle 插件。检查您是否也有 Google 的 Maven 存储库。

buildscript {

repositories {
// Check that you have the following line (if not, add it):
google()  // Google's Maven repository
}

dependencies {
// ...

// Add the following line:
  classpath 'com.google.gms:google-services:4.3.3'  // Google Services plugin
  }
}

allprojects {
 // ...

 repositories {
 // Check that you have the following line (if not, add it):
 google()  // Google's Maven repository
 // ...
  }
}

在您的模块(应用级)Gradle 文件(通常是 app/build.gradle)中,应用 Google Services Gradle 插件:

apply plugin: 'com.android.application'
// Add the following line:
apply plugin: 'com.google.gms.google-services'  // Google Services plugin

 android {
  // ...
 }

【讨论】:

  • 仍然抛出错误
猜你喜欢
  • 1970-01-01
  • 2021-08-09
  • 2018-04-25
  • 2020-01-04
  • 1970-01-01
  • 2019-05-22
  • 2018-11-15
  • 2018-11-28
  • 1970-01-01
相关资源
最近更新 更多