<commit_before># Building TensorFlow on Android

To get you started working with TensorFlow on Android, we'll walk through two
ways to build our TensorFlow mobile demos and deploying them on an Android
device. The first is Android Studio, which lets you build and deploy in an
IDE. The second is building with Bazel and deploying with ADB on the command
line.

Why choose one or the other of these methods?

The simplest way to use TensorFlow on Android is to use Android Studio. If you
aren't planning to customize your TensorFlow build at all, or if you want to use
Android Studio's editor and other features to build an app and just want to add
TensorFlow to it, we recommend using Android Studio.

If you are using custom ops, or have some other reason to build TensorFlow from
scratch, scroll down and see our instructions
for [building the demo with Bazel](#build_the_demo_using_bazel).

## Build the demo using Android Studio

**Prerequisites**

If you haven't already, do the following two things:

- Install [Android Studio](https://developer.android.com/studio/index.html),
  following the instructions on their website.

- Clone the TensorFlow repository from Github:

        git clone https://github.com/tensorflow/tensorflow

**Building**

1. Open Android Studio, and from the Welcome screen, select **Open an existing
   Android Studio project**.

2. From the **Open File or Project** window that appears, navigate to and select
    the `tensorflow/examples/android` directory from wherever you cloned the
    TensorFlow Github repo.  Click OK.

    If it asks you to do a Gradle Sync, click OK.

    You may also need to install various platforms and tools, if you get
    errors like "Failed to find target with hash string 'android-23' and similar.

3. Open the `build.gradle` file (you can go to **1:Project** in the side panel
    and find it under the **Gradle Scripts** zippy under **Android**). Look for
    the `nativeBuildSystem` variable and set it to `none` if it isn't already:

        // set to 'bazel', 'cmake', 'makefile', 'none'
        def nativeBuildSystem = 'none'

4. Click the Run button (the green arrow) or use **Run -> Run 'android'** from the top menu.

    If it asks you to use Instant Run, click **Proceed Without Instant Run**.

    Also, you need to have an Android device plugged in with developer options
    enabled at this
    point. See [here](https://developer.android.com/studio/run/device.html) for<commit_msg>Docs: Fix 'Unable to find source java class'<commit_after># Building TensorFlow on Android

To get you started working with TensorFlow on Android, we'll walk through two
ways to build our TensorFlow mobile demos and deploying them on an Android
device. The first is Android Studio, which lets you build and deploy in an
IDE. The second is building with Bazel and deploying with ADB on the command
line.

Why choose one or the other of these methods?

The simplest way to use TensorFlow on Android is to use Android Studio. If you
aren't planning to customize your TensorFlow build at all, or if you want to use
Android Studio's editor and other features to build an app and just want to add
TensorFlow to it, we recommend using Android Studio.

If you are using custom ops, or have some other reason to build TensorFlow from
scratch, scroll down and see our instructions
for [building the demo with Bazel](#build_the_demo_using_bazel).

## Build the demo using Android Studio

**Prerequisites**

If you haven't already, do the following two things:

- Install [Android Studio](https://developer.android.com/studio/index.html),
  following the instructions on their website.

- Clone the TensorFlow repository from Github:

        git clone https://github.com/tensorflow/tensorflow

**Building**

1. Open Android Studio, and from the Welcome screen, select **Open an existing
   Android Studio project**.

2. From the **Open File or Project** window that appears, navigate to and select
    the `tensorflow/examples/android` directory from wherever you cloned the
    TensorFlow Github repo.  Click OK.

    If it asks you to do a Gradle Sync, click OK.

    You may also need to install various platforms and tools, if you get
    errors like "Failed to find target with hash string 'android-23' and similar.

3. Open the `build.gradle` file (you can go to **1:Project** in the side panel
    and find it under the **Gradle Scripts** zippy under **Android**). Look for
    the `nativeBuildSystem` variable and set it to `none` if it isn't already:

        // set to 'bazel', 'cmake', 'makefile', 'none'
        def nativeBuildSystem = 'none'

4. Running "Build -> Rebuild Project" from Android Studio menu and click the 
    Run button (the green arrow) or use **Run -> Run 'android'** from the top menu.

    If it asks you to use Instant Run, click **Proceed Without Instant Run**.

    Also, you need to have an Android device plugged in with developer options
    enabled at this
    point. See [here](https://developer.android.com/studio/run/device.html) for
{'fraction_non_alphanumeric': 0.06660039761431412, 'fraction_numerical': 0.002783300198807157, 'mean_word_length': 3.828214971209213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3359228', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1290, 'n_words': 737}