Publishing TWA to playstore
TWA are way to publish your PWA website on playstore. People can visit you website and then click on install now, But it is also great if you have app on playstore so people can search and install. You can use old webview style but trust me it do have lot of problems in both performance and managing ( for my type of people ). More over you came here searching so you already know the benifit of TWA . So let’s publish your app on playstore.
Create No activity Project
now choose the API level . I will go for API 19 as it will cover more people. Set name of the app and then package name
Open build.gradle (Project … ) and add maven to project like this
...
allprojects {
repositories {
google()
jcenter()
maven {url 'https://jitpack.io'} // add this line
}
}
...
open build.gradle ( Module …) and add this
buildToolsVersion "29.0.0"
defaultConfig {
manifestPlaceholders = [
hostName: "https://yourpwawebsiteurl.com/",
defaultUrl: "https://yourpwawebsiteurl.com/",
launcherName: "App Name"
]
..
now in AndroidManifest.xml
...
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name="android.support.customtabs.trusted.LauncherActivity"
android:label="${launcherName}">
<meta-data
android:name="asset_statements"
android:value="${assetStatements}" />
<meta-data
android:name="android.support.customtabs.trusted.DEFAULT_URL"
android:value="${defaultUrl}"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="https"
android:host="${hostName}"/>
</intent-filter>
</activity>
</application>
....
Application Tag will be present already.
At this point android will be throwing error that unresolved path for that
Go to build.gradle ( Module.. ) in dependencies add
dependencies {
....
implementation 'com.github.GoogleChrome:custom-tabs-client:a0f7418972' // add this
}
also add
android { ...
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
...
}
And press sync now
Click on Build => Sign Apk
Go ahead and create keystore or use existing ( But remember the Path). Build the release apk.
if facing issue
comment out
<meta-data
android:name="asset_statements"
android:value="${assetStatements}" />
in android manifest file
or in build.gradle (Module… )
compileSdkVersion 28 // set this value
buildToolsVersion "28.0.3" // set this value
targetSdkVersion 28 // set this value
Creating Digital Asset link
By doing this your app will not ask open with again and again .
In android studio on right most side. Click on Assistant
If Assistant option is not coming in right then
Click on search and
Click on open URL mapping
Click on plus sign
Fill the relevant host name. If activity is not coming up then click on arrow and choose or check your Manifest file.
Click OK
Then
Click on Open Digital asset Links File Generator
Then keep the default but in
select Select keystore file and then browse the keystore file saved above
then click Generate Digital asset link
then copy the json and I have React app so i will save this text in /public/.well-known/assetlinks.json .You will need to copy this text in your website’s source code so that it is publicly assecisble on
https://yourwebsiteurl.com/.well-known/assetlinks.json
( in my case i have to add chmod 775 v1/build/.well-known/assetlinks.json on server . I have jenkins setup so added line in it so it will run command automatically,)
Now click on
You will see 2 green ticks then you are good to go for next step.
Now copy the json data you get on https://yourwebsiteurl.com/.well-known/assetlinks.json
and then got to build.gradle( module ..) and
update the manifestPlaceholders
manifestPlaceholders = [
hostName: "....",
defaultUrl: "...",
launcherName: "...",
assetStatements:'' +
'[{' +
' "relation": ["delegate_permission/common.handle_all_urls"],' +
' "target": {' +
' "namespace": "android_app",' +
' "package_name": " ... ",' +
' "sha256_cert_fingerprints":' +
' ["BC:4F:79:44:4E:36:6B:FF:53:4A:92:1C"]' +
' }' +
'}]'
]
You can add
<meta-data
android:name="asset_statements"
android:value="${assetStatements}" />
in androidmanifest.json
Now easy part
Create the sign apk and then publish to playstore. You can find various videos on that. So Covering this part not very deeply.
For those who need help in publishing apk can follow further
Click on Build => Genrate sign apk ( in android studio)
choose App bundle => Next => choose or create keystore => next => release => finish
locate the build bundle ( /app/release )
got to
https://play.google.com/apps/publish
Click on
then fill
Then fill more details
Then they will ask you to upload image icon
I usually go to this website. It will create the icon image according to playstore requirement .
Upload app icon and some screenshot of the app. Fill the form accordingly.
Go to App Release
upload your apk on production => Complete Content Rating => Complete App content => Pricing and distribution
After these tab got green tick like
Click on App Releases and scroll down to Review button and click it
click on start rollout
Click confirm
Now your app is being processed by google team and if every thing is well you will get your app nooo TWA published
— — — — — — — — —
Thankyou for making this far. Hope This article help you and you have published your TWA on playstore. It do have lot of steps thats why i decided to write blog for others to get reference. I will happy to see your app you can share it with me on linkedin.com/in/rajan-lagah-5b3035143 if any problem contact me at rajanlagah@gmail.com