2017-04-09 13 views
0

私はここにチュートリアル以下午前:AWS:認証ハンドラjava.lang.AbstractMethodError:

04-09 01:56:42.557 16494-16494/umbc.edu.app E/AndroidRuntime: FATAL EXCEPTION: main 
                  Process: umbc.edu.app, PID: 16494 
                  java.lang.AbstractMethodError: abstract method "void com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.AuthenticationHandler.onSuccess(com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserSession, com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoDevice)" 
                   at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser$5$1.run(CognitoUser.java:639) 
                   at android.os.Handler.handleCallback(Handler.java:739) 
                   at android.os.Handler.dispatchMessage(Handler.java:95) 
                   at android.os.Looper.loop(Looper.java:145) 
                   at android.app.ActivityThread.main(ActivityThread.java:6862) 
                   at java.lang.reflect.Method.invoke(Native Method) 
                   at java.lang.reflect.Method.invoke(Method.java:372) 
                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 
:私は次のエラーを取得する

import android.content.Intent; 
import android.content.IntentFilter; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.View; 
import android.view.WindowManager; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.TextView; 
import android.widget.Toast; 
import com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserSession; 
import com.amazonaws.mobileconnectors.cognitoidentityprovider.continuations.AuthenticationContinuation; 
import com.amazonaws.mobileconnectors.cognitoidentityprovider.continuations.AuthenticationDetails; 
import com.amazonaws.mobileconnectors.cognitoidentityprovider.continuations.MultiFactorAuthenticationContinuation; 
import com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.AuthenticationHandler; 
import umbc.edu.helpers.AppHelper; 

public class MainActivity extends AppCompatActivity implements View.OnClickListener { 

EditText username, password; 
Button login; 
TextView create_acount; 
String username_, password_; 

String TAG = "MainActivity.class"; 

protected String tag = "MainActivity"; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    Log.w(tag, "onCreate()"); 
    setContentView(R.layout.activity_main); 
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); 
    username = (EditText) findViewById(R.id.username); 
    password = (EditText) findViewById(R.id.password); 
    login = (Button) findViewById(R.id.login_button); 
    login.setOnClickListener(this); 
    create_acount = (TextView) findViewById(R.id.create_account); 
    create_acount.setOnClickListener(this); 

} 

@Override 
protected void onPause() { 
    super.onPause(); 
    Log.w(tag, "onPause()"); 
} 

@Override 
protected void onResume() { 
    super.onResume(); 
    Log.w(tag, "onResume()"); 
} 

@Override 
protected void onDestroy() { 
    super.onDestroy(); 
    Log.w(tag, "onDestroy()"); 
} 

@Override 
protected void onStart() { 
    super.onStart(); 
    Log.w(tag, "onStart()"); 
} 

@Override 
protected void onStop() { 
    super.onStop(); 
    Log.w(tag, "onStop()"); 
} 

@Override 
public void onClick(View v) { 
    switch (v.getId()) { 
     case R.id.login_button: 
      username_ = username.getText().toString(); 
      password_ = password.getText().toString(); 

      if (!username_.matches("") && !password_.matches("")) { 
       AppHelper.init(getApplicationContext()); 
       AppHelper.getPool().getUser(username_).getSessionInBackground(authenticationHandler); 
      } 
      break; 
     case R.id.create_account: 
      Intent intent = new Intent(this, CreateAccountActivity.class); 
      startActivity(intent); 
      break; 
    } 
} 

AuthenticationHandler authenticationHandler = new AuthenticationHandler() { 

    @Override 
    public void onSuccess(CognitoUserSession cognitoUserSession) { 
     Log.d(TAG, "Auth Success"); 
     AppHelper.setCurrSession(cognitoUserSession); 

     //Go To Home Activity 
     startActivity(new Intent(MainActivity.this, HomeActivity.class)); 
    } 

    @Override 
    public void getAuthenticationDetails(AuthenticationContinuation authenticationContinuation, String username) { 
     // The API needs user sign-in credentials to continue 
     AuthenticationDetails authenticationDetails = new AuthenticationDetails(username_, password_, null); 

     // Pass the user sign-in credentials to the continuation 
     authenticationContinuation.setAuthenticationDetails(authenticationDetails); 

     // Allow the sign-in to continue 
     authenticationContinuation.continueTask(); 
    } 

    @Override 
    public void getMFACode(MultiFactorAuthenticationContinuation multiFactorAuthenticationContinuation) { 
     Toast.makeText(MainActivity.this, "GET MFA CODE CALLED", Toast.LENGTH_LONG).show(); 
    } 

    @Override 
    public void onFailure(Exception e) { 
     Toast.makeText(MainActivity.this, "Failed" + e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); 
    } 
}; 
} 

:ここ

http://docs.aws.amazon.com/cognito/latest/developerguide/tutorial-integrating-user-pools-android.html 

は私のコードです

どうすれば解決できますか?それは別のライブラリを使用しているかのようです。

答えて

0

私はそれを理解しました。

私はAWSのjarファイルとのlibsフォルダがありますが、私はまた私のgradle.buildファイルにfollwoingた:

compile 'com.amazonaws:aws-android-sdk-core:2.2.+' 
compile 'com.amazonaws:aws-android-sdk-ddb:2.2.+' 
compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.2.+' 

私はちょうどそれらを削除し、すべてが良かったの