我是火基地的新手我试图用firebase制作我的第一个应用程序,它只是一个注册应用程序,有两个编辑文本和一个按钮 我添加了firebase依赖项和google-service。 json文件到我的测试项目
apply plugin: 'com.google.gms.google-services'
构建gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "dev.fbase.com.firebaseexample"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-auth:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
构建gradle(项目)依赖
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的点击代码是
public void register(){
String email = editTextEmail.getText().toString();
String password = editTextPassword.getText().toString();
if (TextUtils.isEmpty(email)||TextUtils.isEmpty(password))
{
Toast.makeText(MainActivity.this,"fill all the fields",Toast.LENGTH_SHORT).show();
return;
}
progressDialog.setMessage("connecting..");
progressDialog.show();
firebaseAuth.createUserWithEmailAndPassword(email,password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful())
{
progressDialog.hide();
Toast.makeText(MainActivity.this,"Registration Success",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(MainActivity.this,"Registration Failed",Toast.LENGTH_SHORT).show();
}
}
});
}
执行显示错误的程序时 这是日志;
03-14 13:31:31.585 1054-1772/system_process V/WindowManager: Adding window Window{f249820 u0 PopupWindow:5e4fee9} at 3 of 8 (after Window{d1abaee u0 dev.fbase.com.firebaseexample/dev.fbase.com.firebaseexample.MainActivity})
03-14 13:31:31.642 2331-2632/dev.fbase.com.firebaseexample W/EGL_emulation: eglSurfaceAttrib not implemented
03-14 13:31:31.642 2331-2632/dev.fbase.com.firebaseexample W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe242b580, error=EGL_SUCCESS
03-14 13:32:00.808 1054-1225/system_process W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client
03-14 13:32:00.846 1054-1502/system_process V/WindowManager: not Base app: Adding window Window{4bd695 u0 dev.fbase.com.firebaseexample/dev.fbase.com.firebaseexample.MainActivity} at 3 of 8
03-14 13:32:00.852 2331-2619/dev.fbase.com.firebaseexample W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
03-14 13:32:00.852 2331-2619/dev.fbase.com.firebaseexample W/GooglePlayServicesUtil: Google Play Store is missing.
03-14 13:32:00.911 2331-2632/dev.fbase.com.firebaseexample W/EGL_emulation: eglSurfaceAttrib not implemented
03-14 13:32:00.912 2331-2632/dev.fbase.com.firebaseexample W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe242b720, error=EGL_SUCCESS
03-14 13:32:01.335 2331-2632/dev.fbase.com.firebaseexample W/EGL_emulation: eglSurfaceAttrib not implemented
03-14 13:32:01.335 2331-2632/dev.fbase.com.firebaseexample W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe247da20, error=EGL_SUCCESS
03-14 13:32:01.721 2331-2632/dev.fbase.com.firebaseexample V/RenderScript: 0xeed9da00 Launching thread(s), CPUs 4
答案 0 :(得分:0)
尝试使用
的最新版本 compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
答案 1 :(得分:0)
您可以尝试使用真实设备吗?您的设备没有“ Google Play商店”。
您可以看到此日志。
03-14 13:32:00.852 2331-2619/dev.fbase.com.firebaseexample W/GooglePlayServicesUtil: Google Play Store is missing.
如果要使用Firebase,则需要安装了Google Play服务10或更高版本的android设备或simultor。