Я последовал за этим description, чтобы добавить свой адаптер синхронизации.IllegalArgumentException: addAccount не поддерживается
Но есть Литты ошибка :-(
Когда я открываю Настройки -> Account -> Добавить учетную запись и выберите свой счет я получаю сообщение об ошибке
java.lang.IllegalArgumentException: addAccount not supported
at android.accounts.AccountManager.convertErrorToException(AccountManager.java:2147)
at android.accounts.AccountManager.-wrap0(AccountManager.java)
at android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:1993)
at android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69)
at android.os.Binder.execTransact(Binder.java:453)
Похоже, что эта авария приходит от преобразования Authenticator Java класса к классу Котлин.
Java-замки класса, как это
public class Authenticator extends AbstractAccountAuthenticator {
private final Context mContext;
// Simple constructor
public Authenticator(Context context) {
super(context);
mContext = context;
}
// Editing properties is not supported
@Override
public Bundle editProperties(AccountAuthenticatorResponse response,
String accountType) {
throw new UnsupportedOperationException();
}
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
String authTokenType, String[] requiredFeatures, Bundle options)
throws NetworkErrorException {
SyncUtilsKt.createSyncAccount(mContext);
final Bundle bundle = new Bundle();
bundle.putString(AccountManager.KEY_ACCOUNT_NAME, ConstantsKt.SYNC_ACCOUNT);
bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, BuildConfig.ACCOUNT_TYPE);
return bundle;
}
// Ignore attempts to confirm credentials
@Override
public Bundle confirmCredentials(AccountAuthenticatorResponse response,
Account account, Bundle options)
throws NetworkErrorException {
return null;
}
// Getting an authentication token is not supported
@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response,
Account account, String authTokenType, Bundle options)
throws NetworkErrorException {
throw new UnsupportedOperationException();
}
// Getting a label for the auth token is not supported
@Override
public String getAuthTokenLabel(String authTokenType) {
throw new UnsupportedOperationException();
}
// Updating user credentials is not supported
@Override
public Bundle updateCredentials(AccountAuthenticatorResponse response,
Account account, String authTokenType, Bundle options) throws NetworkErrorException {
throw new UnsupportedOperationException();
}
// Checking features for the account is not supported
@Override
public Bundle hasFeatures(AccountAuthenticatorResponse response,
Account account, String[] features) throws NetworkErrorException {
throw new UnsupportedOperationException();
}
}
После преобразования его в Котлин он блокирует как это:
class Authenticator(private val mContext: Context) : AbstractAccountAuthenticator(mContext) {
// Editing properties is not supported
override fun editProperties(response: AccountAuthenticatorResponse,
accountType: String): Bundle {
throw UnsupportedOperationException()
}
@Throws(NetworkErrorException::class)
override fun addAccount(response: AccountAuthenticatorResponse, accountType: String,
authTokenType: String, requiredFeatures: Array<String>, options: Bundle): Bundle {
createSyncAccount(mContext)
val bundle = Bundle()
bundle.putString(AccountManager.KEY_ACCOUNT_NAME, SYNC_ACCOUNT)
bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, BuildConfig.ACCOUNT_TYPE)
return bundle
}
// Ignore attempts to confirm credentials
@Throws(NetworkErrorException::class)
override fun confirmCredentials(response: AccountAuthenticatorResponse,
account: Account, options: Bundle): Bundle? {
return null
}
// Getting an authentication token is not supported
@Throws(NetworkErrorException::class)
override fun getAuthToken(response: AccountAuthenticatorResponse,
account: Account, authTokenType: String, options: Bundle): Bundle {
throw UnsupportedOperationException()
}
// Getting a label for the auth token is not supported
override fun getAuthTokenLabel(authTokenType: String): String {
throw UnsupportedOperationException()
}
// Updating user credentials is not supported
@Throws(NetworkErrorException::class)
override fun updateCredentials(response: AccountAuthenticatorResponse,
account: Account, authTokenType: String, options: Bundle): Bundle {
throw UnsupportedOperationException()
}
// Checking features for the account is not supported
@Throws(NetworkErrorException::class)
override fun hasFeatures(response: AccountAuthenticatorResponse,
account: Account, features: Array<String>): Bundle {
throw UnsupportedOperationException()
}
}
Я думаю, что там что-то было неправильно переделанный, но что?
, если у вас есть свой собственный 'AbstractAccountAuthenticator', вероятно, кто-то должен увидеть его код – pskink