<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
	<channel>
		<title>Keeping Secrets Safe in Android Projects | Infinum</title>
		<atom:link href="https://infinum.com/blog/secrets-android-projects/feed/" rel="self" type="application/rss+xml" />
		<link>https://infinum.com/blog/secrets-android-projects/</link>
		<description>Building digital products</description>
		<lastBuildDate>Tue, 14 Apr 2026 10:32:35 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>

					<item>
				<image>
					<url>7966https://infinum.com/uploads/2020/12/secrets-android-projects-0.webp</url>
				</image>
				<title>Keeping Secrets Safe in Android Projects</title>
				<link>https://infinum.com/blog/secrets-android-projects/</link>
				<pubDate>Mon, 21 Dec 2020 15:40:00 +0000</pubDate>
				<dc:creator>Mladen Rakonjac</dc:creator>
				<guid isPermaLink="false">https://infinum.com/the-capsized-eight/secrets-android-projects/</guid>
				<description>
					<![CDATA[<p>You can never be too cautious with your secrets.</p>
<p>The post <a href="https://infinum.com/blog/secrets-android-projects/">Keeping Secrets Safe in Android Projects</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</description>
				<content:encoded>
					<![CDATA[<div
	class="wrapper"
	data-id="es-216"
	 data-animation-target='inner-items'>
		
			<div class="wrapper__inner">
			<div class="block-blog-content js-block-blog-content">
	
<div class="block-blog-content-sidebar" data-id="es-92">
	</div>

<div class="block-blog-content-main">
	
<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-95"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-93">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-94'
	>
	My Cryptography course professor used to say: “Nothing is 100% secure. Even if you go to the farthest place to hide the key for a safe, there is still a small percentage of probability that somebody will find it”.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-98"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-96">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-97'
	>
	Making something more secure actually means making sure that percentage is as low as possible.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-101"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-99">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-100'
	>
	What can we do to make secrets more secure in Android projects?</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-104"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-102">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-103'
	>
	The secret in Android projects can be an API key, Keystore, credentials for publishing, credentials for some special access to the 3rd party SDK, etc. If we want to secure a secret in an Android project, we usually ignore it in Git. When somebody new jumps into the project, those ignored files should be added manually.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-107"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-105">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-106'
	>
	Usually, secrets, like credentials, are inside the <code>build.gradle</code> file because they are environment-specific. For simplicity, let’s say that we have an environment called <code>preproduction</code> in which we have credentials to log in automatically into the application tapping on the login button multiple times.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-110"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-108">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-109'
	>
	This environment acts the same as <code>production</code> plus this log in automatically feature. This is good to have for fast internal testing in the <code>production</code> environment before production release. However, this secret should never be visible in the final production apk. For simplicity, let’s say that we have <code>CREDENTIALS</code> that we use only in the preproduction environment.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-113"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-111">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-112'
	>
	We can add it to the <code>build.gradle</code> file:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-115"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-groovy github-light" data-language="groovy" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #d73a49;">..</span><span class="token">.
</span></span><span class="line"><span class="token">defaultConfig </span><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">..</span><span class="token">.
</span></span><span class="line"><span class="token">    resValue </span><span class="token" style="color: #005cc5;">RES_STRING</span><span class="token">, ‘</span><span class="token" style="color: #005cc5;">CREDENTIALS_USERNAME</span><span class="token">’,’’
</span></span><span class="line"><span class="token">    resValue </span><span class="token" style="color: #005cc5;">RES_STRING</span><span class="token">, ‘</span><span class="token" style="color: #005cc5;">CREDENTIALS_PASSWORD</span><span class="token">’,’’
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">..</span><span class="token">.
</span></span><span class="line"><span class="token">}</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span><span class="line"><span class="token">productFlavors </span><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token">    preproduction </span><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token">            </span><span class="token" style="color: #d73a49;">..</span><span class="token">.
</span></span><span class="line"><span class="token">            resValue </span><span class="token" style="color: #005cc5;">RES_STRING</span><span class="token">, ‘</span><span class="token" style="color: #005cc5;">CREDENTIALS_USERNAME</span><span class="token">’,’mladen’
</span></span><span class="line"><span class="token">            resValue </span><span class="token" style="color: #005cc5;">RES_STRING</span><span class="token">, ‘</span><span class="token" style="color: #005cc5;">CREDENTIALS_PASSWORD</span><span class="token">’,’str0ngP4ssw0rd’
</span></span><span class="line"><span class="token">            </span><span class="token" style="color: #d73a49;">..</span><span class="token">.
</span></span><span class="line"><span class="token">    </span><span class="token">}</span><span class="token">
</span></span><span class="line"><span class="token">}</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">..</span><span class="token">.
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-118"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-116">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-117'
	>
	When we build the project, the credentials strings are located in <code>gradleResValues.xml</code> and we can access them using <code>@string/</code> in XML files or <code>getString</code> function in Kotlin/Java classes as we do for any other string from resources.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-121"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-119">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-120'
	>
	The<code>build.gradle</code> file should not be ignored in the version-control system cause all developers in the team should have the same version. With the current implementation, <code>‘CREDENTIALS_USERNAME’</code> and <code>‘CREDENTIALS_PASSWORD’</code> as part of the <code>build.gradle</code> file, will be included in git. This is not safe.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-124"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-122">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-123'
	>
	We want to make it more secure, so if somebody gets access to the repository that person should not get access to our production credentials.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-127"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-125"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-126">
	<picture class="image__picture block-media__image-picture">
								
			<source
				srcset=https://infinum.com/uploads/2020/12/secrets-android-projects-1-1400x349.webp				media='(max-width: 699px)'
				type=image/webp								height="349"
												width="1400"
				 />
												<img
					src="https://infinum.com/uploads/2020/12/secrets-android-projects-1.webp"
					class="image__img block-media__image-img"
					alt=""
										height="390"
															width="1566"
										loading="lazy"
					 />
					</picture>

	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-130"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-128">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-129'
	>
	To avoid that, we can store this key in the local.properties file:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-132"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-groovy github-light" data-language="groovy" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #005cc5;">CREDENTIALS_USERNAME</span><span class="token" style="color: #d73a49;">=</span><span class="token">mladen
</span></span><span class="line"><span class="token" style="color: #005cc5;">CREDENTIALS_PASSWORD</span><span class="token" style="color: #d73a49;">=</span><span class="token">str0ngP4ssw0rd
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-135"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-133">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-134'
	>
	The local.properties file should not be included in the version-control system.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-138"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-136">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-137'
	>
	To make keys from <code>local.properties</code> accessible in <code>build.gradle</code> we can add the following function:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-140"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-groovy github-light" data-language="groovy" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token">def getLocalProperties() {
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">Properties</span><span class="token"> </span><span class="token">props</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token" style="color: #d73a49;">new</span><span class="token"> </span><span class="token" style="color: #d73a49;">Properties</span><span class="token">(</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">if</span><span class="token"> </span><span class="token">(</span><span class="token">file</span><span class="token">(</span><span class="token">’</span><span class="token" style="color: #d73a49;">..</span><span class="token" style="color: #d73a49;">/</span><span class="token">local</span><span class="token" style="color: #d73a49;">.</span><span class="token">properties’</span><span class="token">)</span><span class="token" style="color: #d73a49;">.</span><span class="token">ex</span><span class="token">i</span><span class="token">sts</span><span class="token">(</span><span class="token">)</span><span class="token">)</span><span class="token"> </span><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token">        props</span><span class="token" style="color: #d73a49;">.</span><span class="token">load</span><span class="token">(</span><span class="token" style="color: #d73a49;">new</span><span class="token"> </span><span class="token" style="color: #d73a49;">FileInputStream</span><span class="token">(</span><span class="token">file</span><span class="token">(</span><span class="token">’</span><span class="token" style="color: #d73a49;">..</span><span class="token" style="color: #d73a49;">/</span><span class="token">local</span><span class="token" style="color: #d73a49;">.</span><span class="token">properties’</span><span class="token">)</span><span class="token">)</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token">}</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">return</span><span class="token"> props
</span></span><span class="line"><span class="token">}
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-143"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-141">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-142'
	>
	Next, we should create a build config field this way:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-145"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-groovy github-light" data-language="groovy" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token">preproduction </span><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">..</span><span class="token">.
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">Properties</span><span class="token"> localProperties </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token">getLocalProperties</span><span class="token">(</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">    resValue </span><span class="token" style="color: #005cc5;">RES_STRING</span><span class="token">, ‘</span><span class="token" style="color: #005cc5;">CREDENTIALS_USERNAME</span><span class="token">’, localProperties</span><span class="token">[</span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">CREDENTIALS_USERNAME</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">]</span><span class="token">
</span></span><span class="line"><span class="token">    resValue </span><span class="token" style="color: #005cc5;">RES_STRING</span><span class="token">, ‘</span><span class="token" style="color: #005cc5;">CREDENTIALS_PASSWORD</span><span class="token">’, localProperties</span><span class="token">[</span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">CREDENTIALS_PASSWORD</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">]</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">..</span><span class="token">.
</span></span><span class="line"><span class="token">}</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-148"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-146">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-147'
	>
	How will CI know about this secret?</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-151"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-149">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-150'
	>
	At Infinum, we switched from <a href="https://infinum.com/blog/bitrise-vs-circleci-for-android-in-a-head-to-head-battle/">CircleCI to Bitrise</a>, so in this blog post, I’ll show you how to do this on Bitrise, but it’s similar to any other CI.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-154"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-152">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-153'
	>
	We should copy the key from our local.properties file and add it inside Bitrise Secret ( Project -&gt; Workflow -&gt; Secrets -&gt; Add New). Let’s name it <code>CREDENTIALS_USERNAME</code>.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-157"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-155">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-156'
	>
	Next, we should change build config field:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-159"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-kotlin github-light" data-language="kotlin" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token">
</span></span><span class="line"><span class="token">resValue RES_STRING, ‘CREDENTIALS_USERNAME’, System</span><span class="token">.getenv</span><span class="token">(</span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">CREDENTIALS_USERNAME</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">) ?: project.properties[</span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">CREDENTIALS_USERNAME</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">]
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-162"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-160">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-161'
	>
	If we run the build on CI, it will get <code>CREDENTIALS_USERNAME</code> from Secrets, if we run it locally it will get <code>API_KEY</code> from <code>local.properties</code> file.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-165"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-163">
	<h3	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-164'
	>
	What if we want to have a special credentials.properties file with all API keys?</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-168"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-166">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-167'
	>
	If we want to separate API keys from other properties in the <code>local.properties</code> file, we can create a new <code>credentials.properties</code> file. Moreover, instead of storing key by key in Bitrise Secrets, we can store the whole content of the<code>credentials.properties</code> file in one Bitrise secret called <code>CREDENTIALS_PROPERTIES</code>.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-171"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-169">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-170'
	>
	Then, we can make a special workflow step that will create credentials.properties file and fill it with data stored in Bitrise Secret. That step should be called before any other step.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-174"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-172"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-173">
	<picture class="image__picture block-media__image-picture">
								
			<source
				srcset=https://infinum.com/uploads/2020/12/secrets-android-projects-2-1400x261.webp				media='(max-width: 699px)'
				type=image/webp								height="261"
												width="1400"
				 />
												<img
					src="https://infinum.com/uploads/2020/12/secrets-android-projects-2.webp"
					class="image__img block-media__image-img"
					alt=""
										height="298"
															width="1600"
										loading="lazy"
					 />
					</picture>

	</figure></div></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-177"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-175">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-176'
	>
	A script could be made as follows:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-179"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-shellscript github-light" data-language="shellscript" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token">
</span></span><span class="line"><span class="token" style="color: #005cc5;">set</span><span class="token"> </span><span class="token" style="color: #005cc5;">-</span><span class="token" style="color: #005cc5;">e</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #005cc5;">echo</span><span class="token"> </span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">$</span><span class="token" style="color: #032f62;">{</span><span class="token" style="color: #24292e;">CREDENTIALS_PROPERTIES</span><span class="token" style="color: #032f62;">}</span><span class="token" style="color: #032f62;">&quot;</span><span class="token"> </span><span class="token" style="color: #d73a49;">&gt;</span><span class="token"> </span><span class="token" style="color: #032f62;">credentials.properties</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-182"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-180">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-181'
	>
	In that case, we should have only the following, without fetching the key from the system envs.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-184"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-groovy github-light" data-language="groovy" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token">resValue </span><span class="token" style="color: #005cc5;">RES_STRING</span><span class="token">, ‘</span><span class="token" style="color: #005cc5;">CREDENTIALS_USERNAME</span><span class="token">’, project</span><span class="token" style="color: #d73a49;">.</span><span class="token">properties</span><span class="token">[</span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">CREDENTIALS_USERNAME</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">]</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-187"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-185">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-186'
	>
	You can choose one of the two approaches depending on what works for you.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-190"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-188">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-189'
	>
	Sharing secrets between team members with Vault</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-193"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-191">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-192'
	>
	Adding secrets to the CI is a one-time thing. You add them and you won’t change them ever, but what if you need to share them with your colleagues? It’s possible to use a password manager, but when someone joins the project, they have to add a new file and copy-paste the credentials. If you have a lot of them, this can be tedious.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-196"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-194">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-195'
	>
	A better way to share secrets is by using <a href="https://www.vaultproject.io/">Vault</a>. This tool enables you to have secrets for all your projects in one place. It has a command-line tool, so you can integrate it with your continuous integration script. That way, you do not expose secrets on your CI as they will be fetched only when you need them.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-199"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-197">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-198'
	>
	Any colleague who joins the project can have access to the Vault and will be able to fetch all or only one secret.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-202"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-200">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-201'
	>
	There are other tools that you can use instead of Vault, but the idea is the same. You have one tool which will help you share those secrets with your team.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-205"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-203">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-204'
	>
	Is this secure enough?</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-208"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-206">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-207'
	>
	If someone wants to, they can still do reverse engineering of the apk file and find keys, so it is really important what you have in a final production apk. If somebody gets access to the repository, credentials that are not included in the final production apk but are used during the development should not be exposed to that person.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-211"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-209">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-210'
	>
	Also, it is really important that those apks for preproduction environment will be stored in some internal host.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-214"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-212">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-213'
	>
	This was just one example of how we make Android projects more secure. In the end, everything is vulnerable, but we should try to make it harder for the bad guys. By introducing more layers of security, we reduce the vulnerability.</p></div>	</div>
</div>
</div>		</div>
	</div><p>The post <a href="https://infinum.com/blog/secrets-android-projects/">Keeping Secrets Safe in Android Projects</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</content:encoded>
			</item>
		
	</channel>
</rss>