Ошибка
Caused by: java.lang.SecurityException: uid 10184 cannot get secrets for accounts of type:
Код
@Nullable
public static Account getSyncAccount(Context context)
{
AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.content_authority));
assert accountManager != null;
if (null == accountManager.getPassword(newAccount))
{
if (!accountManager.addAccountExplicitly(newAccount,"",null)) //Error here
{
return null;
}
onAccountCreated(newAccount,context);
}
return newAccount;
}
Служба аутентификатора
<service android:name = ".sync.ProductAuthenticatorService">
<intent-filter>
<action android:name = "android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data android:name = "android.accounts.AccountAuthenticator"
android:resource = "@xml/authenticator"/>
</service>
<!-- Sync Adapter Service -->
<service android:name = ".sync.ProductSyncService"
android:exported = "true"
>
<intent-filter>
<action android:name = "android.content.SyncAdapter"/>
</intent-filter>
<meta-data android:name = "android.content.SyncAdapter"
android:resource = "@xml/syncadapter"/>
</service>
Добавление
<uses-permission android:name = "Manifest.permission.GET_ACCOUNTS"/>
К вашему манифесту должен решить ваш SecurityException.
(Начиная с Android 6.0 (уровень API 23), если приложение использует подпись аутентификатора, который управляет учетной записью, ему не требуется разрешение «GET_ACCOUNTS» для чтения информации об этой учетной записи. На Android 5.1 и ниже всем приложениям требуется » GET_ACCOUNTS "разрешение на чтение информации о любой учетной записи.)
Пожалуйста, поясните, чего вы пытаетесь достичь и в чем проблема.