2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
Android용 스크립팅 레이어에 Trade Federation 사용
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android용 스크립팅 레이어인 SL4A는 플랫폼과 상관없는 방식으로 Android API를 호출하기 위한 자동화 도구 모음입니다.
adb
를 통한 원격 자동화와 일련의 가벼운 변환 레이어를 통한 기기에서의 스크립트 실행을 모두 지원합니다.
프로젝트는 platform/external/sl4a에서 찾을 수 있습니다.
사용
SL4A README에 따라 이를 수동으로 빌드하고 설치할 수 있습니다. 또한 Tradefed를 통해 실행 중인 경우에는 몇몇 하네스 유틸리티를 활용하여 좀 더 쉽게 사용할 수 있습니다.
다운로드 및 설치
우선 두 기기를 사용하는 Tradefed 구성의 예인 BT-discovery-sl4a.xml을 검토할 수 있습니다. SL4A.apk
는 tests
폴더 내의 대부분의 기기 빌드에서 사용할 수 있습니다.
위의 Tradefed 예시는 자동으로 빌드를 가져오고 두 기기를 모두 플래시한 후 SL4A.apk
를 두 기기에 모두 설치합니다. 아래와 같이 실행할 수 있습니다.
source build/envsetup.sh
lunch
make sl4a
tradefed.sh run google/example/BT-discovery-sl4a
아니면 빌드 후에 다음을 수행합니다.
./tradefed.sh run google/example/BT-discovery-sl4a
SL4A를 사용하여 Tradefed에서 테스트 작성
위에서 설명한 테스트 샘플을 따를 수 있습니다(Sl4aBluetoothDiscovery.java).
이는 Tradefed 테스트 내에서 SL4A를 사용하기 위한 흐름에 관한 좋은 예시를 제공합니다.
SL4A API 문서
SL4A를 통해 사용 가능한 전체 콜백 목록을 생성할 수 있습니다. SL4A 소스 디렉터리 platform/external/sl4a/
에서 다음 명령어를 실행합니다.
python Docs/generate_api_reference_md.py
문서 디렉터리에는 SL4A에서 제공되는 RPC 함수와 RPC 함수에 관한 문서가 포함된 ApiReference.md
파일이 있습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Use Trade Federation with Scripting Layer for Android\n\nScripting Layer for Android, SL4A, is an\nautomation toolset for calling Android APIs in a platform-independent manner.\nIt supports both remote automation via `adb` and execution of scripts\nfrom on-device via a series of lightweight translation layers.\n\nThe project is located at [platform/external/sl4a](https://android.googlesource.com/platform/external/sl4a/).\n\nUse\n---\n\nYou can follow the [SL4A README](https://android.googlesource.com/platform/external/sl4a/+/refs/heads/android16-release/README.md)\nto build and install it manually. And when running through Tradefed, you\ncan take advantage of some of the harness utilities to make use easier.\n\n### Download and install\n\nYou can start by reviewing\n[BT-discovery-sl4a.xml](https://android.googlesource.com/platform/tools/tradefederation/contrib/+/refs/heads/android16-release/res/config/google/example/BT-discovery-sl4a.xml),\nan example Tradefed configuration that uses two devices. The `SL4A.apk` is\navailable in most device builds within their `tests` folder.\n\nThe Tradefed example above automatically fetches the builds, flashes both\ndevices and installs `SL4A.apk` on both devices. You can run it like so: \n\n source build/envsetup.sh\n lunch\n make sl4a\n tradefed.sh run google/example/BT-discovery-sl4a\n\nOr once built: \n\n ./tradefed.sh run google/example/BT-discovery-sl4a\n\n### Write a test in Tradefed using SL4A\n\nYou can follow the test sample describe above:\n[Sl4aBluetoothDiscovery.java](https://android.googlesource.com/platform/tools/tradefederation/contrib/+/refs/heads/android16-release/src/com/android/tradefed/Sl4aBluetoothDiscovery.java).\nThis gives a good example of the flow to use SL4A within a Tradefed test.\n\n### SL4A API documentation\n\nThe complete list of callbacks available through SL4A can be generated. From the\nSL4A source directory, `platform/external/sl4a/`, run this command: \n\n python Docs/generate_api_reference_md.py\n\nIn the Docs directory there will be an `ApiReference.md` file that contains\nthe RPC functions available in SL4A, as well as documentation for the RPC\nfunctions."]]