2017-03-21 1 views
0

내가 내 프로젝트를 빌드하려고 할 때 나는 아래 오류 코드를 제공합니다. 안드로이드 스튜디오를 2.3.After로 업데이트하기 전에 잘 작동합니다.이 오류가 발생합니다. 스트라이프를 사용하고 있습니다. API 버전 2016-07-06스트라이프 안드로이드 오류 없음 적절한 생성자

코드

Stripe stripe = new Stripe(); 
    stripe.createToken(card, publishableApiKey, new TokenCallback() { 
     public void onSuccess(MediaSession.Token token) { 
     // TODO: Send Token information to your backend to initiate a charge 
     Log.d("StripeToken", "MediaSession.Token created: " + token.toString()); 
     Toast.makeText(getApplicationContext(),"MediaSession.Token created: " + token.toString(), //getId(),Toast.LENGTH_LONG).show(); 
    } 

오류

Error:(100, 13) error: no suitable constructor found for Stripe(no arguments) 
constructor Stripe.Stripe(Context) is not applicable 
(actual and formal argument lists differ in length) 
constructor Stripe.Stripe(Context,String) is not applicable 
(actual and formal argument lists differ in length) 
+0

일부 매개 변수가있는 Striple 생성자와 비슷합니다. –

+0

오류 메시지가 분명하지 않습니다. 'Stripe' 클래스에는 매개 변수가없는 생성자가 없습니다. 매개 변수에 뭔가를 전달해야합니다. –

+0

하지만 안드로이드 스튜디오를 업데이트하기 전에 같은 코드가 나를 위해 일했습니다 – satya

답변

2

당신은 당신의 Stripe 객체 생성자에 Context 인수를 전달해야합니다. Stripe 객체에 대해서는 더 이상 arg가없는 생성자가 없습니다 (즉, 2.1.0 -> 3.0.0으로 바뀌 었습니다).

Stripe 라이브러리 업그레이드 만 Android Studio 업그레이드와 아무 관련이 없습니다.

0

@mrmcduff가 맞습니다.

올바른 방법은 아래 documentation에서 찾으십시오.

Stripe stripe = new Stripe(mContext, "pk_test_6pRNASCoBOKtIshFeQd4XMUh"); 
stripe.createToken(
    card, 
    new TokenCallback() { 
    public void onSuccess(Token token) { 
     // Send token to your server 
    } 
    public void onError(Exception error) { 
     // Show localized error message 
     Toast.makeText(getContext(), 
     error.getLocalizedString(getContext()), 
     Toast.LENGTH_LONG 
    ).show(); 
    } 
    } 
)