Developers » AS2 tagging » Android » Advanced features » Instant App
Instant App
Foreword
Before getting started, you’ll need to download our SDK via the Tag Composer tool by logging into your AT Internet account, or by using the SDK dependency available in JCenter (refer to the documentation on integrating the library).
Creating an instant app requires version 3.0 minimum of Android Studio.
See all prerequisites in the official documentation: https://developer.android.com/topic/instant-apps/getting-started/index.html
Basic structure of a project
A “basic” instant app is composed of three modules: the instant app module (Instant app module), the app module and the base feature (see https://developer.android.com/topic/instant-apps/getting-started/structure.html).
Integration in Android Studio
Library
The principle of integration is the same as with a standard application. Only the destination changes, since in order to integrate the library into your project, you must copy it to the folder called “MyProject/feature/libs” in the base feature module, this module contains (among other things) the resources shared between the instant app and app modules.
After having synchronised your project (Sync Project with Gradle Files), open the build.gradle file in the base feature module (feature in this example).
The build.gradle file :
- Integration of the library in JAR format
apply plugin: 'com.android.feature' android { compileSdkVersion 26 defaultConfig { minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } // If this block doesn't exists, add it repositories{ maven { url "https://dl.bintray.com/atinternet/maven/" } flatDir { dirs 'libs' } } dependencies { api fileTree(dir: 'libs', include: ['*.jar']) implementation project(':base') testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' }
- Integration of the library in AAR format
apply plugin: 'com.android.feature' android { compileSdkVersion 26 defaultConfig { minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } // If this block doesn't exists, add it repositories{ maven { url "https://dl.bintray.com/atinternet/maven/" } flatDir { dirs 'libs' } } dependencies { api fileTree(dir: 'libs', include: ['*.aar']) implementation project(':base') testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' }
- Integration of the JCenter dependency
apply plugin: 'com.android.feature' android { compileSdkVersion 26 defaultConfig { minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } // If this block doesn't exists, add it repositories{ maven { url "https://dl.bintray.com/atinternet/maven/" } flatDir { dirs 'libs' } } dependencies { implementation project(':base') testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' api 'com.atinternet:Tracker:2.x.x'// >= 2.0.6 }
Instant app best practices would suggest reducing overall module size (including the “libs” file with archives). It’s therefore preferable for the user to load the library in JAR format which is lighter.
It should nonetheless be noted that, in this case, it won’t be possible to enable Live Tagging or the Debugger which require graphic resources only present in the AAR-format archive.
The Live Tagging and Debugger features are not available on instant app-type modules, notably due to limitations in terms of Android permissions (not possible to use the permission on the overlay: “android.permission.SYSTEM_ALERT_WINDOW”). Please see https://developer.android.com/topic/instant-apps/faqs.html for more details.
Authorisations
The addition of authorisations must be done in the AndroidManifest.xml file of the base feature module.
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Tagging
Tagging must be added in the activity of the feature(s) in question based on the project’s structure.
According to Android documentation FAQ: “All the network traffic from inside instant apps must use HTTPS. Instant apps does not support HTTP.” (see https://developer.android.com/topic/instant-apps/faqs.html).
Last update: 11/12/2017The Tracker’s secure mode must be enabled (with secure log) to allow hits to be sent on an instant app.