From fab50875b98e8274ac8ee44b38ba42521bbbf1f9 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Wed, 16 Apr 2014 14:40:42 -0700 Subject: Add support for building split APKs Build multiple APKs, each containing a disjoint subset of configurations. These can then be loaded into the device AssetManager and should operate as if they were never split. Use the idea of building multiple sets of files, where each set represents an APK. An ApkBuilder can place files in a set based on its configuration, but you can actually add directly to a set, in the case of the resources.arsc and generated AndroidManifest.xml for splits. Change-Id: Ic65d3f0ac1bbd290185695b9971d425c85ab1de3 --- tests/Split/Android.mk | 28 +++++++++++++ tests/Split/AndroidManifest.xml | 27 +++++++++++++ tests/Split/assets/blah.txt | 1 + tests/Split/assets/statement.xml | 19 +++++++++ tests/Split/res/layout-fr-sw600dp/main.xml | 23 +++++++++++ tests/Split/res/layout/main.xml | 19 +++++++++ tests/Split/res/values-de/values.xml | 19 +++++++++ tests/Split/res/values-fr/values.xml | 25 ++++++++++++ tests/Split/res/values-sw600dp/values.xml | 19 +++++++++ tests/Split/res/values/values.xml | 47 ++++++++++++++++++++++ .../com/android/example/split/ActivityMain.java | 31 ++++++++++++++ 11 files changed, 258 insertions(+) create mode 100644 tests/Split/Android.mk create mode 100644 tests/Split/AndroidManifest.xml create mode 100644 tests/Split/assets/blah.txt create mode 100644 tests/Split/assets/statement.xml create mode 100644 tests/Split/res/layout-fr-sw600dp/main.xml create mode 100644 tests/Split/res/layout/main.xml create mode 100644 tests/Split/res/values-de/values.xml create mode 100644 tests/Split/res/values-fr/values.xml create mode 100644 tests/Split/res/values-sw600dp/values.xml create mode 100644 tests/Split/res/values/values.xml create mode 100644 tests/Split/src/java/com/android/example/split/ActivityMain.java (limited to 'tests') diff --git a/tests/Split/Android.mk b/tests/Split/Android.mk new file mode 100644 index 0000000..7884d4d --- /dev/null +++ b/tests/Split/Android.mk @@ -0,0 +1,28 @@ +# +# Copyright (C) 2014 The Android Open Source Project +# +# 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. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) +LOCAL_PACKAGE_NAME := Split + +LOCAL_AAPT_FLAGS := --split fr,de +LOCAL_AAPT_FLAGS += -v + +LOCAL_MODULE_TAGS := tests + +include $(BUILD_PACKAGE) diff --git a/tests/Split/AndroidManifest.xml b/tests/Split/AndroidManifest.xml new file mode 100644 index 0000000..a4956a7 --- /dev/null +++ b/tests/Split/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/tests/Split/assets/blah.txt b/tests/Split/assets/blah.txt new file mode 100644 index 0000000..1b37e40 --- /dev/null +++ b/tests/Split/assets/blah.txt @@ -0,0 +1 @@ +This is some useful info. diff --git a/tests/Split/assets/statement.xml b/tests/Split/assets/statement.xml new file mode 100644 index 0000000..91750d1 --- /dev/null +++ b/tests/Split/assets/statement.xml @@ -0,0 +1,19 @@ + + + + + Hello + diff --git a/tests/Split/res/layout-fr-sw600dp/main.xml b/tests/Split/res/layout-fr-sw600dp/main.xml new file mode 100644 index 0000000..2461c8c --- /dev/null +++ b/tests/Split/res/layout-fr-sw600dp/main.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/tests/Split/res/layout/main.xml b/tests/Split/res/layout/main.xml new file mode 100644 index 0000000..36992a2 --- /dev/null +++ b/tests/Split/res/layout/main.xml @@ -0,0 +1,19 @@ + + + + diff --git a/tests/Split/res/values-de/values.xml b/tests/Split/res/values-de/values.xml new file mode 100644 index 0000000..26d0507 --- /dev/null +++ b/tests/Split/res/values-de/values.xml @@ -0,0 +1,19 @@ + + + + + Achtung! + diff --git a/tests/Split/res/values-fr/values.xml b/tests/Split/res/values-fr/values.xml new file mode 100644 index 0000000..16532da --- /dev/null +++ b/tests/Split/res/values-fr/values.xml @@ -0,0 +1,25 @@ + + + + + APK Divisé + Bonjour, Monde! + Bleh.. + + Hé là + Au revoir + + diff --git a/tests/Split/res/values-sw600dp/values.xml b/tests/Split/res/values-sw600dp/values.xml new file mode 100644 index 0000000..a8329bb --- /dev/null +++ b/tests/Split/res/values-sw600dp/values.xml @@ -0,0 +1,19 @@ + + + + + 230dp + diff --git a/tests/Split/res/values/values.xml b/tests/Split/res/values/values.xml new file mode 100644 index 0000000..68edc77 --- /dev/null +++ b/tests/Split/res/values/values.xml @@ -0,0 +1,47 @@ + + + + + Split APK + Hello, World! + Boom! + Blah... + + Hello there + Good bye + + + + I no haz :( + I haz 1!1! :) + I haz ALL! + + + true + #00FF00 + 23dp + + 123 + + 1234 + + + + @string/test + @string/boom + 25dp + + diff --git a/tests/Split/src/java/com/android/example/split/ActivityMain.java b/tests/Split/src/java/com/android/example/split/ActivityMain.java new file mode 100644 index 0000000..a15fb3c --- /dev/null +++ b/tests/Split/src/java/com/android/example/split/ActivityMain.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * 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. + */ + +package com.android.example.split; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; + +public class ActivityMain extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + TextView text = new TextView(this); + text.setText(R.string.test); + setContentView(text); + } +} -- cgit v1.1