Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fastlane screengrab: "has not requested permission android.permission.CHANGE_CONFIGURATION"

I'm trying to execute the command fastlane screengrab in a Nexus 5X API 26 emulator.

This is the result I get:

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$

This is a problem that normally happens for not having the proper permission in the AndroidManifest.xml file, but when I add it, not only I get the same error, but also the AndroidManifest.xml seems to complain about that: Android Manifest Error

So I tried to add this line that appears in this thread: Permission is only granted to system app

<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"
        tools:ignore="ProtectedPermissions" />

but the results remain the same.

Anybody has a clue of what can cause that error?

like image 391
rcarba Avatar asked Sep 06 '18 15:09

rcarba


People also ask

How do you check all permission is granted in Android?

On your phone, open the Settings app. Permission manager. Tap a permission type. If you allowed or denied permission to any apps, you'll find them here.

What is Protectedpermissions in Android?

This is an error. Permissions with the protection level signature , privileged or signatureOrSystem are only granted to system apps. If an app is a regular non-system app, it will never be able to use these permissions.


1 Answers

Okay, just building a new debug apk and it works, I hope it helps someone.

Update: Now that I know more about it, this was probably because when I executed the command, it was always with the same debug apk, and it doesn't matter the changes I did on the androidManifest. Once I build the new debug apk, all the changes of the androidManifest went to the build, and of course, it worked then.

like image 124
rcarba Avatar answered Sep 23 '22 17:09

rcarba