{"id":273966,"date":"2016-02-10T10:49:04","date_gmt":"2016-02-10T07:49:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=273966"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=273966","title":{"rendered":"\u0420\u0435\u0446\u0435\u043f\u0442\u044b \u043f\u043e\u0434 Android: IoC \u0441\u043e \u0432\u043a\u0443\u0441\u043e\u043c Gradle"},"content":{"rendered":"<p>       Android-\u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438. \u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u2014 \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434 \u0434\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b: Android \u0438 FireOS, \u0447\u0442\u043e \u043e\u0442 Amazon. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043a\u0440\u0443\u0433 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439, \u0432\u0435\u0434\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0447\u0438\u0442\u0430\u043b\u043e\u043a Kindle Fire \u043b\u044e\u0431\u044f\u0442 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c:). \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u043e \u0436\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432 Android \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 GCM \u0434\u043b\u044f push-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0442\u043e \u0432 FireOS \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e Amazon AWS. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c \u043f\u043e\u043a\u0443\u043f\u043e\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: Google in-app billing vs. In-App Purchasing. \u041d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e \u0432\u044b\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f! <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0431\u0438\u043b\u0434\u044b \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0445 \u0431\u0435\u0437 \u0432\u0440\u0435\u0434\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<h2>\u0427\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u0438\u043c?<\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c68\/f84\/455\/c68f8445551246349084937628c983b1.png\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0420\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044f \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u043a\u043e\u0434\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c, \u043d\u043e \u0431\u0443\u0434\u0443\u0447\u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u043c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u043c\u0435\u0440\u0442\u0432\u044b\u043c \u0433\u0440\u0443\u0437\u043e\u043c. \u041f\u043e\u043c\u0438\u043c\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0435\u0442 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0442\u0435\u043c \u0436\u0435 \u0433\u0440\u0443\u0437\u043e\u043c \u0438 \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0443\u0436\u0435 \u0441\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0430 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u0434 Android: \u201c\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 65k\u201d, best practice \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435, \u0441 \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0443\u0436\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0410 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 ifAndroid() \u0438\u043b\u0438 ifAmazon() \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u0438\u0434\u0435\u0442\u044c \u0447\u0443\u0442\u044c \u0440\u0435\u0436\u0435 \u0447\u0435\u043c \u043d\u0438\u043a\u043e\u0433\u0434\u0430.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043e\u043f\u044b\u0442\u043d\u044b\u0439 Android-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0443\u0436\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u0442\u0430\u043a\u043e\u0439 \u043e\u043f\u0446\u0438\u0435\u0439 Android Gladle \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u043a\u0430\u043a ProductFlavor. <\/p>\n<p>  <b><i>Flavor (\u0430\u043d\u0433\u043b.) \u2014 \u0432\u043a\u0443\u0441, \u0430\u0440\u043e\u043c\u0430\u0442<\/i><\/b><\/p>\n<p>  \u042d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432 \u0431\u0438\u043b\u0434 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u043e\u0433\u043e flavor-\u0430. \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e ProductFlavor \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u201c\u0431\u0440\u0435\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\u201d \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u044b (\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0442\u0435\u043a\u0441\u0442\u044b, \u0441\u0441\u044b\u043b\u043a\u0438). \u0414\u0440\u0443\u0433\u043e\u0439 \u0447\u0430\u0441\u0442\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u2013 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 demo- \u0438 \u043f\u043e\u043b\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043c\u044f \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e flavor\u2019\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 BuildConfig.FLAVOR. \u0415\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432 runtime \u0438 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 demo-\u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<p>  \u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430 flavor\u2019\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043d\u043e \u0438 \u043a\u043e\u0434. \u041d\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432\u043e flavor1, \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043a\u043e\u0434\u043e\u043c \u0438\u0437 flavor2. \u0410 \u043a\u043e\u0434, \u043b\u0435\u0436\u0430\u0449\u0438\u0439 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043e\u0434\u0438\u043d flavor\u2019\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e \u0432\u0440\u0435\u043c\u044f. \u0412\u0441\u0451 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043c flavor\u2019\u0435 \u043d\u0430\u0431\u043e\u0440 utility-\u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c\u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c. \u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043e\u0434 \u043d\u0443\u0436\u043d\u043e \u0441 \u0443\u043c\u043e\u043c \u0438 \u043e\u0447\u0435\u043d\u044c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e, \u0442\u0430\u043a, \u0447\u0442\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0431\u0438\u043b\u0434\u043e\u0432 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f. \u0411\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043e\u043a\u0430\u0436\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d Dependency Injection. \u0421\u043b\u0435\u0434\u0443\u044f \u0435\u043c\u0443, \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0449\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u043c \u043f\u043e flavor\u2019\u0430\u043c. \u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u043d\u0430 GitHub.<\/p>\n<h2>\u0418\u043d\u0433\u0440\u0435\u0434\u0438\u0435\u043d\u0442\u044b<\/h2>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:  <\/p>\n<ol>\n<li>\u042d\u043a\u0440\u0430\u043d \u0441 \u043f\u043e\u043b\u0435\u043c \u0432\u0432\u043e\u0434\u0430, \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u0438 \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 (1 \u0448\u0442.).<\/li>\n<li>\u041a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Github Web API: \u0435\u0433\u043e mock \u0438 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u0438\u0442\u043e\u0433\u043e 2 \u0448\u0442.).<\/li>\n<li>\u041a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043f\u043e\u0438\u0441\u043a\u0430: \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438 mock-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u0438\u0442\u043e\u0433\u043e 2 \u0448\u0442.).<\/li>\n<li>\u0418\u043a\u043e\u043d\u043a\u0438, \u0442\u0435\u043a\u0441\u0442\u044b, \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0431\u0430\u0440\u044b \u2013 \u043f\u043e \u0432\u043a\u0443\u0441\u0443.<\/li>\n<\/ol>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u043b\u043e\u0438 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c 3 \u043f\u0430\u043a\u0435\u0442\u0430: .view \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, .models \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0431\u0438\u0437\u043d\u0435\u0441\u043b\u043e\u0433\u0438\u043a\u0438 \u0438 .data \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u0412 \u043f\u0430\u043a\u0435\u0442\u0435 data \u043d\u0430\u043c \u0435\u0449\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f 2 \u043f\u0430\u043a\u0435\u0442\u0430 services \u0438 storages. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9be\/33a\/b2d\/9be33ab2d51d4af4b574114fdb6a8bd8.png\"\/><\/p>\n<p>  \u041c\u043e\u0434\u0435\u043b\u044c\u043a\u0438 \u043d\u0430\u043c \u0445\u0432\u0430\u0442\u0438\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439: \u201cRepository\u201d. \u041c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043d\u0435\u0439 \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0430 \u043d\u0430\u043c \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u0442\u044c \u0432 \u043d\u0435\u0439 description, name \u0438 htmlUrl.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c\u0441\u044f \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430-\u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 AppService:  <\/p>\n<pre><code>public interface AppService {   List&lt;Repository&gt; searchRepositories(String query); } <\/code><\/pre>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u044d\u0448\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430 RepositoryStorage:  <\/p>\n<pre><code>public interface RepositoryStorage {   void saveRepositories(String query, List&lt;Repository&gt; repositoryList);   List&lt;Repository&gt; getRepositories(String query); } <\/code><\/pre>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 Application-\u043a\u043b\u0430\u0441\u0441\u0430:  <\/p>\n<pre><code>public class App extends Application {    private AppService appService;   private RepositoryStorage repositoryStorage;    public AppService getAppService() {       return appService;   }    public RepositoryStorage getRepositoryStorage() {       return repositoryStorage;   } } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0430\u043c \u044d\u043a\u0440\u0430\u043d \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043d\u0451\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u0445\u0432\u0430\u0442\u0438\u0442 \u0438 AsyncTask, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0444\u043e\u043d\u043e\u0432\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043d\u043e \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434.  <\/p>\n<pre><code>public class MainActivity extends AppCompatActivity {    @Bind(R.id.actionSearchView) Button actionSearchView;   @Bind(R.id.recyclerView) RecyclerView recyclerView;   @Bind(R.id.searchQueryView) EditText searchQueryView;   @Bind(R.id.progressView) View progressView;   private SearchResultsAdapter adapter;   private AppService appService;   private SearchTask searchTask;   private RepositoryStorage repositoryStorage;    @Override   protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ButterKnife.bind(this);       appService = ((App) getApplication()).getAppService();       repositoryStorage = ((App) getApplication()).getRepositoryStorage();       recyclerView.setLayoutManager(new LinearLayoutManager(this));       adapter = new SearchResultsAdapter();       recyclerView.setAdapter(adapter);       searchQueryView.setOnEditorActionListener(new TextView.OnEditorActionListener() {           @Override           public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {               querySearch(searchQueryView.getText().toString());               return true;           }       });   }    @OnClick(R.id.actionSearchView)   void onActionSearchClicked() {       querySearch(searchQueryView.getText().toString());   }    private void querySearch(String query) {       if (TextUtils.isEmpty(query)) {           return;       }       if (searchTask != null) {           return;       }        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);       imm.hideSoftInputFromWindow(searchQueryView.getWindowToken(), 0);        searchTask = new SearchTask();       searchTask.execute(query);       showProgress(true);   }    private void showData(List&lt;Repository&gt; repositories) {       searchTask = null;       adapter.setData(repositories);   }    private void showProgress(boolean inProgress) {       progressView.setVisibility(inProgress ? View.VISIBLE : View.GONE);       actionSearchView.setEnabled(!inProgress);   }    private void showError(@Nullable ApiException exception) {       searchTask = null;       new AlertDialog.Builder(this)               .setMessage(exception != null ? exception.getMessage() : getString(R.string.unknown_error))               .setTitle(R.string.error_title)               .show();   }    private class SearchTask extends AsyncTask&lt;String, Void, SearchTaskResult&gt; {        @Override       protected SearchTaskResult doInBackground(String... params) {           String q = params[0];           SearchTaskResult result = new SearchTaskResult();           try {               result.repositories = appService.searchRepositories(q);               repositoryStorage.saveRepositories(q, result.repositories);           } catch (ApiException e) {               result.exception = e;               \/\/try to show some cached results               result.repositories = repositoryStorage.getRepositories(q);           }            return result;       }        @Override       protected void onPostExecute(SearchTaskResult result) {           if (result.exception != null) {               showError(result.exception);           }           showData(result.repositories);           showProgress(false);       }   }    private class SearchTaskResult {       List&lt;Repository&gt; repositories;       ApiException exception;   } } <\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0435\u0441\u044c \u0434\u0435\u043c\u043e-\u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/EBTRussia\/FlavorDI\/\">GitHub<\/a>.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d, \u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430, \u0432\u0435\u0434\u044c \u043c\u044b \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 <b>AppService<\/b> \u0438 <b>RepositoryStorage<\/b>, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u043a\u0443\u0441<\/h2>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c <b>build.gradle<\/b> \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043d\u0430\u0448\u0438 flavor-\u044b. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0438\u0445, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, <b>\u201cmock\u201d<\/b> \u0438 <b>\u201cprod\u201d<\/b>  <\/p>\n<pre><code>productFlavors {   mock {}   prod {} } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432 \u0441\u0435\u043a\u0446\u0438\u044e <b>android {&#8230;}<\/b> \u043d\u0430 \u0442\u043e\u043c \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u0435, \u0447\u0442\u043e \u0438 <b>buildTypes {&#8230;}<\/b>.<br \/>  \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 Sync Project With Gradle Files<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d41\/8ee\/28d\/d418ee28d49045dd8f68c6a11d138411.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430 \u0432 \u043e\u043a\u043d\u0435 Build Variants \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 flavor\u2019\u044b<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9b5\/c73\/fe3\/9b5c73fe355c4d53a86e91e911a4403b.png\"\/><\/p>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u044b\u0431\u0435\u0440\u0435\u043c <b>mockDebug<\/b>.<\/p>\n<p>  \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 product flavor\u2019\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0438\u0445 \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 \u0442\u043e\u043c \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u0435, \u0447\u0442\u043e \u0438 <b>main<\/b>. \u0418\u0437 \u044d\u0442\u0438\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 \u0438 \u0431\u0443\u0434\u0443\u0442 \u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0438\u0437 flavor\u2019\u043e\u0432.<br \/>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <b>mock<\/b>, \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0432 \u0432 \u043d\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 <b>services<\/b> \u0438 <b>storages<\/b>:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fdd\/f5c\/9f5\/fddf5c9f5bee4112b8675d6f23db0a2b.png\"\/><\/p>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a mock-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432:  <\/p>\n<pre><code>public class AppServiceImpl implements AppService {   @Override   public List&lt;Repository&gt; searchRepositories(String query) {       if (query.equals(&quot;error&quot;)) {           throw new ApiException(&quot;Manual exception&quot;);       }       List&lt;Repository&gt; results = new ArrayList&lt;&gt;();       for (int i = 1; i &lt;= 10; i++) {           results.add(new Repository(&quot;Mock description &quot; + i, &quot;Mock Repository &quot; + i, &quot;http:\/\/mock-repo-url&quot;));       }       return results;   } }  public class MockRepositoryStorage implements RepositoryStorage {     @Override   public void saveRepositories(String q, List&lt;Repository&gt; repositoryList) {}    @Override   public List&lt;Repository&gt; getRepositories(String q) {       return null;   } } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, mock-\u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u0434\u0430\u0435\u0442 \u043d\u0430\u043c 10 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u043a Repository, \u0430 mock-storage \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u0447\u0435\u0433\u043e. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0435\u043c App-\u043a\u043b\u0430\u0441\u0441\u0435:  <\/p>\n<pre><code>@Override public void onCreate() {   super.onCreate();   appService = new AppServiceImpl();   repositoryStorage = new MockRepositoryStorage(); } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u043e \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0433\u043e\u0442\u043e\u0432\u043e \u0431\u044b\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u044b\u043c \u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u044b\u043c. \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 UI. \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u043e \u043c\u044b\u2026 \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432.<\/p>\n<p>  \u0412 \u043e\u043a\u043d\u0435 Build Variants \u0432\u044b\u0431\u0438\u0440\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <b>prodDebug <\/b>\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0430\u043f\u043a\u0435 <b>mock <\/b>\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <b>prod <\/b>\u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/580\/93e\/f2a\/58093ef2af8c46109272c4523b5ddca8.png\"\/><\/p>\n<p>  \u041c\u044b \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0435\u043c \u043a \u043f\u043e\u043c\u043e\u0449\u0438 retrofit2 \u0434\u043b\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 AppServiceImpl:  <\/p>\n<pre><code>public class AppServiceImpl implements AppService {     private final RetroGithubService service;    public AppServiceImpl() {       service = new Retrofit.Builder()               .baseUrl(&quot;https:\/\/api.github.com\/&quot;)               .addConverterFactory(GsonConverterFactory.create())               .build().create(RetroGithubService.class);   }    @Override   public List&lt;Repository&gt; searchRepositories(String query) {       Call&lt;ApiRepositorySearchEntity&gt; call = service.searchRepositories(query);       try {           Response&lt;ApiRepositorySearchEntity&gt; response = call.execute();           if (response.isSuccess()) {               ApiRepositorySearchEntity body = response.body();               List&lt;Repository&gt; results = new ArrayList&lt;&gt;();               RepositoryMapper mapper = new RepositoryMapper();               for (RepositoryEntity entity : body.items) {                   results.add(mapper.map(entity));               }               return results;           } else {               throw new ApiException(response.message());           }       } catch (Exception e) {           throw new ApiException(e);       }   } }  public interface RetroGithubService {   @GET(&quot;search\/repositories&quot;)   Call&lt;ApiRepositorySearchEntity&gt; searchRepositories(@Query(&quot;q&quot;) String query); } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0438\u0437 \u043a\u043e\u0434\u0430, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<b> *Entity<\/b> \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0438 <b>RepositoryMapper<\/b> \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c <b>Repository<\/b>. <\/p>\n<p>  <b><i>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a RepositoryEntity, RepositoryMapper, RetroGithubService, \u043b\u0435\u0436\u0430\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 flavor\u2019\u0430 \u201cprod\u201d. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e flavor\u2019\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 mock, \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 apk-\u0444\u0430\u0439\u043b<\/i>.<\/b><\/p>\n<p>  \u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u0438\u043c\u044f \u0435\u0433\u043e mock-\u0430\u043d\u0430\u043b\u043e\u0433\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442: <b>AppServiceImpl.java<\/b>. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 main, \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 flavor\u2019\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e. \u041f\u0440\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c flavor\u2019\u0435 <b>mock <\/b>\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0438\u0434\u0438\u0442 \u043a\u043b\u0430\u0441\u0441 AppServiceImpl, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0432 \u043f\u0430\u043f\u043a\u0435 mock \u0438 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u043a\u043b\u0430\u0441\u0441, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0432 \u043f\u0430\u043f\u043a\u0435 <b>prod<\/b>. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u043f\u0440\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c flavor\u2019\u0435 <b>prod<\/b>.<\/p>\n<p>  \u0421\u0442\u043e\u043b\u044c \u0436\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0435\u0448\u0430 \u043c\u044b \u043d\u0430\u0437\u0432\u0430\u043b\u0438 <b>MockRepositoryStorage<\/b> \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043f\u0435\u0447\u0430\u0442\u0430\u043b\u0438\u0441\u044c. \u041d\u043e \u043d\u0435\u0442, \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0438 \u0434\u0430\u0436\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445.<br \/>  \u0422\u0440\u044e\u043a \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 flavor\u2019\u043e\u0432 \u043a\u043b\u0430\u0441\u0441 <b>RepositoryStorageBuilder<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e flavor\u2019\u0430 \u043e\u0442\u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>  productFlavor = prod  <\/p>\n<pre><code>public class RepositoryStorageBuilder {   private int maxSize;    public RepositoryStorageBuilder setMaxSize(int maxSize) {       this.maxSize = maxSize;       return this;   }    public RepositoryStorage build() {       return new InMemoryRepositoryStorage(maxSize);   } } <\/code><\/pre>\n<p>  productFlavor = mock  <\/p>\n<pre><code>public class RepositoryStorageBuilder {    public RepositoryStorageBuilder setMaxSize(int maxSize) {       return this;   }    public RepositoryStorage build() {       return new MockRepositoryStorage();   } } <\/code><\/pre>\n<p>  \u0418 \u043e\u0431\u0449\u0430\u044f \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 Application:  <\/p>\n<pre><code>@Override public void onCreate() {   super.onCreate();   ...   repositoryStorage = new RepositoryStorageBuilder()           .setMaxSize(5)           .build(); } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438 \u201c\u0447\u0435\u0441\u0442\u043d\u0443\u044e\u201d \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u0437\u0434\u0435\u0441\u044c, \u0442\u043e \u043d\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u0441\u0435\u0439 \u043c\u043e\u0449\u044c\u044e ProductFlavor. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0447\u0435\u0441\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <b>dependencies<\/b>, \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043d\u0430\u0448\u0443 \u0441\u0431\u043e\u0440\u043a\u0443 \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e flavor\u2019\u0430. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u043c \u043b\u0438 \u043c\u044b \u0435\u0451 \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0431\u0438\u043b\u0434\u0435, \u0434\u043e\u043f\u0438\u0441\u0430\u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u0438\u043c\u044f flavor \u043f\u0435\u0440\u0435\u0434 \u0441\u043b\u043e\u0432\u043e\u043c compile:  <\/p>\n<pre><code>dependencies {   compile fileTree(dir: 'libs', include: ['*.jar'])   testCompile 'junit:junit:4.12'   prodCompile 'com.squareup.retrofit:retrofit:2.0.0-beta2'   prodCompile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'   prodCompile 'com.google.code.gson:gson:2.5'   compile 'com.android.support:appcompat-v7:23.1.1'   compile 'com.android.support:recyclerview-v7:23.1.1'   compile 'com.jakewharton:butterknife:7.0.1' } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u043e \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u0441\u0431\u043e\u0440\u043a\u0438, \u0435\u0441\u043b\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u0435.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c?<\/h2>\n<p>  \u0417\u0430\u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a Dependency Injection, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c Dagger2, Roboguice, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e?<br \/>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0435\u0449\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u0432 \u0431\u0438\u043b\u0434 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u043c\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 runtime \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044e\u0431\u0438\u0432\u0448\u0438\u0439\u0441\u044f DI-\u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a.<\/p>\n<h2>True Story<\/h2>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0438 \u0432\u043d\u0430\u0447\u0430\u043b\u0435, \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434 \u0434\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b: Android \u0438 Amazon FireOS. \u042d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0445\u043e\u0436\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u044b \u0432\u0441\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c \u043a\u0442\u043e \u0438 \u043d\u0430 \u043a\u043e\u0433\u043e \u043f\u043e\u0445\u043e\u0436 :)), \u043d\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0445 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0438 \u0441\u0432\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043a\u0443\u043f\u043e\u043a. \u0414\u043b\u044f \u044d\u0442\u0438\u0445 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c \u043c\u044b, \u043a\u0430\u043a \u0438 \u0432 \u0434\u0435\u043c\u043e-\u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0449\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b: \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u0434\u0435\u0432\u0430\u0439\u0441\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 push-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u043e\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u0438\u043c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 flavor\u2019\u0430\u0445.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cf9\/6a7\/d90\/cf96a7d907c8496785e77816a37d18b4.jpg\"\/><\/p>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e \u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c\u0438 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<br \/>  \u041f\u043b\u044e\u0441\u044b  <\/p>\n<ol>\n<li>\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u0432\u0441\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0437 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c.<\/li>\n<li>\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0442.\u043a. \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 (\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439) flavor.<\/li>\n<li>\u0412\u0441\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f IoC, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u044b\u0445 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u0441\u0442\u0438\u043b\u0435 if isAndroid.()<\/li>\n<\/ol>\n<p>  \u041c\u0438\u043d\u0443\u0441\u044b  <\/p>\n<ol>\n<li>Android Studio \u0432\u0438\u0434\u0438\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 flavor \u0438 \u0435\u0433\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u043f\u043e\u043b\u043d\u043e\u0439 \u043c\u0435\u0440\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433, \u043f\u043e\u0438\u0441\u043a \u043f\u043e java-\u043a\u043b\u0430\u0441\u0441\u0430\u043c, \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c. \u041d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435, \u0447\u0442\u043e \u043d\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 flavor\u2019\u044b. \u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 flavor\u2019\u0430\u043c\u0438 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445.<\/li>\n<\/ol>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u043b\u044e\u0441\u043e\u0432 \u0432 3 \u0440\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \ud83d\ude42 \u0412\u0441\u0435\u043c \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0430\u043f\u043f\u0435\u0442\u0438\u0442\u0430!               <\/p>\n<div class=\"clear\"><\/div>\n<p> \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:\/\/habrahabr.ru\/post\/276927\/\"> https:\/\/habrahabr.ru\/post\/276927\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       Android-\u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438. \u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u2014 \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434 \u0434\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b: Android \u0438 FireOS, \u0447\u0442\u043e \u043e\u0442 Amazon. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u043a\u0440\u0443\u0433 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439, \u0432\u0435\u0434\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0447\u0438\u0442\u0430\u043b\u043e\u043a Kindle Fire \u043b\u044e\u0431\u044f\u0442 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c:). \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u043e \u0436\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432 Android \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 GCM \u0434\u043b\u044f push-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0442\u043e \u0432 FireOS \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e Amazon AWS. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u0434\u043b\u044f \u0441\u0438\u0441\u0442\u0435\u043c \u043f\u043e\u043a\u0443\u043f\u043e\u043a \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: Google in-app billing vs. In-App Purchasing. \u041d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e \u0432\u044b\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f! <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0431\u0438\u043b\u0434\u044b \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c \u0438\u0445 \u0431\u0435\u0437 \u0432\u0440\u0435\u0434\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<h2>\u0427\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u0438\u043c?<\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c68\/f84\/455\/c68f8445551246349084937628c983b1.png\"\/>  <\/p>\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-273966","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273966","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=273966"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273966\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=273966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=273966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=273966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}