6

私は Android を試していますAccountManager

ユーザー名/パスワードを入力するための UI を表示するアカウント認証サービスがあります。

[設定]、[アカウント]、[アカウントの追加] の順に移動し、新しいアカウントの種類を選択すると、UI が表示されます。

[OK] をクリックすると、次のエラーが表示されます

04-24 14:48:29.334: E/AndroidRuntime(386): java.lang.SecurityException: 
    caller uid 10035 is different than the authenticator's uid

MyAccountAuthenticationService の唯一の方法:

@Override
public IBinder onBind(Intent intent) {
    return new MyAccountAuthenticator(this).getIBinder();
}

MyAccountAuthenticator:

@Override
public Bundle addAccount(AccountAuthenticatorResponse response, 
    String accountType, String authTokenType, String[] requiredFeatures, 
    Bundle options) throws NetworkErrorException {

    final Intent intent = new Intent(context, MyAccountCreatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

MyAccountCreatorActivityの断片onClick

AccountManager accManager = AccountManager.get(this);
Account newAccount = new Account(email, MyAccountAuthenticator.ACCOUNT_TYPE);
accManager.setPassword(newAccount, password);

で例外がスローされsetPasswordます。すでにすべてのアカウンティング権限が必要です。何が原因なのかわかりません。さらにコード/情報が必要な場合は、お問い合わせください。

ありがとうございました。

4

4 に答える 4

17

当たり前のようですが、認証サービスが AndroidManifest.xml で定義されていない場合にも、このエラーが表示されます。例えば:

<service android:name="your.AuthService">
    <intent-filter>
        <action android:name="android.accounts.AccountAuthenticator" />
    </intent-filter>
    <meta-data android:name="android.accounts.AccountAuthenticator"
         android:resource="@xml/authenticator" />
</service>
于 2013-06-06T20:57:35.510 に答える
4

@imran khanのおかげで、私の定数値がオーセンティケーターXML定義にあるものと「正確に」一致しないことを発見しました

于 2012-04-24T15:10:32.003 に答える
1

私の場合、<application>タグの外側のマニフェストで誤って AuthenticatorService を定義しました。宣言を内部に移動すると<application>、問題が修正されました。希望は誰かを助けるでしょう。

于 2016-05-08T16:48:26.277 に答える