Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

Commit

Permalink
New samples, improve docs, update versions
Browse files Browse the repository at this point in the history
Introduce new samples:

* config-splits
* cookie-api

Improve documentation

* Improve README files throughout.
* More consistent README files throughout.
* Unify launch instructions within the top level REAMDE.md.
* Move `hello` sample to `hello-java` to be consistent with `hello-kotlin`.
* Remove resources only relevant to serving in publication case.

Update versions

* gradle and plugin to beta6 requirements
* support lib to 26.0.1
  • Loading branch information
keyboardsurfer committed Oct 3, 2017
1 parent 39b5137 commit 95085c3
Show file tree
Hide file tree
Showing 182 changed files with 2,788 additions and 547 deletions.
17 changes: 8 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

## Contributor License Agreements

We'd love to accept your sample apps and patches! Before we can take them, we
We'd love to accept your sample apps and patches! Before we can accept them, we
have to jump a couple of legal hurdles.

Please fill out either the individual or corporate Contributor License Agreement (CLA).

* If you are an individual writing original source code and you're sure you
own the intellectual property, then you'll need to sign an [individual CLA]
(https://developers.google.com/open-source/cla/individual).
own the intellectual property, then you'll need to sign an
[individual CLA](https://developers.google.com/open-source/cla/individual).
* If you work for a company that wants to allow you to contribute your work,
then you'll need to sign a [corporate CLA]
(https://developers.google.com/open-source/cla/corporate).
then you'll need to sign a
[corporate CLA](https://developers.google.com/open-source/cla/corporate).

Follow either of the two links above to access the appropriate CLA and
Follow either of the two links mentioned above to access the appropriate CLA and
instructions for how to sign and return it. Once we receive it, we'll be able to
accept your pull requests.

Expand All @@ -27,9 +27,8 @@ accept your pull requests.
1. Fork the desired repo, develop and test your code changes.
1. Ensure that your code adheres to the existing style in the sample to which
you are contributing. Refer to the
[Android Code Style Guide]
(https://source.android.com/source/code-style.html) for the
recommended coding standards for this organization.
[Android Code Style Guide](https://source.android.com/source/code-style.html)
for the recommended coding standards for this organization.
1. Ensure that your code has an appropriate set of unit tests which all pass.
1. Submit a pull request.

72 changes: 69 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,76 @@
# Android Instant Apps
# Android Instant Apps - Sample code collection

The samples in this repository demonstrate [Android Instant Apps](https://d.android.com/topic/instant-apps).
The samples in this repository demonstrate building and using APIs related to
[Android Instant Apps](https://d.android.com/topic/instant-apps).

## Getting started

Enter one of the directories and read the corresponding README.md
Shared instructions on the samples are collected in this file.
For sample specific instructions, enter a sample's directory and
follow the corresponding README file.

## Available samples

`analytics` -> Usage of Firebase Analytics

`config-splits` -> Introduces Configuration splits API

`cookie-api` -> Usage of the Cookie API

`hello-java` -> Hello World written in the Java Programming Language.

`hello-kotlin` -> Hello World written in Kotlin.

`hello-feature-module` -> Hello World with feature modules

`multi-feature-module` -> More complex feature module sample

`flavors` -> product flavors in an Instant App


## Running an Instant App sample

### From Android Studio

1. Select the `instant` feature module run configuration
2. Run the selected configuration

Some samples provide multiple entry points.
In this case you can choose which URL to use before starting the Instant App.

### From the command line (Android O+)

#### Find the build output

1. Run a gradle build `./gradlew assembleDebug`.
2. Locate the zip file containing the instant app.
2.1 This is usually located at `./instant/build/outputs/debug/instant-debug.zip`
2.2 Some samples contain flavors. In these cases the output path is different.
These build output paths will be specified in the sample in question.

#### Run the Instant App

From the sample's root directory, execute

```
cd instant/build/outputs/apk/debug # navigate to build dir
unzip instantapp-debug.zip # extract apks
adb install-multiple -r -t --instantapp *.apk # install apks
# launch entry point; you'll have to replace $(SAMPLE_ENTRY_POINT)
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d $(SAMPLE_ENTRY_POINT)
cd - # takes you back to the root directory
```

### Troubleshooting

Refer to the [troubleshooting section](https://developer.android.com/topic/instant-apps/troubleshoot.html)
of the Android Instant Apps documentation.

If you find an issue with a sample, please file a [new issue](https://github.com/googlesamples/android-instant-apps/issues/new).

In case you have questions on Instant Apps, refer to [StackOverflow](https://stackoverflow.com/questions/tagged/android-instant-apps).

## License

Expand Down
4 changes: 4 additions & 0 deletions analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ After you have added the sample's package name to your Firebase project,
download the Firebase project's google-services.json file. Place the file in
the `base/` module of this sample.

## Launch URL

`https://instant.android.example.com/analytics`

## License

```
Expand Down
6 changes: 3 additions & 3 deletions analytics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath 'com.google.gms:google-services:3.1.0'
}
}
Expand All @@ -39,13 +39,13 @@ task clean(type: Delete) {
}

ext {
buildTools = '26.0.0'
buildTools = '26.0.1'
compileSdk = 26
minSdk = 15
minSdkInstant = 23
versionCode = 1
versionName = '1.0'
supportLib = '25.3.1'
supportLib = '26.1.0'
firebaseVer = '10.2.4'
instantAppsVer = '1.0.0'
}
2 changes: 1 addition & 1 deletion analytics/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
3 changes: 2 additions & 1 deletion build_all.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

set -e # Exit immediately if a command exits with a non-zero status.
projects=("analytics" "flavors" "hello" "hello-feature-module" "hello-kotlin" "service")
projects=("analytics" "config-splits" "cookie-api" "flavors"
"hello-feature-module" "hello-java" "hello-kotlin" "service")

for p in ${projects[@]}; do
echo
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions config-splits/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Android Instant Apps - Config Splits Sample

This sample displays the usage of
[Configuration APKs](https://developer.android.com/topic/instant-apps/guides/config-splits.html)
via configuration splits within gradle.

The setup of Configuration APKs can be seen within the `features/build.gradle` file.

After a build, the resulting zip file (`instant/build/output/apk/debug/instant-debug.zip`)
holds several APKs, each with a specific configuration.

In a production environment, APKs that are relevant to users' display density and locale are
served to the users. This reduces the file size over the wire and on device.

## Launch URL

`https://configsplits.instantappsample.com`

## License

```
Copyright 2017 Google Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
```

53 changes: 53 additions & 0 deletions config-splits/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.4-3'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

ext {
buildTools = '26.0.1'
compileSdk = 26
minSdkInstant = 23
minSdk = 21
versionCode = 1
versionName = '1.0'
supportLib = '26.1.0'
}
54 changes: 54 additions & 0 deletions config-splits/features/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android'

android {
compileSdkVersion rootProject.compileSdk
buildToolsVersion rootProject.buildTools

defaultConfig {
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
versionCode rootProject.versionCode
versionName rootProject.versionName
}

buildTypes {
debug {}
}

baseFeature true

splits {
generatePureSplits true

language {
enable true
include "de", "de-rAT", "de-rCH", "en", "en-rAU", "es", "pl"
}
density {
enable true
}
}
}

dependencies {
api "com.android.support:appcompat-v7:${rootProject.supportLib}"
application project(':installed')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
53 changes: 53 additions & 0 deletions config-splits/features/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--
~ Copyright 2017 Google Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.instantapps.samples.configsplits.feature">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:supportsRtl="true">

<activity
android:name=".MainActivity"
android:label="@string/app_name">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter
android:autoVerify="true"
android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />

<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="configsplits.instantappsample.com" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://configsplits.instantappsample.com" />
</activity>

</application>
</manifest>
Loading

0 comments on commit 95085c3

Please sign in to comment.