Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running on device (android) documentation #375

Closed
jneuendorf opened this issue May 25, 2018 · 2 comments
Closed

Running on device (android) documentation #375

jneuendorf opened this issue May 25, 2018 · 2 comments
Labels
Stale Issues/PR that are not getting much activity and are closer to be closed

Comments

@jneuendorf
Copy link

jneuendorf commented May 25, 2018

Hi,

I struggled getting my app running on an android device (from macOS). Steps 1 und 2 worked well but when I ran the app I got the following problems:

  1. SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
    The .gitignore created by RN even contains local.properties.
  2. The SDK package licenses have not been accepted.

I think both things should be at least mentioned1 in the docs as people running a (RN) app on android for the very first time will run into these problems - even if these problems aren't directly caused be RN.

1 I provided some links in the script below.

Here is my final (homebrew-based) script for preparing everything for running my app on android. If such details are welcome in the docs (I've read the guidelines but am not sure if this is a bit to much/specific), some parts of the script could be written down more human-friendly I guess.

#!/usr/bin/env bash

which brew > /dev/null
# install Homebrew if not yet installed
if [[ "$?" == "1" ]]; then
    echo "Installing homebrew."
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

echo "Installing android-platform-tools."
brew cask install android-platform-tools
echo "Installing android-sdk."
brew cask install android-sdk

which java > /dev/null
# install java 8 (required for android-sdk)
if [[ "$?" == "1" ]]; then
    echo "Installing Java 8."
    brew cask install caskroom/versions/java8
else
    is_java8=$(java -version 2>&1 | grep 'java version "1.8')
    if [[ "$is_java8" != "" ]]; then
        echo "Yeah, you have the right Java version installed!"
    else
        echo "You seem to have Java installed but you need version 8 for the android SDK."
        echo "Check out https://stackoverflow.com/a/29195815/6928824 for more information on managing multiple Java versions."
    fi
fi

# See https://stackoverflow.com/questions/35141951/
props_file=./android/local.properties
touch "$props_file"
if grep --quiet 'sdk.dir' "$props_file"; then
    echo "'$props_file' already contains a property 'sdk.dir'."
    echo "You should set the following its value as shown below:

    sdk.dir=/usr/local/share/android-sdk
    "
else
    echo "Setting SDK path."
    echo "sdk.dir=/usr/local/share/android-sdk" >> "$props_file"
fi

# This file should exist to avoid a warning. See https://stackoverflow.com/a/38641430/6928824
repo_file=~/.android/repositories.cfg
if [ ! -f "$repo_file" ]; then
    echo "Creating '$repo_file'."
    echo "### User Sources for Android SDK Manager
    count=0" > "$repo_file"
else
    echo "No need to create $repo_file. It already exists."
fi

# Accept all licenses. See https://stackoverflow.com/q/38096225/6928824
echo "Accepting licenses."
yes | sdkmanager --licenses #--sdk_root=$ANDROID_SDK_PATH

I find this issue is somewhat related to #370.

@stale
Copy link

stale bot commented Aug 16, 2020

👋 Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Issues/PR that are not getting much activity and are closer to be closed label Aug 16, 2020
@stale
Copy link

stale bot commented Aug 23, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Issues/PR that are not getting much activity and are closer to be closed
Projects
None yet
Development

No branches or pull requests

1 participant