{"id":462193,"date":"2025-06-05T15:01:28","date_gmt":"2025-06-05T15:01:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=462193"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=462193","title":{"rendered":"<span>Redroid<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 ReDroid?<\/h3>\n<p><strong>ReDroid<\/strong> \u2014 \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c\u0443 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0443 Android, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u043a\u0430\u043a Docker-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. ReDroid \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e Android-\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>ReDroid \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044f\u0434\u0440\u043e Linux \u0445\u043e\u0441\u0442-\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 anbox-\u043c\u043e\u0434\u0443\u043b\u044f, \u0447\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a Android \u0431\u0435\u0437 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 \u0441\u0440\u0435\u0434\u0435 CI\/CD, \u0433\u0434\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u044e\u0442 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h3>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u043e\u043c Android Studio:<\/h3>\n<p>ReDroid \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e UI-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 CI\/CD, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u0436\u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440 Android Studio \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0439 \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<h3>\u0420\u0443\u0447\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 ReDroid (Docker) \u0438 \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435 \u043e\u043a\u043e\u043b\u043e \u043c\u0438\u043d\u0443\u0442\u044b \u0434\u043b\u044f \u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438:<\/p>\n<pre><code class=\"bash\">docker run -d --name redroid --privileged -p 5555:5555 redroid\/redroid:15.0.0_64only-latest sleep 30 <\/code><\/pre>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u0441\u044c \u043a \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 ADB:<\/p>\n<pre><code class=\"bash\">adb connect localhost:5555 adb devices <\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043d\u0430 ReDroid \u043e\u0431\u0430 APK-\u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"bash\">adb -s localhost:5555 install .\/app\/build\/outputs\/apk\/debug\/app-debug.apk adb -s localhost:5555 install .\/app\/build\/outputs\/apk\/androidTest\/debug\/app-debug-androidTest.apk <\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0432\u0430\u0448\u0438 Espresso\/UI-\u0442\u0435\u0441\u0442\u044b \u0441 ADB:<\/p>\n<pre><code class=\"bash\">adb -s localhost:5555 shell am instrument -w your.package.name.test\/androidx.test.runner.AndroidJUnitRunner <\/code><\/pre>\n<p>\u0412\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u043b\u043e\u0433\u0438 \u043f\u043e\u0441\u043b\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">adb -s localhost:5555 logcat -d &gt; android-log.txt <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440:<\/p>\n<pre><code class=\"bash\">docker stop redroid &amp;&amp; docker rm redroid <\/code><\/pre>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/\/post_images\/de1\/6b6\/eec\/de16b6eec48c297063bb5aac29e792dc.png\" alt=\"Redroid\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/\/post_images\/de1\/6b6\/eec\/de16b6eec48c297063bb5aac29e792dc.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/\/post_images\/de1\/6b6\/eec\/de16b6eec48c297063bb5aac29e792dc.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>Redroid<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 Android-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043b\u044f UI-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<h4>\u0428\u0430\u0433 1: \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 app\/build.gradle<\/h4>\n<p>gradle<\/p>\n<pre><code>android {     defaultConfig {         testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"     } }  dependencies {     \/\/ \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043b\u044f UI-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'     androidTestImplementation 'androidx.test:runner:1.5.2'     androidTestImplementation 'androidx.test:rules:1.5.0'          \/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Espresso \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.5.1'     androidTestImplementation 'androidx.test.espresso:espresso-intents:3.5.1'          \/\/ JUnit \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c     androidTestImplementation 'androidx.test.ext:junit:1.1.5' } <\/code><\/pre>\n<h4>\u0428\u0430\u0433 2: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 UI-\u0442\u0435\u0441\u0442\u0430 \u0441 Espresso<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>app\/src\/androidTest\/java\/com\/example\/app\/MainActivityTest.java<\/code>:<\/p>\n<p>java<\/p>\n<pre><code class=\"java\">package com.example.app;  import androidx.test.espresso.matcher.ViewMatchers; import androidx.test.ext.junit.rules.ActivityScenarioRule; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest;  import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith;  import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText;  @RunWith(AndroidJUnit4.class) @LargeTest public class MainActivityTest {      @Rule     public ActivityScenarioRule&lt;MainActivity&gt; activityRule =         new ActivityScenarioRule&lt;&gt;(MainActivity.class);      @Test     public void welcomeTextIsDisplayed() {         \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0441 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f         onView(withId(R.id.welcome_text))             .check(matches(isDisplayed()))             .check(matches(withText(\"Hello World!\")));     }          @Test     public void buttonClickChangesText() {         \/\/ \u041d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443         onView(withId(R.id.action_button))             .perform(click());                      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f         onView(withId(R.id.welcome_text))             .check(matches(withText(\"Button Clicked!\")));     } } <\/code><\/pre>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Jenkins \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 UI-\u0442\u0435\u0441\u0442\u043e\u0432 \u0441 ReDroid<\/h3>\n<h4>\u0428\u0430\u0433 1: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432 \u0432 Jenkins<\/h4>\n<p>\u0412 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 Jenkins \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b &#171;\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Jenkins&#187; &gt; &#171;\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438&#187; \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>Docker Pipeline<\/p>\n<\/li>\n<li>\n<p>Gradle Plugin<\/p>\n<\/li>\n<li>\n<p>HTML Publisher Plugin<\/p>\n<\/li>\n<li>\n<p>JUnit Plugin<\/p>\n<\/li>\n<li>\n<p>Allure Jenkins Plugin (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u0447\u0435\u0442\u043d\u043e\u0441\u0442\u0438)<\/p>\n<\/li>\n<\/ul>\n<h4>\u0428\u0430\u0433 2: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Jenkinsfile \u0434\u043b\u044f \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>Jenkinsfile<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<p>groovy<\/p>\n<pre><code>pipeline {     agent any          environment {         \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f         ANDROID_HOME = '\/opt\/android-sdk'         REDROID_IMAGE = 'redroid\/redroid:15.0.0_64only-latest'         REDROID_CONTAINER = 'android-ui-test-container'         ADB_PORT = '5555'         TEST_RESULTS_DIR = 'app\/build\/outputs\/androidTest-results'         TEST_REPORT_DIR = 'app\/build\/reports\/androidTests'     }          stages {         stage('Checkout') {             steps {                 checkout scm             }         }                  stage('Build APKs') {             steps {                 sh '.\/gradlew clean assembleDebug assembleDebugAndroidTest'             }         }                  stage('Start ReDroid Container') {             steps {                 script {                     \/\/ \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442                     sh \"docker stop ${REDROID_CONTAINER} || true\"                     sh \"docker rm ${REDROID_CONTAINER} || true\"                                          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a ReDroid \u0432 Docker                     sh \"\"\"                         docker run -d --name ${REDROID_CONTAINER} \\                         --privileged \\                         -p ${ADB_PORT}:${ADB_PORT} \\                         -e REDROID_PROP_ro.debuggable=1 \\                         -e REDROID_PROP_service.adb.tcp.port=${ADB_PORT} \\                         ${REDROID_IMAGE}                     \"\"\"                                          \/\/ \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 ReDroid                     sh \"sleep 30\"                 }             }         }                  stage('Connect to ReDroid and Install APKs') {             steps {                 script {                     \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u0447\u0435\u0440\u0435\u0437 ADB                     sh \"adb connect localhost:${ADB_PORT}\"                     sh \"adb devices\"                                          \/\/ \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b                     sh \"adb wait-for-device\"                                          \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 APK \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0435\u0441\u0442\u043e\u0432                     sh \"adb -s localhost:${ADB_PORT} install -r app\/build\/outputs\/apk\/debug\/app-debug.apk\"                     sh \"adb -s localhost:${ADB_PORT} install -r app\/build\/outputs\/apk\/androidTest\/debug\/app-debug-androidTest.apk\"                 }             }         }                  stage('Run UI Tests') {             steps {                 script {                     \/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0434\u043b\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432                     sh \"mkdir -p ${TEST_RESULTS_DIR}\"                                          \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u0430\u043a\u0435\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f                     def packageName = sh(                         script: \"aapt dump badging app\/build\/outputs\/apk\/debug\/app-debug.apk | grep package | awk '{print \\$2}' | sed s\/name=\/\/g | sed s\/\\\\'\/\/g\",                         returnStdout: true                     ).trim()                                          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a UI-\u0442\u0435\u0441\u0442\u043e\u0432                     sh \"\"\"                         adb -s localhost:${ADB_PORT} shell am instrument -w \\                         -e debug false \\                         -e junit.output.format=xml \\                         -e additionalTestOutputDir=\/sdcard\/test-results \\                         ${packageName}.test\/androidx.test.runner.AndroidJUnitRunner                     \"\"\"                                          \/\/ \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430                     sh \"adb -s localhost:${ADB_PORT} pull \/sdcard\/test-results ${TEST_RESULTS_DIR}\"                                          \/\/ \u0421\u0431\u043e\u0440 \u043b\u043e\u0433\u043e\u0432                     sh \"adb -s localhost:${ADB_PORT} logcat -d &gt; ${TEST_RESULTS_DIR}\/device-log.txt\"                                          \/\/ \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0434\u043b\u044f \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e)                     sh \"adb -s localhost:${ADB_PORT} shell screencap -p \/sdcard\/screen.png\"                     sh \"adb -s localhost:${ADB_PORT} pull \/sdcard\/screen.png ${TEST_RESULTS_DIR}\/\"                 }             }         }     }          post {         always {             \/\/ \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f JUnit-\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432             junit \"${TEST_RESULTS_DIR}\/**\/*.xml\"                          \/\/ \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043e\u0442\u0447\u0435\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f             publishHTML([                 allowMissing: true,                 alwaysLinkToLastBuild: true,                 keepAll: true,                 reportDir: \"${TEST_REPORT_DIR}\/connected\",                 reportName: 'Espresso Test Report',                 reportFiles: 'index.html'             ])                          \/\/ \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430             script {                 sh \"docker stop ${REDROID_CONTAINER} || true\"                 sh \"docker rm ${REDROID_CONTAINER} || true\"             }                          \/\/ \u041e\u0447\u0438\u0441\u0442\u043a\u0430 ADB             sh \"adb disconnect localhost:${ADB_PORT} || true\"                          \/\/ \u0410\u0440\u0445\u0438\u0432\u0430\u0446\u0438\u044f \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u043e\u0432             archiveArtifacts artifacts: \"${TEST_RESULTS_DIR}\/**\/*\", allowEmptyArchive: true         }     } } <\/code><\/pre>\n<hr\/>\n<h3>Scrcpy<\/h3>\n<p><strong>Scrcpy<\/strong>\u00a0\u2014 \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0430\u044f \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043a\u0440\u0430\u043d\u043e\u043c Android-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e USB (ADB) \u0438\u043b\u0438 \u043f\u043e Wi-Fi \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a (\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u043f\u043e USB):<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">scrcpy <\/code><\/pre>\n<ul>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Wi-Fi (\u0437\u043d\u0430\u044f IP-\u0430\u0434\u0440\u0435\u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430):<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">adb connect 192.168.1.5:5555 scrcpy -s 192.168.1.5:5555 <\/code><\/pre>\n<ul>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0435\u043e:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">scrcpy -m 1024 <\/code><\/pre>\n<ul>\n<li>\n<p>\u0417\u0430\u043f\u0438\u0441\u044c \u0432\u0438\u0434\u0435\u043e \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">scrcpy --record file.mp4 <\/code><\/pre>\n<ul>\n<li>\n<p>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0431\u0435\u0437 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u044d\u043a\u0440\u0430\u043d\u0430 (\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0432\u043e\u0434 \u0441 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b \u0438 \u043c\u044b\u0448\u0438):<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">scrcpy -N <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0437\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Scrcpy \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d:<\/p>\n<p>groovy<\/p>\n<pre><code>stage('Visual Debug with Scrcpy') {     when {         expression { return params.ENABLE_VISUAL_DEBUG }     }     steps {         script {             \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Scrcpy, \u0435\u0441\u043b\u0438 \u0435\u0449\u0435 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430             sh '''                 if ! command -v scrcpy &amp;&gt; \/dev\/null; then                     apt-get update &amp;&amp; apt-get install -y scrcpy                 fi             '''                          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a Scrcpy \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f             sh \"mkdir -p ${TEST_RESULTS_DIR}\/recordings\"                          for (int i = 0; i &lt; DEVICE_COUNT; i++) {                 def adbPort = BASE_ADB_PORT + i                 sh \"\"\"                     nohup scrcpy --no-display --record=${TEST_RESULTS_DIR}\/recordings\/device-${i}-recording.mp4 \\                     --serial=localhost:${adbPort} &amp;                 \"\"\"             }                          \/\/ \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0438\u0441\u0438             sh \"sleep 60\"  \/\/ \u0417\u0430\u043f\u0438\u0441\u044c \u043f\u0435\u0440\u0432\u043e\u0439 \u043c\u0438\u043d\u0443\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f             sh \"pkill scrcpy || true\"         }     } <\/code><\/pre>\n<h3>Kubernetes<\/h3>\n<h4>\u0417\u0430\u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ReDroid \u0432 Kubernetes<\/h4>\n<p><strong>ReDroid<\/strong> \u0432 Kubernetes \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412\u043e\u0442 \u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u043f\u043b\u044e\u0441\u044b:<\/p>\n<p><strong>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/strong> \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0448\u044c \u0441\u0440\u0430\u0437\u0443 \u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 Android-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0448\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p><strong>\u041c\u0435\u043d\u044c\u0448\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/strong> \u2014 ReDroid \u043b\u0435\u0433\u043a\u0438\u0439, \u0430 Kubernetes \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438.<\/p>\n<p><strong>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/strong> \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0430\u043c\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442, \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 Android-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0431\u0435\u0437 \u0442\u0432\u043e\u0435\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u0438\u044f.<\/p>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0432\u044f\u0437\u044c \u0441 CI\/CD<\/strong> \u2014 \u043b\u0435\u0433\u043a\u043e \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u044b Jenkins \u0438\u043b\u0438 GitLab CI.<\/p>\n<p><strong>\u0418\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432<\/strong> \u2014 \u043a\u0430\u0436\u0434\u043e\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e, \u0431\u0435\u0437 \u043f\u043e\u043c\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u043c \u0442\u0435\u0441\u0442\u0430\u043c.<\/p>\n<p><strong>\u0426\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/strong> \u2014 \u0432\u0441\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p><strong>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u0431\u044e\u0434\u0436\u0435\u0442\u0430<\/strong> \u2014 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u0434\u043e\u0440\u043e\u0433\u0438\u0445 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432.<\/p>\n<p><strong>\u041e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f<\/strong> \u2014 \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u0441\u0440\u0435\u0434\u0435, \u0447\u0442\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<p><strong>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044e<\/strong> \u2014 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 GPU \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u042d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u0445 \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e.<\/p>\n<pre><code class=\"yaml\">apiVersion: apps\/v1 kind: StatefulSet metadata:   name: redroid-farm   namespace: android-testing spec:   serviceName: \"redroid\"   replicas: 3  # \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432   selector:     matchLabels:       app: redroid-device   template:     metadata:       labels:         app: redroid-device     spec:       securityContext:         runAsUser: 0  # \u0417\u0430\u043f\u0443\u0441\u043a \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 root       containers:       - name: redroid         image: redroid\/redroid:15.0.0_64only-latest         securityContext:           privileged: true  # \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f redroid         ports:         - containerPort: 5555           name: adb         env:         - name: REDROID_PROP_ro.debuggable           value: \"1\"         - name: REDROID_PROP_service.adb.tcp.port           value: \"5555\"         - name: ANDROID_ARCH           value: \"x86_64\"         resources:           requests:             cpu: 2             memory: 3Gi           limits:             cpu: 4             memory: 6Gi         volumeMounts:         - name: dri           mountPath: \/dev\/dri         - name: kvm           mountPath: \/dev\/kvm         lifecycle:           preStop:             exec:               command: [\"\/system\/bin\/reboot\", \"-p\"]       volumes:       - name: dri         hostPath:           path: \/dev\/dri       - name: kvm         hostPath:           path: \/dev\/kvm       nodeSelector:         hardware-acceleration: \"true\"  # \u0412\u044b\u0431\u043e\u0440 \u0443\u0437\u043b\u043e\u0432 \u0441 GPU\/\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435\u043c  <\/code><\/pre>\n<h3>Wireshark \u0438 ReDroid: \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/h3>\n<p><strong>Wireshark<\/strong> \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 <strong>ReDroid<\/strong> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442  \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u042d\u0442\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 API-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0441\u0435\u0442\u044c\u044e.<\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438:<\/strong><\/p>\n<p><strong>\u041d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u043e\u043c<\/strong> \u2014 Wireshark \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 ReDroid \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438.<\/p>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/strong> \u2014 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 ReDroid \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a Docker-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0435\u0433\u043e \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0442\u0440\u0430\u0444\u0438\u043a \u043b\u0435\u0433\u043a\u043e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Docker-\u0441\u0435\u0442\u044c \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435.<\/p>\n<p><strong>\u0410\u043d\u0430\u043b\u0438\u0437 \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430<\/strong> \u2014 \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u0436\u0435 HTTPS-\u0442\u0440\u0430\u0444\u0438\u043a (\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 mitmproxy \u0434\u043b\u044f ReDroid).<\/p>\n<p><strong>\u041f\u043e\u0438\u0441\u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/strong> \u2014 \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0435\u0442\u0435\u0432\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<p><strong>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 API<\/strong> \u2014 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0435\u0442\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 ReDroid \u0441 \u043e\u0441\u043e\u0431\u044b\u043c\u0438 \u0441\u0435\u0442\u0435\u0432\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">docker run --name redroid-test --network host redroid\/redroid:11.0.0-latest <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0432 Wireshark, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0438\u043b\u044c\u0442\u0440 \u0434\u043b\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 ReDroid:<\/p>\n<\/li>\n<\/ol>\n<pre><code>ip.addr == [IP-\u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430] <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0414\u043b\u044f HTTPS-\u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u043e\u043a\u0441\u0438 \u0432 ReDroid \u0447\u0435\u0440\u0435\u0437 ADB:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">adb connect localhost:5555 adb shell settings put global http_proxy \"localhost:8080\" <\/code><\/pre>\n<ol start=\"4\">\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 mitmproxy \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 HTTPS:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"bash\">mitmproxy --listen-port 8080 <\/code><\/pre>\n<p>\u042d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430\u043c \u0433\u043b\u0443\u0431\u0436\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u0438\u0445 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0441 \u0441\u0435\u0442\u044c\u044e, \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0438\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u043e\u0432.<\/p>\n<hr\/>\n<p><a href=\"https:\/\/t.me\/akrylof\" rel=\"noopener noreferrer nofollow\">https:\/\/t.me\/akrylof<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/avkcode\/resume\/blob\/main\/resume.pdf\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/avkcode\/resume\/blob\/main\/resume.pdf<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/915954\/\"> https:\/\/habr.com\/ru\/articles\/915954\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 ReDroid?<\/h3>\n<p><strong>ReDroid<\/strong> \u2014 \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c\u0443 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0443 Android, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u043a\u0430\u043a Docker-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. ReDroid \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e Android-\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>ReDroid \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044f\u0434\u0440\u043e Linux \u0445\u043e\u0441\u0442-\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 anbox-\u043c\u043e\u0434\u0443\u043b\u044f, \u0447\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a Android \u0431\u0435\u0437 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 \u0441\u0440\u0435\u0434\u0435 CI\/CD, \u0433\u0434\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u044e\u0442 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h3>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u043e\u043c Android Studio:<\/h3>\n<p>ReDroid \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e UI-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 CI\/CD, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u0436\u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440 Android Studio \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0439 \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<h3>\u0420\u0443\u0447\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 ReDroid (Docker) \u0438 \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435 \u043e\u043a\u043e\u043b\u043e \u043c\u0438\u043d\u0443\u0442\u044b \u0434\u043b\u044f \u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438:<\/p>\n<pre><code class=\"bash\">docker run -d --name redroid --privileged -p 5555:5555 redroid\/redroid:15.0.0_64only-latest sleep 30 <\/code><\/pre>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u0441\u044c \u043a \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 ADB:<\/p>\n<pre><code class=\"bash\">adb connect localhost:5555 adb devices <\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043d\u0430 ReDroid \u043e\u0431\u0430 APK-\u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"bash\">adb -s localhost:5555 install .\/app\/build\/outputs\/apk\/debug\/app-debug.apk adb -s localhost:5555 install .\/app\/build\/outputs\/apk\/androidTest\/debug\/app-debug-androidTest.apk <\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0432\u0430\u0448\u0438 Espresso\/UI-\u0442\u0435\u0441\u0442\u044b \u0441 ADB:<\/p>\n<pre><code class=\"bash\">adb -s localhost:5555 shell am instrument -w your.package.name.test\/androidx.test.runner.AndroidJUnitRunner <\/code><\/pre>\n<p>\u0412\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u043b\u043e\u0433\u0438 \u043f\u043e\u0441\u043b\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">adb -s localhost:5555 logcat -d &gt; android-log.txt <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440:<\/p>\n<pre><code class=\"bash\">docker stop redroid &amp;&amp; docker rm redroid <\/code><\/pre>\n<figure class=\"\">\n<div><figcaption>Redroid<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 Android-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043b\u044f UI-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<h4>\u0428\u0430\u0433 1: \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 app\/build.gradle<\/h4>\n<p>gradle<\/p>\n<pre><code>android {     defaultConfig {         testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"     } }  dependencies {     \/\/ \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043b\u044f UI-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'     androidTestImplementation 'androidx.test:runner:1.5.2'     androidTestImplementation 'androidx.test:rules:1.5.0'          \/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Espresso \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.5.1'     androidTestImplementation 'androidx.test.espresso:espresso-intents:3.5.1'          \/\/ JUnit \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c     androidTestImplementation 'androidx.test.ext:junit:1.1.5' } <\/code><\/pre>\n<h4>\u0428\u0430\u0433 2: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 UI-\u0442\u0435\u0441\u0442\u0430 \u0441 Espresso<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>app\/src\/androidTest\/java\/com\/example\/app\/MainActivityTest.java<\/code>:<\/p>\n<p>java<\/p>\n<pre><code class=\"java\">package com.example.app;  import androidx.test.espresso.matcher.ViewMatchers; import androidx.test.ext.junit.rules.ActivityScenarioRule; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest;  import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith;  import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText;  @RunWith(AndroidJUnit4.class) @LargeTest public class MainActivityTest {      @Rule     public ActivityScenarioRule&lt;MainActivity&gt; activityRule =         new ActivityScenarioRule&lt;&gt;(MainActivity.class);      @Test     public void welcomeTextIsDisplayed() {         \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0441 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f         onView(withId(R.id.welcome_text))             .check(matches(isDisplayed()))             .check(matches(withText(\"Hello World!\")));     }          @Test     public void buttonClickChangesText() {         \/\/ \u041d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443         onView(withId(R.id.action_button))             .perform(click());                      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f         onView(withId(R.id.welcome_text))             .check(matches(withText(\"Button Clicked!\")));     } } <\/code><\/pre>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Jenkins \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 UI-\u0442\u0435\u0441\u0442\u043e\u0432 \u0441 ReDroid<\/h3>\n<h4>\u0428\u0430\u0433 1: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432 \u0432 Jenkins<\/h4>\n<p>\u0412 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 Jenkins \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b &#171;\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Jenkins&#187; &gt; &#171;\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438&#187; \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435:<\/p>\n<ul>\n<li>\n<p>Docker Pipeline<\/p>\n<\/li>\n<li>\n<p>Gradle Plugin<\/p>\n<\/li>\n<li>\n<p>HTML Publisher Plugin<\/p>\n<\/li>\n<li>\n<p>JUnit Plugin<\/p>\n<\/li>\n<li>\n<p>Allure Jenkins Plugin (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u0447\u0435\u0442\u043d\u043e\u0441\u0442\u0438)<\/p>\n<\/li>\n<\/ul>\n<h4>\u0428\u0430\u0433 2: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Jenkinsfile \u0434\u043b\u044f \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>Jenkinsfile<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<p>groovy<\/p>\n<pre><code>pipeline {     agent any          environment {         \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f         ANDROID_HOME = '\/opt\/android-sdk'         REDROID_IMAGE = 'redroid\/redroid:15.0.0_64only-latest'         REDROID_CONTAINER = 'android-ui-test-container'         ADB_PORT = '5555'         TEST_RESULTS_DIR = 'app\/build\/outputs\/androidTest-results'         TEST_REPORT_DIR = 'app\/build\/reports\/androidTests'     }          stages {         stage('Checkout') {             steps {                 checkout scm             }         }                  stage('Build APKs') {             steps {                 sh '.\/gradlew clean assembleDebug assembleDebugAndroidTest'             }         }                  stage('Start ReDroid Container') {             steps {                 script {                     \/\/ \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442                     sh \"docker stop ${REDROID_CONTAINER} || true\"                     sh \"docker rm ${REDROID_CONTAINER} || true\"                                          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a ReDroid \u0432 Docker                     sh \"\"\"                         docker run -d --name ${REDROID_CONTAINER} \\                         --privileged \\                         -p ${ADB_PORT}:${ADB_PORT} \\                         -e REDROID_PROP_ro.debuggable=1 \\                         -e REDROID_PROP_service.adb.tcp.port=${ADB_PORT} \\                         ${REDROID_IMAGE}                     \"\"\"                                          \/\/ \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 ReDroid                     sh \"sleep 30\"                 }             }         }                  stage('Connect to ReDroid and Install APKs') {             steps {                 script {                     \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u0447\u0435\u0440\u0435\u0437 ADB                     sh \"adb connect localhost:${ADB_PORT}\"                     sh \"adb devices\"                                          \/\/ \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b                     sh \"adb wait-for-device\"                                          \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 APK \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0435\u0441\u0442\u043e\u0432                     sh \"adb -s localhost:${ADB_PORT} install -r app\/build\/outputs\/apk\/debug\/app-debug.apk\"                     sh \"adb -s localhost:${ADB_PORT} install -r app\/build\/outputs\/apk\/androidTest\/debug\/app-debug-androidTest.apk\"                 }             }         }                  stage('Run UI Tests') {             steps {                 script {                     \/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0434\u043b\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432                     sh \"mkdir -p ${TEST_RESULTS_DIR}\"                                          \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u0430\u043a\u0435\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f                     def packageName = sh(                         script: \"aapt dump badging app\/build\/outputs\/apk\/debug\/app-debug.apk | grep package | awk '{print \\$2}' | sed s\/name=\/\/g | sed s\/\\\\'\/\/g\",                         returnStdout: true                     ).trim()                                          \/\/ \u0417\u0430\u043f\u0443\u0441\u043a UI-\u0442\u0435\u0441\u0442\u043e\u0432                     sh \"\"\"                         adb -s localhost:${ADB_PORT} shell am instrument -w \\                         -e debug false \\                         -e junit.output.format=xml \\                         -e additionalTestOutputDir=\/sdcard\/test-results \\                         ${packageName}.test\/androidx.test.runner.AndroidJUnitRunner                     \"\"\"                                          \/\/ \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430                     sh \"adb -s localhost:${ADB_PORT} pull \/sdcard\/test-results ${TEST_RESULTS_DIR}\"                                          \/\/ \u0421\u0431\u043e\u0440 \u043b\u043e\u0433\u043e\u0432                     sh \"adb -s localhost:${ADB_PORT} logcat -d &gt; ${TEST_RESULTS_DIR}\/device-log.txt\"                                          \/\/ \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0434\u043b\u044f \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e)                     sh \"adb -s localhost:${ADB_PORT} shell screencap -p \/sdcard\/screen.png\"                     sh \"adb -s localhost:${ADB_PORT} pull \/sdcard\/screen.png ${TEST_RESULTS_DIR}\/\"                 }             }         }     }          post {         always {             \/\/ \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f JUnit-\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432             junit \"${TEST_RESULTS_DIR}\/**\/*.xml\"                          \/\/ \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043e\u0442\u0447\u0435\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f             publishHTML([                 allowMissing: true,                 alwaysLinkToLastBuild: true,                 keepAll: true,                 reportDir: \"${TEST_REPORT_DIR}\/connected\",                 reportName: 'Espresso Test Report',                 reportFiles: 'index.html'             ])                          \/\/ \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430             script {                 sh \"docker stop ${REDROID_CONTAINER} || true\"                 sh \"docker rm ${REDROID_CONTAINER} || true\"             }                          \/\/ \u041e\u0447\u0438\u0441\u0442\u043a\u0430 ADB             sh \"adb disconnect localhost:${ADB_PORT} || true\"                          \/\/ \u0410\u0440\u0445\u0438\u0432\u0430\u0446\u0438\u044f \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u043e\u0432             archiveArtifacts artifacts: \"${TEST_RESULTS_DIR}\/**\/*\", allowEmptyArchive: true         }     } } <\/code><\/pre>\n<hr\/>\n<h3>Scrcpy<\/h3>\n<p><strong>Scrcpy<\/strong>\u00a0\u2014 \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0430\u044f \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043a\u0440\u0430\u043d\u043e\u043c Android-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e USB (ADB) \u0438\u043b\u0438 \u043f\u043e Wi-Fi \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a (\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u043f\u043e USB):<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">scrcpy <\/code><\/pre>\n<ul>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Wi-Fi (\u0437\u043d\u0430\u044f IP-\u0430\u0434\u0440\u0435\u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430):<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">adb connect 192.168.1.5:5555 scrcpy -s 192.168.1.5:5555 <\/code><\/pre>\n<ul>\n<li>\n<p>\u0418<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-462193","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=462193"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462193\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=462193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=462193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=462193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}