building the attached test, I can see the permission is correctly added to
the resulting test apk.
jedo-macbookpro2:androidManifestInTest.tst jedo$
~/oss/adt/sdk/build-tools/21.1.1/aapt l -a
./build/outputs/apk/androidManifestInTest.tst-debug-androidTest-unaligned.apk
AndroidManifest.xml
resources.arsc
classes.dex
META-INF/MANIFEST.MF
META-INF/CERT.SF
META-INF/CERT.RSA
Resource table:
Package Groups (1)
Package Group 0 id=0x7f packageCount=1 name=com.android.tests.basic.test
Package 0 id=0x7f name=com.android.tests.basic.test
type 1 configCount=1 entryCount=1
spec resource 0x7f020000
com.android.tests.basic.test:string/app_name: flags=0x00000000
config (default):
resource 0x7f020000 com.android.tests.basic.test:string/app_name:
t=0x03 d=0x00000000 (s=0x0008 r=0x00)
Android manifest:
N: android=http://schemas.android.com/apk/res/android
E: manifest (line=2)
A: package="com.android.tests.basic.test" (Raw:
"com.android.tests.basic.test")
E: uses-sdk (line=5)
A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
A: android:targetSdkVersion(0x01010270)=(type 0x10)0x10
E: instrumentation (line=9)
A: android:label(0x01010001)="Tests for com.android.tests.basic"
(Raw: "Tests for com.android.tests.basic")
A: android:name(0x01010003)="android.test.InstrumentationTestRunner"
(Raw: "android.test.InstrumentationTestRunner")
A: android:targetPackage(0x01010021)="com.android.tests.basic" (Raw:
"com.android.tests.basic")
A: android:handleProfiling(0x01010022)=(type 0x12)0x0
A: android:functionalTest(0x01010023)=(type 0x12)0x0
E: meta-data (line=15)
A: android:name(0x01010003)="listener" (Raw: "listener")
A:
android:value(0x01010024)="android.support.test.internal.runner.listener.ManifestListener"
(Raw: "android.support.test.internal.runner.listener.ManifestListener")
E: uses-permission (line=20)
A:
android:name(0x01010003)="android.permission.AUTHENTICATE_ACCOUNTS" (Raw:
"android.permission.AUTHENTICATE_ACCOUNTS")
E: permission-group (line=22)
A: android:label(0x01010001)=@0x7f020000
A: android:name(0x01010003)="foo.permission-group.COST_MONEY" (Raw:
"foo.permission-group.COST_MONEY")
A: android:description(0x01010020)=@0x7f020000
E: permission (line=27)
A: android:label(0x01010001)=@0x7f020000
A: android:name(0x01010003)="foo.permission.RECEIVED_SMS" (Raw:
"foo.permission.RECEIVED_SMS")
A:
android:permissionGroup(0x0101000a)="foo.permission-group.COST_MONEY" (Raw:
"foo.permission-group.COST_MONEY")
A: android:description(0x01010020)=@0x7f020000
E: application (line=33)
A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
E: uses-library (line=34)
A: android:name(0x01010003)="android.test.runner" (Raw:
"android.test.runner")
On Tue Jan 06 2015 at 9:33:19 AM Jerome Dochez <[email protected]> wrote:
> 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 <[email protected]> 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("[email protected]", "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 <[email protected]>
>>>> 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 [email protected].
>>>>> 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 [email protected].
>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.