After setting up your environment, you can follow the steps below to run the pass Culture mobile application on Android.
If you encounter errors during this setup, refer to the Troubleshooting section at the end of this document.
First download Android Studio :
brew install --cask android-studioThen open the folder android in Android Studio.
Finally, open the Android Virtual Devices Manager and select (or create) a Virtual Device with the android version you want to run.
-
Download
testing.keystoreandtesting.keystore.propertiesfiles from Keeper and place it inside the/android/keystoresdirectory.If you do not find
testing.keystore, contact an admin. -
Modify
testing.keystore.propertiesto match with this configuration (required inbuild.gradle) :keyAlias=passculture storeFile=testing.keystore storePassword= keyPassword= -
Do the same for staging and production.
In the .env.local file (create the file if not exists), add
SECRET_KEYTOOL_PASSWORD=THE_PASSWORD # replace THE_PASSWORD with the one from Keeper search for "Android keytool password"then in your terminal run :
sudo xcodebuild -license # read and accept Apple license to be abble to use git inside Android Studio
./scripts/install_certificate_java.sh # this script ask root password
direnv reloadIf it fails see troubleshooting
Download the google-services.json file from Keeper and place it inside the android/app directory. You can also download this file from the Firebase console.
To run the app, simply run:
yarn android:testingThis will also start the metro server. If not, run in another tab :
yarn start-
Open Android Studio
-
Open settings
-
In settings, search "Android SDK" and open it
-
Check "Show Package Details" (in bottom right)
-
Unfold some image versions (any version supported)
-
Check "Google APIs
*System Image"Where
*match you CPU architecture that you can know using the following command in the terminaluname -m
Example:
Google APIs ARM 64 v8a System ImageThis type of image is known to work unlike to "Google APIs ATD" or "Google Play" which are known to have issues
-
Click on "OK", this will download stuff
- Open Android Studio
- Open Device Manager
- Click on "Add a new device"
- Click on "Create Virtual Device"
- Choose any hardware
- Choose a "Google APIs" image that have been previously downloaded, you may have to go to the "Other Images" tab
If you have a pass Culture's computer, which has a proxy that adds a custom certificate.
-
Start your emulator at least once
-
Stop your emulator
-
Run in a terminal
yarn android:testing
No value has been specified for property 'manifestOutputDirectory'
In Android Studio: File > Settings > Experimental > Gradle -> uncheck "Only sync the active variant" checkbox.
If you encounter an issue with JDK, install using brew install --cask temurin@17 and add the path JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home in .zshrc
Version conflict
It happens when you try to install with a build number lower than the one already installed.
- Ensure that there is one
$ yarn run-android | grep 'INSTALL_FAILED_VERSION_DOWNGRADE'- If no line containing
'INSTALL_FAILED_VERSION_DOWNGRADE'is caught, this is not the problem - If a line with
'INSTALL_FAILED_VERSION_DOWNGRADE'is caught → Uninstall the app on your emulator before building:
General error for building the app on Android Studio
These are the general solutions for errors :
run cd android && ./gradlew clean to clear the build directory.
on the root of the repository : rm -rf node_modules then yarn or yarn install, this will delete all the installed modules from the repo then reinstalled it.
Try to invalidate the cache: in Android Studio > open project's android folder > file tab > Invalidate caches/restart > Invalidate and restart
If you're on M1 or M2 Mac and the problem still remains, see the error below.
[M1 & M2 processor] Error while building the app on android with Android Studio : `Android Studio-- Cause: error=86, Bad CPU type in executable` or `Task :app:processApptestingDebugResources FAILED`
If you get this error on M1 or M2 Mac, installing Rosetta 2 should solve the issue. You can install it with this command : softwareupdate --install-rosetta.
Rosetta will allow applications requiring Intel processor to run on M1 & M2 Mac.