2016-06-08 3 views
1

createUserWithEmailAndPassword 메서드를 사용하여 사용자를 만들려고했지만 그렇게 할 수 없습니다.
OnAuthenticate 메서드가 호출되었지만 사용자 개체가 null이고 firebase 콘솔에 사용자가 생성되지 않습니다.
여기 내 코드는 온라인으로도 제공됩니다.firebase createUserWithEmailAndPassword가 안드로이드에서 작동하지 않습니다.

MAinActivity.java

private static FirebaseAuth mAuth; 
private static FirebaseAuth.AuthStateListener mAuthListener; 
private static String TAG = "RegisterDEbug"; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    //setContentView(R.layout.activity_main); 
    mAuth = FirebaseAuth.getInstance(); 
    mAuthListener = new FirebaseAuth.AuthStateListener() { 
     @Override 
     public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { 
      waitForDebugger(); 
      FirebaseUser user = firebaseAuth.getCurrentUser(); 
      if (user != null) { 
       // User is signed in 
       Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); 
      } else { 
       // User is signed out 
       Log.d(TAG, "onAuthStateChanged:signed_out"); 
      } 
      // ... 
     } 
    }; 
    mAuth.addAuthStateListener(mAuthListener); 
    mAuth.createUserWithEmailAndPassword("[email protected]", "corrfecthorsebatterystaple") 
      .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { 
       @Override 
       public void onComplete(@NonNull Task<AuthResult> task) { 
        waitForDebugger(); 
        Log.d(TAG, "Authentication successful"); 
        if (!task.isSuccessful()) { 
         //Toast.makeText(this, "Authentication failed.", Toast.LENGTH_SHORT).show(); 
        } 
       } 
      }); 
} 

app.properties

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.0' 

     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 
} 

app.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "com.pt.reg" 
     minSdkVersion 10 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.google.android.gms:play-services:9.0.2' 
    //compile 'com.google.android.gms:play-services-auth:9.0.2' 

    compile 'com.google.firebase:firebase-core:9.0.2' 
    compile 'com.google.firebase:firebase-auth:9.0.2' 
} 

apply plugin: 'com.google.gms.google-services' 

없음 te - 나는 잘 작동하는 사용자 생성을 위해 firebase에서 웹 솔루션을 시도했다.

답변

12

이 문제도 발생했습니다. 앱을 테스트하는 비밀번호가 너무 짧습니다. 더 긴 암호로 그것을 확장하고 그것은 효과가 있었다. 당신은 구글의 암호 복잡성 표준을 충족해야합니다.

+0

, U 감사합니다 – fayza

1

동일한 문제가 있습니다.

변화 :

mAuth.createUserWithEmailAndPassword("[email protected]", "corrfecthorsebatterystaple") 
      .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() 

에 : u는 내 시간을 절약

mAuth.createUserWithEmailAndPassword("[email protected]", "corrfecthorsebatterystaple") 
      .addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() 
관련 문제