I try to build and run the sample helloworld/mobile
in project (https://github.com/android/car-samples)
My question is about how to select the sample app directory as described in README.md:
helloworld/mobile
) in the Project Structure
UI on the top left. Each sample app has two build targets, one for the mobile
platform and the other for the automotive
platform.
<<<<I went through Project Structure
UI, I tried different possibilities but no way,
Build menu always shows Make Module car-simples-main
and when I launch Make Module, nothing happens.
Wondering if something has changed in the last Android Studio version, I use Android Studio Chipmunk | 2021.2.1 Patch 1
Anyone can help?
Thanks.
First of all, let's understand how the git directory is structured.
The directory has the two folders car-lib/CarGearViewerKotlin
and car_app_library
, which are gradle projects that can be built using gradle.
How do you know?
Any folder contains gradle wrapper
and a build.gradle
and settings.gradle
files means that they're ready to be built using gradle, and these can contain modules inside of them.
Now helloworld/mobile
is a module, or you can view it as a sub-project.
How do you know?
If you open up the parent's settings.gradle
file, you will see the line include ':helloworld:mobile'
meaning that the directory helloworld/mobile
is a sub-project or module for the top level car_app_library
project.
Modules by themselves are not runnable, they need to be contained in a parent project with top-level gradle files.
Now the solution for your problem should be: open up these two as projects in Android studio individually: car-lib/CarGearViewerKotlin
and car_app_library
, it will create a default run configuration for each project.
You won't be able to run helloworld/mobile
alone, you'll need to run the parent project car-samples/car_app_library
.
However, You should technically be able to open the root directory (the git directory containing all of the projects) and creating a run configurations by hand for each project, and you should be able to run the projects using one Android Studio window opened.