Welcome to the complete documentation for AASDK (Android Auto Software Development Kit), a C++ library implementing core AndroidAuto™ functionalities for building headunit software.
- Quick Start
- Project Overview
- Development Environment Setup
- Building the Project
- Testing
- Packaging and Distribution
- Troubleshooting
- Contributing
- Architecture and Design
- API Reference
Using DevContainers (Recommended):
# 1. Open VS Code in project directory
# 2. Ctrl+Shift+P → "Dev Containers: Reopen in Container"
# 3. Build the project
./build.sh debugTraditional Setup:
# Install dependencies (Ubuntu/Debian)
sudo apt update
sudo apt install build-essential cmake libboost-all-dev libusb-1.0-0-dev libssl-dev libprotobuf-dev protobuf-compiler
# Build
mkdir build && cd build
cmake ..
make -j$(nproc)AASDK is a comprehensive C++ library that implements the AndroidAuto™ protocol stack, enabling developers to create headunit software that can communicate with Android devices running Android Auto.
Core Protocols:
- ✅ AOAP (Android Open Accessory Protocol)
- ✅ USB transport with hotplug support
- ✅ TCP transport for wireless connectivity
- ✅ SSL encryption for secure communication
- ✅ AndroidAuto™ protocol implementation
Communication Channels:
- 🎵 Media Audio Channel - Music and audio streaming
- 🔊 System Audio Channel - Navigation and system sounds
- 🎤 Speech Audio Channel - Voice commands and TTS
- 📞 Audio Input Channel - Microphone input
- 📺 Video Channel - Display mirroring and apps
- 📱 Bluetooth Channel - Bluetooth device management
- 📊 Sensor Channel - Vehicle sensor data
- ⚙️ Control Channel - System control and configuration
- 🖱️ Input Channel - Touch and button inputs
┌─────────────────────────────────────────────────────────────────┐
│ AASDK Library │
├─────────────────────────────────────────────────────────────────┤
│ Transport Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ USB │ │ TCP │ │ Bluetooth │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ Protocol Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ AOAP │ │ AndroidAuto │ │ SSL │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ Channel Management │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Audio │ │ Video │ │ Control │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Prerequisites:
Supported Architectures:
| Architecture | Use Case | Container |
|---|---|---|
| x64 | Native development, fastest builds | Default container |
| ARM64 | Raspberry Pi 4, Apple Silicon | devcontainer-arm64.json |
| ARMHF | Raspberry Pi 3, older ARM devices | devcontainer-armhf.json |
Setup Steps:
- Open VS Code in project directory
- Press
Ctrl+Shift+P→ "Dev Containers: Reopen in Container" - Select target architecture if needed
- Wait for container setup (5-10 minutes first time)
Ubuntu/Debian Dependencies:
sudo apt update
sudo apt install -y \
build-essential \
cmake \
git \
pkg-config \
libboost-all-dev \
libusb-1.0-0-dev \
libssl-dev \
libprotobuf-dev \
protobuf-compiler \
googletest \
libgtest-devCentOS/RHEL/Fedora Dependencies:
sudo dnf install -y \
gcc gcc-c++ \
cmake \
git \
pkgconfig \
boost-devel \
libusb1-devel \
openssl-devel \
protobuf-devel \
protobuf-compiler \
gtest-develQuick Build:
# Debug build
./build.sh debug
# Release build
./build.sh release
# Clean and rebuild
./build.sh debug cleanAvailable tasks (Ctrl+Shift+P → "Tasks: Run Task"):
DevContainer: Build Debug (Quick)DevContainer: Build Release (Quick)DevContainer: Clean & BuildDevContainer: Create Packages
Debug Build:
mkdir -p build-debug
cd build-debug
cmake -DCMAKE_BUILD_TYPE=Debug -DTARGET_ARCH=${TARGET_ARCH:-amd64} ../
make -j$(nproc)Release Build:
mkdir -p build-release
cd build-release
cmake -DCMAKE_BUILD_TYPE=Release -DTARGET_ARCH=${TARGET_ARCH:-amd64} ../
make -j$(nproc)Cross-Compilation:
# For ARM64
cmake -DCMAKE_BUILD_TYPE=Release -DTARGET_ARCH=arm64 ../
# For ARMHF
cmake -DCMAKE_BUILD_TYPE=Release -DTARGET_ARCH=armhf ../| Option | Description | Default |
|---|---|---|
CMAKE_BUILD_TYPE |
Build configuration | Release |
TARGET_ARCH |
Target architecture | amd64 |
BUILD_TESTING |
Enable unit tests | ON |
ENABLE_COVERAGE |
Enable code coverage | OFF |
Run All Tests:
cd build-debug
ctest --output-on-failureRun Specific Test Suite:
cd build-debug
./test_aasdk_transport
./test_aasdk_channel
./test_aasdk_protocolLogger Test:
# Compile test program
g++ -std=c++17 test_logger.cpp -o test_logger \
-I./include \
-L./build-debug/lib \
-laasdk \
-lboost_system \
-lboost_log \
-lpthread
# Run logger test
./test_loggerMigration Test:
# Test modern logger migration
g++ -std=c++17 test_migration.cpp -o test_migration \
-I./include \
-L./build-debug/lib \
-laasdk
./test_migrationTest Package Dependencies:
cd test_package_build
./test_package_deps.shTest Package Installation:
# Test runtime package
sudo dpkg -i packages/libaasdk-*.deb
# Test development package
sudo dpkg -i packages/libaasdk-*-dev*.deb
# Verify installation
ldconfig -p | grep aasdk
pkg-config --modversion aasdkMemory Leak Detection:
valgrind --tool=memcheck --leak-check=full ./your_aasdk_appPerformance Profiling:
perf record -g ./your_aasdk_app
perf reportThe build system creates semantic versioned packages:
Release Packages:
libaasdk-{arch}_{version}_{arch}.deb- Runtime librarylibaasdk-{arch}-dev_{version}_{arch}.deb- Development headers
Debug Packages:
libaasdk-{arch}-dbg_{version}.debug_{arch}.deb- Debug runtimelibaasdk-{arch}-dbg-dev_{version}.debug_{arch}.deb- Debug development
Source Package:
libaasdk-{arch}-{version}-src.tar.gz- Source distribution
Date-based semantic versioning: YYYY.MM.DD+git.{commit}.{status}
Examples:
2025.07.30+git.abc1234(clean release)2025.07.30+git.abc1234.dirty(uncommitted changes)2025.07.30+git.abc1234.debug(debug build)
Using Tasks:
# VS Code: Ctrl+Shift+P → "Tasks: Run Task" → "DevContainer: Create Packages"Manual Creation:
# Release packages
cd build-release
cpack --config CPackConfig.cmake
mkdir -p ../packages
mv *.deb ../packages/
# Debug packages
cd build-debug
cpack --config CPackConfig.cmake
mkdir -p ../packages
mv *.deb ../packages/
# Source package
cd build-release
cpack --config CPackSourceConfig.cmake
mv *.tar.* ../packages/Problem: CMake cannot find required libraries
CMake Error: Could not find Boost
Solution:
# Ubuntu/Debian
sudo apt install libboost-all-dev
# CentOS/RHEL/Fedora
sudo dnf install boost-develProblem:
error: 'GOOGLE_PROTOBUF_VERSION' was not declared
Solution:
# Check protobuf version
protoc --version
# Install correct version (Ubuntu)
sudo apt install libprotobuf-dev protobuf-compiler
# Build protobuf from source if needed
cd protobuf
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc) && make installProblem:
fatal error: libusb.h: No such file or directory
Solution:
# Install libusb development headers
sudo apt install libusb-1.0-0-devProblem: ARM cross-compilation fails
No CMAKE_C_COMPILER could be found
Solution:
# Install cross-compilation toolchain
sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# Verify toolchain
arm-linux-gnueabihf-gcc --version
aarch64-linux-gnu-gcc --versionProblem: Cannot access USB devices
libusb: error [get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/002: Permission denied
Solution:
# Add user to plugdev group
sudo usermod -a -G plugdev $USER
# Create udev rule for Android devices
sudo tee /etc/udev/rules.d/51-android.rules << EOF
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev"
EOF
# Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm triggerProblem: SSL handshake failures
SSL_connect failed: certificate verify failed
Solution:
# Update CA certificates
sudo apt update && sudo apt install ca-certificates
# Check SSL configuration in your code
// Verify SSL context setup in Transport layerProblem: No audio output
ALSA lib pcm_dmix.c: unable to open slave
Solution:
# Check ALSA configuration
aplay -l
amixer scontents
# Install PulseAudio if needed
sudo apt install pulseaudio pulseaudio-utils
# Test audio
speaker-test -t wav -c 2#include <aasdk/Common/Log.hpp>
// Set log level to DEBUG
aasdk::common::Log::setLogLevel(aasdk::common::LogLevel::DEBUG);
// Use category-specific logging
AASDK_LOG_USB_DEBUG() << "USB debug message";
AASDK_LOG_TRANSPORT_ERROR() << "Transport error occurred";# Monitor TCP connections
netstat -an | grep :5277
# Capture network traffic
sudo tcpdump -i any port 5277 -w androidauto.pcap
# Analyze with Wireshark
wireshark androidauto.pcap# List USB devices
lsusb -v
# Monitor USB events
sudo udevadm monitor --udev
# Check USB permissions
ls -la /dev/bus/usb/Check:
- Audio processing threads
- Video decoding performance
- Logging verbosity
Solution:
// Reduce logging verbosity
aasdk::common::Log::setLogLevel(aasdk::common::LogLevel::INFO);
// Optimize audio buffer sizes
// Implement proper thread priorityDetection:
# Compile with AddressSanitizer
cmake -DCMAKE_CXX_FLAGS="-fsanitize=address" ..
# Use Valgrind
valgrind --tool=memcheck --leak-check=full ./your_appDebug Race Conditions:
# Compile with ThreadSanitizer
cmake -DCMAKE_CXX_FLAGS="-fsanitize=thread" ..
# Use GDB for debugging
gdb ./your_app
(gdb) set scheduler-locking step
(gdb) thread apply all bt-
Fork and Clone:
git clone https://github.com/opencardev/aasdk.git cd aasdk -
Create Feature Branch:
git checkout -b feature/your-feature-name
-
Set Up Development Environment:
# Use DevContainer or install dependencies natively ./build.sh debug -
Make Changes and Test:
# Build and test your changes ./build.sh debug cd build-debug && ctest
-
Submit Pull Request:
- Ensure all tests pass
- Follow coding standards
- Update documentation if needed
C++ Style:
- Follow Google C++ Style Guide
- Use RAII principles
- Prefer smart pointers over raw pointers
- Use const-correctness
Logging:
- Use modern logger categories for new code
- Include context information in log messages
- Use appropriate log levels (DEBUG/INFO/WARN/ERROR)
Testing:
- Write unit tests for new functionality
- Ensure high code coverage
- Test on multiple architectures
For migrating existing code to use the modern logger:
# Use the migration script
./migrate_to_modern_logger.sh /path/to/your/source/filesBefore:
AASDK_LOG(debug) << "Connection established";After:
AASDK_LOG_TRANSPORT_DEBUG() << "Connection established";aasdk/
├── Common/ # Core utilities and logging
├── Error/ # Error handling and exceptions
├── IO/ # I/O operations and buffers
├── Transport/ # USB and TCP transport layers
├── Channel/ # Communication channels
├── Messenger/ # Message serialization/deserialization
├── USB/ # USB-specific implementations
└── TCP/ # TCP-specific implementations
Factory Pattern: Used for creating transport and channel instances Observer Pattern: Used for event notifications Strategy Pattern: Used for different audio/video codec implementations RAII: Used throughout for resource management
- Main Thread: UI and control operations
- Transport Thread: USB/TCP communication
- Audio Thread: Real-time audio processing
- Video Thread: Video frame processing
- Worker Threads: Background processing tasks
namespace aasdk::transport {
class ITransport {
public:
virtual void start() = 0;
virtual void stop() = 0;
virtual void send(const common::DataBuffer& buffer) = 0;
};
class USBTransport : public ITransport {
// USB-specific implementation
};
class TCPTransport : public ITransport {
// TCP-specific implementation
};
}namespace aasdk::channel {
class IChannel {
public:
virtual void start() = 0;
virtual void stop() = 0;
virtual ChannelId getId() const = 0;
};
class AudioChannel : public IChannel {
// Audio channel implementation
};
class VideoChannel : public IChannel {
// Video channel implementation
};
}namespace aasdk::common {
enum class LogLevel {
TRACE, DEBUG, INFO, WARN, ERROR, FATAL
};
enum class LogCategory {
SYSTEM, TRANSPORT, USB, TCP, AUDIO, VIDEO,
CHANNEL, MESSENGER, PROTOCOL, GENERAL
};
class ModernLogger {
public:
static void initialize();
static void setLevel(LogLevel level);
static void setLevel(LogCategory category, LogLevel level);
};
}#include <aasdk/Transport/USBTransport.hpp>
#include <aasdk/Common/Log.hpp>
// Initialize logging
aasdk::common::ModernLogger::initialize();
// Create USB transport
auto transport = std::make_unique<aasdk::transport::USBTransport>();
// Set up event handlers
transport->setReceiveHandler([](const aasdk::common::DataBuffer& buffer) {
AASDK_LOG_TRANSPORT_INFO() << "Received " << buffer.size() << " bytes";
});
// Start transport
transport->start();#include <aasdk/Channel/AudioChannel.hpp>
auto audioChannel = std::make_unique<aasdk::channel::AudioChannel>(transport);
audioChannel->setAudioHandler([](const aasdk::audio::AudioData& data) {
AASDK_LOG_AUDIO_MEDIA_DEBUG() << "Processing audio frame: " << data.size();
// Process audio data
});
audioChannel->start();- AndroidAuto Protocol: Official Documentation
- Protocol Buffers: Google Protobuf Guide
- Boost Libraries: Boost Documentation
- CMake: CMake Tutorial
- OpenDsh: Android Auto headunit implementation using AASDK
- AAuto: Desktop Android Auto client
- Crankshaft: Raspberry Pi Android Auto solution
- GitHub Issues: Report bugs and request features
- Discussions: Community discussions
- Matrix Chat: Join our chat room
GNU GPLv3
Copyrights (c) 2018 f1x.studio (Michal Szwaj)
AndroidAuto is registered trademark of Google Inc.
- ✅ Modern logging system with 47+ specialized macros
- ✅ Multi-architecture DevContainer support (x64, ARM64, ARMHF)
- ✅ Semantic date-based versioning system
- ✅ Comprehensive package building and distribution
- ✅ Enhanced testing and debugging capabilities
- ✅ Improved cross-compilation support
- Legacy logging syntax remains fully supported
- New projects should use modern logger categories
- Package versioning has changed to date-based format
- DevContainer is now the recommended development method
This documentation is maintained by the AASDK community. For updates and corrections, please submit pull requests or open issues on GitHub.