1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # This installs the Android SDK (Software Development Kit)
|
---|
4 | # which is needed for the compilation of the Java project.
|
---|
5 |
|
---|
6 | source $ANDROID_DIR/android_aux.sh
|
---|
7 |
|
---|
8 | # Different steps here.
|
---|
9 | # 0: do all
|
---|
10 | # 1: install sdk, ant and sdk tools
|
---|
11 | # 2: install an emulator.
|
---|
12 | # 3: test the emulator
|
---|
13 | # 4: cleanup
|
---|
14 |
|
---|
15 | present_dir=`pwd`;
|
---|
16 | sd_card="issm-sdcard"
|
---|
17 |
|
---|
18 | if [[ $step == "1" || $step == "0" ]]; then
|
---|
19 |
|
---|
20 | # Cleanup the install
|
---|
21 | rm -rf install
|
---|
22 |
|
---|
23 | # Download from ISSM server
|
---|
24 | $ISSM_DIR/scripts/DownloadExternalPackage.sh 'https://issm.ess.uci.edu/files/externalpackages/android-sdk_r'$sdk_rev'-macosx.zip' 'android-sdk_r'${sdk_rev}'-macosx.zip'
|
---|
25 |
|
---|
26 | # Install Android SDK and NDK.
|
---|
27 | unzip -o android-sdk_r${sdk_rev}-macosx.zip
|
---|
28 |
|
---|
29 | # Move to install
|
---|
30 | mv -f android-sdk-macosx install
|
---|
31 |
|
---|
32 | # Post_install configuration:
|
---|
33 | # We need specific settings for specific platforms, for the SDK to
|
---|
34 | # function properly
|
---|
35 |
|
---|
36 | # For now, we need to install:
|
---|
37 | # android sdk platform tools
|
---|
38 | # and a specific android api: API 16, API 15 and API 14
|
---|
39 | # Note: API 16, API 15 and 14 correspond to Android 4.1, 4.0.3 and 4.0 respectively.
|
---|
40 |
|
---|
41 | cd install/tools/ && source ./android update sdk -t platform-tool,${api_levels},system-image --no-ui
|
---|
42 |
|
---|
43 | fi
|
---|
44 |
|
---|
45 | if [[ $step == "2" || $step == "0" ]]; then
|
---|
46 |
|
---|
47 | # Once this is done, we need to install an emulator. Location will default to ~/.android/avd,
|
---|
48 | # which we will move to $ISSM_DIR/externalpackages/android-emulators.
|
---|
49 | # For now, it's called: Android-4.0.3
|
---|
50 |
|
---|
51 | # Here we delete the Android-4.0.3 device if it already exists.
|
---|
52 | cd $present_dir/install/tools
|
---|
53 |
|
---|
54 | if [ -e $ANDROID_DIR/android-emulators/$default_droid ]
|
---|
55 | then
|
---|
56 | echo "Deleting previously created device: $default_droid"
|
---|
57 | ./android delete avd -n $default_droid
|
---|
58 | fi
|
---|
59 |
|
---|
60 | # Android will prompt the user to specify hardware emulation options. For now, default
|
---|
61 | # default settings will suffice. Press 'enter' to take default settings or enter 'no'.
|
---|
62 |
|
---|
63 | ./android create avd -f -n $default_droid -t 1 -p $ANDROID_DIR/android-emulators/$default_droid --abi armeabi-v7a
|
---|
64 | echo "Creating an SD Card"
|
---|
65 | ./mksdcard -l $sd_card 2G $ANDROID_DIR/android-emulators/$sd_card.img
|
---|
66 | fi
|
---|
67 |
|
---|
68 | if [[ $step == "3" || $step == "0" ]]; then
|
---|
69 | # Here we will start up our default emulator to test that it is working properly.
|
---|
70 | # Once the device has booted we will use the Android Debug Bridge tool to gain
|
---|
71 | # a terminal in our device.
|
---|
72 |
|
---|
73 | cd $present_dir/install/tools
|
---|
74 | ./emulator -avd $default_droid -sdcard $ANDROID_DIR/android-emulators/$sd_card.img &
|
---|
75 |
|
---|
76 | cd ../platform-tools
|
---|
77 | ./adb wait-for-device shell
|
---|
78 | fi
|
---|
79 |
|
---|
80 | if [[ $step == "4" || $step == "0" ]]; then
|
---|
81 | rm -rf install
|
---|
82 | fi
|
---|