ok the first thing to do is to check the resulting test apk. can you do a aapt l -a <path_to_test_apk> and check if the permission is there or not. On Mon Jan 05 2015 at 7:32:17 PM Alex Humesky <ahume...@gmail.com> wrote:
> Interestingly, the following also fails, where getTargetContext() is > changed to getContext(): > > Context testContext = getInstrumentation().*getContext*(); > PackageManager pm = testContext.getPackageManager(); > int r = pm.checkPermission( > Manifest.permission.AUTHENTICATE_ACCOUNTS, > testContext.getPackageName()); > assertEquals(PackageManager.PERMISSION_GRANTED, r); > > // Add a fake account > AccountManager accountManager = AccountManager.get(testContext); > Account account = new Account("t...@test.com", "com.test"); > boolean addedAccount = accountManager.*addAccountExplicitly*(account, > "password", new Bundle()); > > What's weird is that the assert passes, yet addAccountExplicity still > fails with > > java.lang.SecurityException: caller uid 10056 lacks any of > android.permission.AUTHENTICATE_ACCOUNTS > > > On Monday, January 5, 2015 10:05:22 PM UTC-5, Alex Humesky wrote: >> >> Correct, when I run the test (either through Android Studio or >> connectedAndroidTest task), the app doesn't seem to have the permission, >> and so trying to use the account manager fails. I've attached a project >> based on the androidManifestInTest sample found at >> http://tools.android.com/tech-docs/new-build-system >> >> Thanks again! >> >> >> On Monday, January 5, 2015 2:29:24 PM UTC-5, Jerome Dochez wrote: >>> >>> yes it is supposed to work. can you describe what you observe not >>> working, the permission is not added to the test app ? >>> >>> On Mon Jan 05 2015 at 11:12:36 AM Alex Humesky <ahum...@gmail.com> >>> wrote: >>> >>>> Hello adt-dev, >>>> I'm trying to write an integration test for a user registration >>>> activity, and so as part of the test's set up, I want to create some test >>>> accounts on the emulator. To do this requires the permission >>>> android.permission.AUTHENTICATE_ACCOUNTS. >>>> >>>> According to the Android Gradle Plugin release notes for >>>> version 0.13.0, I should be able to supply a manifest for the test app at >>>> src/androidTest/AndroidManifest.xml, but adding the permission there >>>> doesn't seem to work. I know the file is being read since adding a syntax >>>> error causes the build to fail. >>>> >>>> I noticed that renaming src/androidTest to src/debug makes the test >>>> work if I launch the test from Android Studio, but then the tests don't get >>>> picked up with the connectedAndroidTest task. >>>> >>>> I'm using Android Studio version 1.0.2 and Android Gradle Plugin 1.0.0 >>>> and a regular project layout. >>>> >>>> Is merging uses-permission from androidTest/AndroidManifest.xml >>>> supposed to work? >>>> >>>> Thanks >>>> >>>> >>>> ps seems to be the same problem as described here: >>>> http://stackoverflow.com/questions/26244998/androidmanifest-in- >>>> androidtest-directory-being-ignored >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "adt-dev" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to adt-dev+u...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- > You received this message because you are subscribed to the Google Groups > "adt-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to adt-dev+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "adt-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.