It’s important to make configurations programmable to manage them codebase and enhance automation. Android has provided apkanalyzer to analyse test target apks easily. Before the command, we use aapt for example. But with the analyzer command, we can get apk related data from target release apks easily.
https://developer.android.com/studio/command-line/apkanalyzer
The below is a simple wrapper for adb and apkanalyzer written in Ruby. I’ve used it to integrate adb commands to integrate Ruby test code.
https://github.com/KazuCocoa/droid_adbs/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'test_helper' | |
| class DroidAdbsAnalyzerTest < Minitest::Test | |
| def setup | |
| @analyzer = DroidAdbs::Apkanalyzer.new "test/data/api.apk" | |
| end | |
| def test_package_id | |
| assert_equal "io.appium.android.apis", @analyzer.manifest_package_id | |
| end | |
| def test_print | |
| @analyzer.manifest_print | |
| assert File.size? './manifest_print.xml' | |
| File.delete './manifest_print.xml' if File.exist? './manifest_print.xml' | |
| end | |
| def test_version_name | |
| # Can be blank | |
| assert_equal "", @analyzer.manifest_version_name | |
| end | |
| def test_version_code | |
| # Can be "null" | |
| assert_equal "null", @analyzer.manifest_version_code | |
| end | |
| def test_min_sdk | |
| assert_equal "4", @analyzer.manifest_min_sdk | |
| end | |
| def test_target_sdk | |
| assert_equal "19", @analyzer.manifest_target_sdk | |
| end | |
| def test_permissions | |
| assert_equal [], @analyzer.manifest_permissions | |
| end | |
| def test_debuggable | |
| assert_equal true, @analyzer.manifest_debuggable | |
| end | |
| # TODO: Append tests for apk, resources and dex methods |
https://github.com/KazuCocoa/droid_adbs/blob/master/test/droid_adbs/analyzer_test.rb