Instant app, Try Now button does not appear in play store - android

i started with following github projects but these example are not working properly. I added missing parts as stated in the docs.
https://github.com/android/app-bundle-samples/tree/main/InstantApps/urlless
https://github.com/googlecodelabs/android-dynamic-features
Here is the docs i read.
https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle
https://developer.android.com/topic/google-play-instant/feature-module-migration
https://developer.android.com/guide/app-bundle/instant-delivery
i try to implement a simple hello world instant app. I tried many things but try now button never appears in play store.
my app contains 2 module:
app
instant-app
build.gradle of app module :
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 61
versionName "61"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dynamicFeatures = [':instantapp']
}
dependencies {
...
implementation "com.google.android.gms:play-services-instantapps:17.0.0"
implementation "com.google.android.play:core:1.9.0"
...
}
build.gradle of my instant-app module
plugins {
id 'com.android.dynamic-feature'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.test.myapp"
minSdkVersion 21
targetSdkVersion 30
versionCode 3
versionName "1.2"
}
}
dependencies {
implementation "com.google.android.play:core:1.9.0"
}
AndroidManifest.xml of my app module
<?xml version="1.0" encoding="utf-8"?>
<manifest >
<dist:module dist:instant="true" />
...
</manifest>
AndroidManifest.xml of my instant-app module
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.test.instantapp"
android:targetSandboxVersion="2">
<dist:module dist:instant="true" dist:onDemand="false"
dist:title="Instant app title">
<dist:fusing dist:include="true" />
</dist:module>
<application android:usesCleartextTraffic="false">
<activity android:name=".InstantMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I generate a signed bundle and upload it in internal test in each of my try but it did not work. i tried it in prod environment too. Not work!
I tried to put applicationId "com.test.myapp" in both app module and instant-app module. I tried to made android:targetSandboxVersion="2" and android:targetSandboxVersion="1". Not work
.
Version code of my app is greater than version code of my instant-app as shown below.
I removed clearTextTraffic and added. Not work!
Some said me to take my instant app enabled code to take into production and upload a new upgraded instant app version. I did it, it did not work either.
I tried many many combinations which i cannot remember now. But try now button never appears. What is the missing part i cannot find ?
There are 3 different sayings for maximum size of instant-app module:
4 mb
10 mb
15 mb
Why the source codes and docs are conflicting too much and there is no working code in github ? If i didn't see working samples in play store, i would think instant apps are dead.

open play store -> select app-> open advanced settings -> add release type instant app
Then upload your instant app from instant apps only option:

Related

Android Studio 3.2 - Instant Run performed a full build and install since the installation on the device does not match the local build on disk

I was following this tutorial from youtube to learn to make an android keyboard. I followed everything as described in it. I was able to build the project succesfully but whenever I try to run it I was getting the following error -
Instant Run performed a full build and install since the installation on the device does not match the local build on disk
So I googled for a solution and tried turning off Instant Run, then the above mentioned error was not appearing. The APK was installed to my device, but when I tried to enable the keyboard in the settings it was not found there. I tried it in device and 2 emulators, but problem is same everywhere.
I don't know what to do. I will copy my Android Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tomsapp.keeskeyboard">
<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">
<service
android:name=".KeesKeyboard"
android:label="#string/app_name"
android:permission="android:permission.BIND_INPUT_METHOD">
<meta-data android:name="android.view.im" android:resource="#xml/method"/>
<intent-filter>
<action android:name="android.view.InputMethod"/>
</intent-filter>
</service>
</application>
and Build Gradle file here:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.tomsapp.keeskeyboard"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Please point out what I am doing wrong here.
In your build.Gradle file set minSDK to 22n so it matches your android vertual device.
If there is an image view in your app then place that image Corresponding to image view in the drawable folder. Don't keep it in drawable -v24 folder and run on your device it may work

Attribute providers FirebaseInitProvider and FacebookInitProvider from AndroidManifest also present at AndroidManifest

