Prerequisites
Before you begin, ensure you have the following installed on your system:Install pnpm
BBPlayer uses pnpm as its package manager. The required version is specified in
package.json.Set up Android development (Required)
BBPlayer is primarily developed for Android. Follow the React Native environment setup guide for Android development.Required:
- Android Studio
- Android SDK (API 34 or higher recommended)
- Java Development Kit (JDK 17)
- Android emulator or physical device
Make sure to set up the
ANDROID_HOME environment variable pointing to your Android SDK location.Clone the Repository
Clone the BBPlayer repository from GitHub:Install Dependencies
BBPlayer is a monorepo managed with pnpm workspaces. Install all dependencies from the root:- Install dependencies for all workspace packages
- Set up git hooks using Lefthook (via the
postinstallscript) - Apply any necessary patches via
patch-packagein the mobile app
Lefthook is automatically installed via the
postinstall script. It manages git hooks for code quality checks including commitlint for commit message validation.Development Tools
Code Quality Tools
BBPlayer uses several tools to maintain code quality:Linting
- oxlint - Fast linter with type-aware checking
- ESLint - JavaScript/TypeScript linting with custom BBPlayer rules
Formatting
Dependency Management
Start Development Server
Navigate to the mobile app directory and start the Expo development server:WITH_ROZENITE=true- Enables Rozenite metro plugins for enhanced developmentAPP_VARIANT=development- Sets the app variant to development mode
Run on Android
To build and run the app on an Android device or emulator:- Build the Android app
- Install it on your connected device/emulator
- Start the Metro bundler
Environment Variables
BBPlayer uses environment variables for configuration. The mobile app usesAPP_VARIANT to control build variants:
development- Development builds with debugging enabledpreview- Preview builds for internal testingproduction- Production builds for release
Firebase and Sentry configurations require API keys. For development, these services can be disabled or you’ll need to set up your own instances.
Protobuf Generation
The mobile app uses Protocol Buffers for Bilibili API communication. If you modify.proto files, regenerate the code:
pbjs- Generates static JavaScript modules from.protofilespbts- Generates TypeScript definitions
Testing
Run tests in the mobile app:jest-expo preset for React Native testing.
Next Steps
Project Structure
Learn about the monorepo structure and how code is organized
Building for Production
Build APKs for Android and iOS (if supported)