AndroidTest Manifest permission not detected

2019-07-11 03:01发布

问题:

I have androidTest Manifest that has this permission:

<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />

However, when I run the test, this permission is not set in my devDebug build. It only works when I add it to main/AndroidManifest.xml.

Full androidTest/AndroidManifest.xml,

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.test.mobile">

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="23"
        tools:overrideLibrary="android.support.test.uiautomator.v18" />
    <uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
</manifest>

Error:

Operation not allowed: java.lang.SecurityException: Package com.test.mobile has not requested permission android.permission.SET_ANIMATION_SCALE

I don't want to add this permission in main Manifest.

回答1:

Create a debug folder and add AndroidManifest.xml in it with the permission.