My application was composed of only one application module. I recently tried to split it into 2 modules (a feature base and a application apk one) in order to add later an instant-app module.
My newly created feature module's AndroidManifest and gradle.build contain everything that was inside the previous application module ones:
feature AndroidManifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest package="base.package"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- all uses-permissions and permissions -->
<application>
<!-- activities, intent-filters... -->
<provider android:authorities="com.facebook.app.FacebookContentProvider663###########"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
<!-- etc -->
</application>
</manifest>
application AndroidManifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest package="app.package"
xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
feature build.gradle :
apply plugin: 'com.android.feature'
android {
buildTypes {
debug {
// debug values
}
release {
// release values
}
}
lintOptions {
checkReleaseBuilds false
}
compileSdkVersion rootProject.compileSdk
defaultConfig {
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
versionCode rootProject.versionCode
versionName rootProject.versionName
}
baseFeature true
}
dependencies {
api "com.android.support:appcompat-v7:$rootProject.supportLib"
application project(':apk')
compile "com.google.firebase:firebase-core:$rootProject.gmsLib"
compile 'com.facebook.android:facebook-android-sdk:4.27.0'
// other dependencies
}
application build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.compileSdk
defaultConfig {
applicationId "app.package"
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
versionCode rootProject.versionCode
versionName rootProject.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(":feature")
}
apply plugin: 'com.google.gms.google-services'
However, although everything builds fine, I have a problem with my APK run configuration:
When I select Default Activity in Launch Options, I get a Default Activity not found warning , and when I select a specific one, I get a The Activity 'XXXX' is not declared in AndroidManifest.xml one.
After some research, I realized this is because of an error with the apk Manifest, that I was able to find by looking at the "Merged Manifest" option. Here is the output:
I couldn't find relevant information to help me about this issue... thanks for any help!
I was able to solve this issue by adding tools:node="replace" in the <application> node of the feature's AndroidManifest. Also, don't forget to add xmlns:tools="http://schemas.android.com/tools" at Manifest top-level.
Try to add these providers in your base module and feature module to fix merge manifest error.
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="{$applicationId}.firebaseinitprovider"
android:exported="(check library provider have exported value true or false)"
tools:node="replace"/>
<provider
android:name="com.facebook.internal.FacebookInitProvider"
android:authorities="{$applicationId}.FacebookInitProvider"
android:exported="(check library provider have exported value true or false)"
tools:node="replace"/>

How to use different package names between flavors?

I'm trying to create a single project with 2 flavors: free and pro (versions).
My app is already in PlayStore with different packages (E.g.: com.example.appfree and com.example.app)
This is my build.gradle:
defaultConfig {
applicationId "com.example.appfree"
}
productFlavors{
lite {
applicationIdSuffix 'lite'
}
pro {
}
}
And this is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
</application>
</manifest>
I tried to upload a build apk for free and pro flavors. Pro flavor is ok, but free flavor isnt accepted by Google, because the package is incorrect. How can I solve this?
====== Solved: ======
applicationIdSuffix only works with buildTypes.
With the new Android Gradle build system, you can easily build multiple different versions of your app; for example, you can build both a "free" version and a "pro" version of your app (using flavors), and these should have different packages in the Google Play store such that they can be installed and purchased separately, both installed at the same time, and so on. Similarly, you may also build both "debug" and "alpha" and "beta" versions of your app (using build types) and these can also similarly contribute to unique package names.
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1"
defaultConfig {
applicationId "com.example.my.app"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
...
app/build.gradle:
productFlavors {
pro {
applicationId = "com.example.my.pkg.pro"
}
free {
applicationId = "com.example.my.pkg.free"
}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
....
from Android Studio Project Site - ApplicationId versus PackageName
flavorDimensions "version"
productFlavors {
demo {
// Assigns this product flavor to the "version" flavor dimension.
// This property is optional if you are using only one dimension.
dimension "version"
applicationIdSuffix ".demo"
versionNameSuffix "-demo"
}
full {
dimension "version"
applicationIdSuffix ".full"
versionNameSuffix "-full"
}
}
Besides the basic gradle.build (app level) changes. Note that you only need to add the config you need to, not all of these:
productFlavors {
enterprise {
applicationId = "com.example.appname.enterprise"
}
consumer {
applicationId = "com.example.appname.consumer"
}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
I wanted to add that if you are using Firebase and you are required to have a google-services.json file. You will see the following:
ERROR: No matching client found for package name "com.example.appname.debug"
To fix it, you will need to register the new package name in Firebase and download the new google-services.json which will have all your existing packages names. If not you will have a compile error saying no client was found for the new package name.

Do I have to set SDKVersion in AndroidManifest.xml when defined in the gradle android closure?

I use Android Studio and have the following in my build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "de.majestella.test1"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Does this configuration automatically adds the following values to the AndroidManifest.xml file?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.androidhive.customlistviewvolley"
android:versionCode="1"
android:versionName="1.0.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
...
When I set permissions like:
<uses-permission android:name="android.permission.INTERNET" />
Does gradle overrides the permissions set in AndroidManifest.xml?
gradle declaration automatically overrides what is in your manifest
Not always.
For example I was using some method which required an API above the current minimum. So I changed it in build.gradle and it did nothing to remove the warning. However once I added it in the Manifest it recognised it and removed the warning. I also double checked to make sure. So it's better practice to declare it in the Manifest itself if you are changing API levels from the original ones used when first creating your apps resource files. I do it whenever I make a complex app with a lot of classes unlike a test app.

android studio debug on device makes 2 application icon on application list

I'm new to Android Studio (v1.0). I've created a project on it and when I debug or run project from android studio into my Galaxy Nexus phone, I see 2 application icon on application list. And when I uninstall one of them another one also removes. The package name of both are the same.
Is this normal? Maybe I forgot to do some settings.
My build.gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.aliaa.myapp"
minSdkVersion 9
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
//noinspection GradleCompatible
compile 'com.android.support:gridlayout-v7:21.0.3'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
}
Does Anyone have same experiences?
Check your AndroidManifest.xml file and inspect <activity> entries. Anything with intent filter like this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
will be listed by Launcher as entry point. You usually need one entry point per app.

Categories

Resources