fastlane screengrab:"没有请求权限android.permission.CHANGE_CONFIGURATION"

rca*_*rba 7 android screen-grab android-permissions fastlane fastlane-snapshot

我正在尝试在Nexus 5X API 26仿真器中执行命令fastlane screengrab.

这是我得到的结果:

rcarba$ fastlane screengrab 
    [?]  
    [16:00:51]: fastlane detected a Gemfile in the current directory
    [16:00:51]: however it seems like you don't use `bundle exec`
    [16:00:51]: to launch fastlane faster, please use
    [16:00:51]: 
    [16:00:51]: $ bundle exec fastlane screengrab
    [16:00:51]: 
    [16:00:51]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
    [16:00:51]: Successfully loaded '/Users/.../fastlane/Screengrabfile' 

    +----------------------------+-----------------------------------------------+
    |              Detected Values from './fastlane/Screengrabfile'              |
    +----------------------------+-----------------------------------------------+
    | app_package_name           | com.my.app                         |
    | app_apk_path               | app/build/outputs/apk/release/app-release.apk |
    | tests_apk_path             | app/build/outputs/apk/debug/app-debug.apk     |
    | locales                    | ["en-US"]                                     |
    | clear_previous_screenshots | true                                          |
    +----------------------------+-----------------------------------------------+

    [16:00:51]: Using `adb` found at /Users/.../Library/Android/sdk/platform-tools/adb which is not within the specified ANDROID_HOME at ~/Library/Android/sdk/
    [16:00:51]: The `aapt` command could not be found relative to your provided ANDROID_HOME at ~/Library/Android/sdk/
    [16:00:51]: Please ensure that the Android SDK is installed and you have the build tools downloaded

    +-----------------------------+------------------------------------------------+
    |                        Summary for screengrab 2.103.1                        |
    +-----------------------------+------------------------------------------------+
    | tests_package_name          | com.my.app.test                     |
    | android_home                | ~/Library/Android/sdk/                         |
    | locales                     | ["en-US"]                                      |
    | clear_previous_screenshots  | true                                           |
    | output_directory            | fastlane/metadata/android                      |
    | skip_open_summary           | false                                          |
    | app_package_name            | com.my.app                          |
    | test_instrumentation_runner | android.support.test.runner.AndroidJUnitRunner |
    | ending_locale               | en-US                                          |
    | app_apk_path                | app/build/outputs/apk/release/app-release.apk  |
    | tests_apk_path              | app/build/outputs/apk/debug/app-debug.apk      |
    | device_type                 | phone                                          |
    | exit_on_test_failure        | true                                           |
    | reinstall_app               | false                                          |
    +-----------------------------+------------------------------------------------+

    [16:00:51]: Limiting the test classes run by `screengrab` to just those that generate screenshots can make runs faster.
    [16:00:51]: Consider using the :use_tests_in_classes or :use_tests_in_packages option, and organize your tests accordingly.
    [16:00:51]: Clearing phoneScreenshots within fastlane/metadata/android
    [16:00:51]: $ /Users/.../Library/Android/sdk/platform-tools/adb devices -l
    [16:00:51]: ? List of devices attached
    [16:00:51]: ? emulator-5554          device product:sdk_gphone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:2
    [16:00:51]: $ /Users/.../Library/Android/sdk/platform-tools/adb -s emulator-5554 shell echo \$EXTERNAL_STORAGE
    [16:00:51]: ? /sdcard
    [16:00:51]: Cleaning screenshots on device
    ls: /sdcard/com.my.App/screengrab: No such file or directory
    [16:00:51]: Exit status: 1
    ls: /data/data/com.my.App/app_screengrab: No such file or directory
    [16:00:52]: Exit status: 1
    [16:00:52]: The `aapt` command could not be found on your system, so your app APK could not be validated
    [16:00:52]: Installing app APK
    [16:00:52]: $ /Users/.../Library/Android/sdk/platform-tools/adb -s emulator-5554 install -t -r app/build/outputs/apk/release/app-release.apk
    [16:01:00]: ? Success
    [16:01:00]: Installing tests APK
    [16:01:00]: $ /Users/.../Library/Android/sdk/platform-tools/adb -s emulator-5554 install -t -r app/build/outputs/apk/debug/app-debug.apk
    [16:01:06]: ? Success
    [16:01:06]: Granting the permission necessary to change locales on the device
    [16:01:06]: $ /Users/.../Library/Android/sdk/platform-tools/adb -s emulator-5554 shell pm grant com.skitude.AllegheUP android.permission.CHANGE_CONFIGURATION
    [16:01:07]: ? Operation not allowed: java.lang.SecurityException: Package com.my.App has not requested permission android.permission.CHANGE_CONFIGURATION
    Operation not allowed: java.lang.SecurityException: Package com.my.App has not requested permission android.permission.CHANGE_CONFIGURATION
    [16:01:07]: Exit status: 1

    [!] Exit status: 1
rcarba$
Run Code Online (Sandbox Code Playgroud)

这是通常发生于没有在AndroidManifest.xml文件中适当的权限问题,但是当我添加它,我不仅得到了同样的错误,也AndroidManifest.xml中似乎很抱怨: Android的明显错误

所以我尝试添加此线程中出现的这一行:权限仅授予系统应用程序

<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"
        tools:ignore="ProtectedPermissions" />
Run Code Online (Sandbox Code Playgroud)

但结果保持不变.

任何人都知道可能导致错误的原因是什么?

rca*_*rba 5

好的,只是构建一个新的调试 apk 并且它可以工作,我希望它可以帮助某人。

更新:现在我对它有了更多的了解,这可能是因为当我执行命令时,它总是使用相同的调试 apk,而且我在 androidManifest 上所做的更改并不重要。一旦我构建了新的调试 apk,androidManifest 的所有更改都会进入构建,当然,它当时就起作用了。