Skip to content

Commit 52fc7fe

Browse files
authored
android: fix missing screenshots for Android.md (#18156)
* Android basic sample app layout polish * Add missing screenshots and polish android README doc * Replace file blobs with URLs served by GitHub pages service.
1 parent cdbada8 commit 52fc7fe

File tree

6 files changed

+37
-33
lines changed

6 files changed

+37
-33
lines changed

docs/android.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11

22
# Android
33

4-
## Build with Android Studio
4+
## Build GUI binding using Android Studio
55

66
Import the `examples/llama.android` directory into Android Studio, then perform a Gradle sync and build the project.
7-
![Project imported into Android Studio](./android/imported-into-android-studio.png)
7+
![Project imported into Android Studio](./android/imported-into-android-studio.jpg)
88

99
This Android binding supports hardware acceleration up to `SME2` for **Arm** and `AMX` for **x86-64** CPUs on Android and ChromeOS devices.
1010
It automatically detects the host's hardware to load compatible kernels. As a result, it runs seamlessly on both the latest premium devices and older devices that may lack modern CPU features or have limited RAM, without requiring any manual configuration.
1111

1212
A minimal Android app frontend is included to showcase the binding’s core functionalities:
13-
1. **Parse GGUF metadata** via `GgufMetadataReader` from either a `ContentResolver` provided `Uri` or a local `File`.
14-
2. **Obtain a `TierDetection` or `InferenceEngine`** instance through the high-level facade APIs.
15-
3. **Send a raw user prompt** for automatic template formatting, prefill, and decoding. Then collect the generated tokens in a Kotlin `Flow`.
13+
1. **Parse GGUF metadata** via `GgufMetadataReader` from either a `ContentResolver` provided `Uri` from shared storage, or a local `File` from your app's private storage.
14+
2. **Obtain a `InferenceEngine`** instance through the `AiChat` facade and load your selected model via its app-private file path.
15+
3. **Send a raw user prompt** for automatic template formatting, prefill, and batch decoding. Then collect the generated tokens in a Kotlin `Flow`.
1616

17-
For a production-ready experience that leverages advanced features such as system prompts and benchmarks, check out [Arm AI Chat](https://play.google.com/store/apps/details?id=com.arm.aichat) on Google Play.
17+
For a production-ready experience that leverages advanced features such as system prompts and benchmarks, plus friendly UI features such as model management and Arm feature visualizer, check out [Arm AI Chat](https://play.google.com/store/apps/details?id=com.arm.aichat) on Google Play.
1818
This project is made possible through a collaborative effort by Arm's **CT-ML**, **CE-ML** and **STE** groups:
1919

20-
| ![Home screen](./android/arm-ai-chat-home-screen.png) | ![System prompt](./android/system-prompt-setup.png) | !["Haiku"](./android/chat-with-system-prompt-haiku.png) |
20+
| ![Home screen](https://naco-siren.github.io/ai-chat/policy/index/1-llm-starter-pack.png) | ![System prompt](https://naco-siren.github.io/ai-chat/policy/index/5-system-prompt.png) | !["Haiku"](https://naco-siren.github.io/ai-chat/policy/index/4-metrics.png) |
2121
|:------------------------------------------------------:|:----------------------------------------------------:|:--------------------------------------------------------:|
2222
| Home screen | System prompt | "Haiku" |
2323

24-
## Build on Android using Termux
24+
## Build CLI on Android using Termux
2525

2626
[Termux](https://termux.dev/en/) is an Android terminal emulator and Linux environment app (no root required). As of writing, Termux is available experimentally in the Google Play Store; otherwise, it may be obtained directly from the project repo or on F-Droid.
2727

@@ -52,7 +52,7 @@ To see what it might look like visually, here's an old demo of an interactive se
5252

5353
https://user-images.githubusercontent.com/271616/225014776-1d567049-ad71-4ef2-b050-55b0b3b9274c.mp4
5454

55-
## Cross-compile using Android NDK
55+
## Cross-compile CLI using Android NDK
5656
It's possible to build `llama.cpp` for Android on your host system via CMake and the Android NDK. If you are interested in this path, ensure you already have an environment prepared to cross-compile programs for Android (i.e., install the Android SDK). Note that, unlike desktop environments, the Android environment ships with a limited set of native libraries, and so only those libraries are available to CMake when building with the Android NDK (see: https://developer.android.com/ndk/guides/stable_apis.)
5757

5858
Once you're ready and have cloned `llama.cpp`, invoke the following in the project directory:
479 KB
Loading

examples/llama.android/README.md

Whitespace-only changes.

examples/llama.android/app/src/main/res/layout/activity_main.xml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
5-
android:id="@+id/main"
6-
android:layout_height="match_parent"
7-
android:layout_width="match_parent">
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:id="@+id/main"
6+
android:layout_height="match_parent"
7+
android:layout_width="match_parent">
88

99
<LinearLayout
1010
android:fitsSystemWindows="true"
1111
android:layout_width="match_parent"
1212
android:layout_height="match_parent"
1313
android:orientation="vertical"
14+
android:layout_marginEnd="4dp"
1415
tools:context=".MainActivity">
1516

16-
<FrameLayout
17+
<ScrollView
1718
android:layout_width="match_parent"
1819
android:layout_height="0dp"
19-
android:layout_weight="1">
20+
android:layout_weight="1"
21+
android:fadeScrollbars="false">
2022

21-
<ScrollView
23+
<TextView
24+
android:id="@+id/gguf"
2225
android:layout_width="match_parent"
2326
android:layout_height="wrap_content"
24-
android:fadeScrollbars="false">
25-
26-
<TextView
27-
android:id="@+id/gguf"
28-
android:layout_width="match_parent"
29-
android:layout_height="wrap_content"
30-
android:layout_margin="16dp"
31-
android:text="Selected GGUF model's metadata will show here."
32-
style="@style/TextAppearance.MaterialComponents.Body2"
33-
android:maxLines="100" />
27+
android:layout_margin="16dp"
28+
android:text="Selected GGUF model's metadata will show here."
29+
style="@style/TextAppearance.MaterialComponents.Body2" />
3430

35-
</ScrollView>
31+
</ScrollView>
3632

37-
</FrameLayout>
33+
<com.google.android.material.divider.MaterialDivider
34+
android:layout_width="match_parent"
35+
android:layout_height="2dp"
36+
android:layout_marginHorizontal="16dp"
37+
android:layout_marginVertical="8dp" />
3838

3939
<androidx.recyclerview.widget.RecyclerView
4040
android:id="@+id/messages"
4141
android:layout_width="match_parent"
4242
android:layout_height="0dp"
4343
android:layout_weight="4"
44-
android:padding="16dp"
4544
android:fadeScrollbars="false"
45+
android:scrollbars="vertical"
4646
app:reverseLayout="true"
4747
tools:listitem="@layout/item_message_assistant"/>
4848

4949
<LinearLayout
5050
android:layout_width="match_parent"
5151
android:layout_height="wrap_content"
52-
android:orientation="horizontal">
52+
android:orientation="horizontal"
53+
android:paddingStart="16dp"
54+
android:paddingEnd="4dp">
5355

5456
<EditText
5557
android:id="@+id/user_input"
@@ -67,7 +69,7 @@
6769
style="@style/Widget.Material3.FloatingActionButton.Primary"
6870
android:layout_width="wrap_content"
6971
android:layout_height="wrap_content"
70-
android:layout_margin="8dp"
72+
android:layout_margin="12dp"
7173
android:src="@drawable/outline_folder_open_24" />
7274

7375
</LinearLayout>

examples/llama.android/app/src/main/res/layout/item_message_assistant.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="wrap_content"
5-
android:padding="8dp"
5+
android:layout_marginHorizontal="16dp"
6+
android:layout_marginVertical="8dp"
67
android:gravity="start">
78

89
<TextView

examples/llama.android/app/src/main/res/layout/item_message_user.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="wrap_content"
5-
android:padding="8dp"
5+
android:layout_marginHorizontal="16dp"
6+
android:layout_marginVertical="8dp"
67
android:gravity="end">
78

89
<TextView

0 commit comments

Comments
 (0)