Categories News

Ejemplo de proyecto de Android con pruebas repetibles ejecutándose dentro del emulador

06 mayo 2020 [Android, Java, Programming, Tech]

Pasé los últimos días luchando contra la línea de comandos de Android para configurar un proyecto simple que pueda ejecutar pruebas automatizadas dentro del emulador de manera confiable y repetible.

Para que las pruebas sean confiables e independientes de cualquier otra cosa en mi máquina, quiero almacenar los archivos AVD y SDK de Android en un directorio local.

Para hacer esto, tuve que definir muchas variables de entorno interrelacionadas y envolver la herramienta en un script que garantizara que se ejecutara con las opciones y configuraciones correctas.

El resultado final de este trabajo está aquí: gitlab.com/andybalaam/android-skeleton

Necesitará todos los scripts de utilidad incluidos en ese repositorio para que funcione, pero algunos importantes incluyen:

Variables de entorno que obtengo en cada script, script/ruta:

PROJECT_ROOT=$(dirname $(dirname $(realpath $BASH_SOURCE[$#BASH_SOURCE[@] - 1])))
export ANDROID_SDK_ROOT="$PROJECT_ROOT/android_sdk"
export ANDROID_SDK_HOME="$ANDROID_SDK_ROOT"
export ANDROID_EMULATOR_HOME="$ANDROID_SDK_ROOT/emulator-home"
export ANDROID_AVD_HOME="$ANDROID_EMULATOR_HOME/avd"

Cree un archivo local.properties que indique a Gradle y Android Studio dónde está el SDK ejecutando algo como esto:

echo "# File created automatically - changes will be overwritten!" > local.properties
echo "sdk.dir=$ANDROID_SDK_ROOT" >> local.properties

Scripts contenedores para herramientas de Android, por ejemplo scripts/sdkmanager:

#!/bin/bash

set -e set -u

source scripts/paths

"$ANDROID_SDK_ROOT/tools/bin/sdkmanager"
"--sdk_root=$ANDROID_SDK_ROOT"
"$@"

El contenedor para avdmanager es particularmente interesante porque parece que necesitamos reemplazar lo que se cree que es el directorio de herramientas para que funcione correctamente: scripts/avdmanager:

#!/bin/bash

set -e set -u

source scripts/paths

AVDMANAGER_OPTS="-Dcom.android.sdkmanager.toolsdir=$ANDROID_SDK_ROOT/tools/bin/"
"$ANDROID_SDK_ROOT/tools/bin/avdmanager" "$@"

Script de instalación que debe ejecutarse una vez antes de usar el script project/install-android-tools:

#!/bin/bash

set -e set -u set -x

source scripts/paths

mkdir -p "$ANDROID_SDK_ROOT" mkdir -p "$ANDROID_AVD_HOME" mkdir -p "$ANDROID_EMULATOR_HOME"

cd "$ANDROID_SDK_ROOT" test -f commandlinetools-.zip ||
wget -q ' unzip -q -u commandlinetools-
.zip cd ..

./scripts/sdkmanager --update

yes | ./scripts/sdkmanager --install 'emulator' 'platform-tools'

./scripts/sdkmanager --install 'platforms;android-21' ./scripts/sdkmanager --install 'platforms;android-29'

yes | ./scripts/sdkmanager --install 'system-images;android-21;default;x86_64' yes | ./scripts/sdkmanager --install 'system-images;android-29;default;x86_64'

echo no | ./scripts/avdmanager -v
create avd
-f
-n "avd-21"
-k "system-images;android-21;default;x86_64"
-p $ANDROID_SDK_ROOT/avds/avd-21 echo no | ./scripts/avdmanager -v
create avd
-f
-n "avd-29"
-k "system-images;android-29;default;x86_64"
-p $ANDROID_SDK_ROOT/avds/avd-29

Contribuya a este proyecto si conoce una manera más fácil de hacerlo.

PakarPBN

A Private Blog Network (PBN) is a collection of websites that are controlled by a single individual or organization and used primarily to build backlinks to a “money site” in order to influence its ranking in search engines such as Google. The core idea behind a PBN is based on the importance of backlinks in Google’s ranking algorithm. Since Google views backlinks as signals of authority and trust, some website owners attempt to artificially create these signals through a controlled network of sites.

In a typical PBN setup, the owner acquires expired or aged domains that already have existing authority, backlinks, and history. These domains are rebuilt with new content and hosted separately, often using different IP addresses, hosting providers, themes, and ownership details to make them appear unrelated. Within the content published on these sites, links are strategically placed that point to the main website the owner wants to rank higher. By doing this, the owner attempts to pass link equity (also known as “link juice”) from the PBN sites to the target website.

The purpose of a PBN is to give the impression that the target website is naturally earning links from multiple independent sources. If done effectively, this can temporarily improve keyword rankings, increase organic visibility, and drive more traffic from search results.

Jasa Backlink

Download Anime Batch

More From Author