Arcs can be developed in the IDE of your choice. Here are some helpful hints to get started.
-
Install Android Studio. When prompted, install the needed SDK Android 10 (SDK version 29).
-
Open Android Studio and install the Bazel extension (
Configure > Plugins
). This should prompt you to restart the IDE, if not restart anyway. -
Upon restarting Android, click "Import Bazel Project"
-
Select the workspace by navigating to the arcs folder, then click "Next".
-
Choose "Import project view file" and click on the three dots.
-
Navigate to the arcs folder, and select the
as.bazelproject
file. Click "OK". -
Click "Next".
-
Click "Finish".
-
Install or Update the Kotlin Plugin, at minimum version 1.3+.
- If installed, update the plugin to the latest version via
Tools > Kotlin > Configure Kotlin Plugin Updates
.
Install IntelliJ. Community Edition is sufficient. For web technologies support, install Ultimate Edition.
- During the setup (within Featured Plugins stage), ensure that Android is enabled.
-
Open IntelliJ and install the Bazel extension (
Configure > Plugins
). This should prompt you to restart the IDE, if not restart anyway. -
Upon restarting IntelliJ, click "Import Bazel Project"
-
Select the workspace by navigating to the arcs folder, then click "Next".
-
Choose "Import project view file" and click on the three dots.
-
Navigate to the arcs folder, and select the
ij.bazelproject
file. Click "OK". -
Click "Next".
-
Click "Finish".
-
Install or Update the Kotlin Plugin, at minimum version 1.3+.
- If installed, update the plugin to the latest version via
Tools > Kotlin > Configure Kotlin Plugin Updates
.
If you have Android Studio already installed, you may skip the next few steps, as this will be automated.
-
Download the command line tools for your OS.
-
After extraction, store the
tools
directory in the platform-appropriate location
OS | Location |
---|---|
Linux | /home/<USER_NAME>/Android/Sdk |
Windows | C:\Users\<USER_NAME>\AppData\Local\Android\sdk |
MacOS | /Users/<USER_NAME>/Library/Android/sdk |
- Download an SDK using the
sdkmanager
binary inAndroid/sdk/tools
:
$ sdkmanager --update
$ sdkmanager --list
$ sdkmanager 'platforms;android-29'
(If you encounter "Warning: File ~/.android/repositories.cfg could not be loaded."
, create one with "touch ~/.android/repositories.cfg
".)
-
Within IntelliJ, go to
File > Project Structure
-
Go to
Platform Settings > SDKs
-
Click the
+
button, chooseAndroid SDK
-
Navigate to the sdk folder that contains the
tools
directory, using the above table.
TBD
-
Go to your IDE
Preferences > Bazel Settings
-
Find the Bazel binary location, and click the three dots next to it.
-
Navigate to the correct location, and select the Bazel binary.
- If you don't know where the Bazel binary is located, open a terminal and run
which bazel
.
-
Click "Apply" then "OK"
-
Re-import the project by hitting the Bazel logo in the upper right hand corner.
Android Studio: Follow the prompts and then restart your IDE. IntelliJ: Follow the above instructions.
You may have already imported the project into your preferred IDE. Please try reopening it.
Optional: Delete the hidden folder and repeat the appropriate steps above.
If web technology support is not needed, choose .bazelproject
instead of ij.bazelproject
. If web technologies are needed, consider upgrading to the ultimate edition of IntelliJ.
My OS (read: MacOS) doesn't let me point to the Android SDK / It only displays user created directories
Consider using the IDE file chooser instead of the native one.
- Try increasing the memory heap allocation.
- Open the
.bazelproject
file. Comment out the targets or directories that are not relevant to your current task, then re-sync.
Assumptions:
- Your Kotlin plugin is at version 1.3.61 or higher: Preferences > Plugins > Installed > Kotlin
- Your IDE is at an recent enough version
IDE | Version |
---|---|
Android Studio | 3.5+ |
IntelliJ | TBD |
- Bazel is version 1.2 (2.0+ may cause problems)
Verified Fixes:
- Local solution: Right click the directory with the BUILD file > Partially Sync /...
- Global solution: Non-incrementally sync the project:
Bazel > Sync > Non-incrementally sync project with BUILD file
- Note: This works because the project may require two builds or syncs in order to "warm up" the generated sources.
Hail-Mary Fixes:
- Try Invalidating Caches:
File > Invalidate Caches > Invalidate and Restart
- Try this workaround (1 should be sufficient).
- Workaround: Launch your IDE from the command line
OS | Command |
---|---|
Linux | /opt/android-studio-stable/bin/studio.sh |
Windows | TBD |
MacOS | /Applications/Android Studio.app/Contents/MacOS/studio |
-
Create a
~/.xsessionrc
file with the following contents:if [ -f ~/.profile ]; then . ~/.profile fi
Please subsitute
.profile
(or repeat) with either.bash_profile
or.bashrc
-- wherever you have vital environment variables. After, log out and log back in to your system. -
Otherwise, try one of these workarounds.
.../arcs/WORKSPACE:33:1: //external:android/sdk depends on @androidsdk//:sdk in repository @androidsdk which failed to fetch. no such package '@androidsdk//': Either the path attribute of android_sdk_repository or the ANDROID_HOME environment variable must be set.
Follow these steps.
Error:(15, 1) Couldn't build file path/to/file/ParticleName_GeneratedSchemas.jvm.kt: error executing shell command: '/bin/bash -c bazel-out/k8-fastbuild/bin/path/to/file/ParticleName_genrule_jvm.sh' failed (Exit 127)
Follow these steps.
Follow these steps.
Examples:
Can not set static final org.robolectric.internal.IShadow field org.robolectric.shadow.api.Shadow.SHADOW_IMPL to org.robolectric.internal.bytecode.ShadowImpl
java.lang.NoClassDefFoundError: Could not initialize class org.robolectric.util.reflector.UnsafeAccess
The likely culprit is an incompatibility between the version of Robolectric and the version of Java on your machine.
We recommend that you use Java 8 or 11. Other Java versions have been associated with errors at the time of writing (2020-07).
To check the Java versions installed on your machine, run:
- MacOS:
/usr/libexec/java_home -V
. - Linux:
sudo update-alternatives --config java
- Windows: Consult this documentation.
java -version
will show which one is in use.
To choose a new version of Java, update your JAVA_HOME
variable:
- MacOS / Linux: add
export JAVA_HOME=<path/to/JDK11/or/JDK1.8>
to the appropriate~/.profile
file (i.e.~/.bash_profile
or~/.bashrc
). Thereafter, restart your IDE. - Windows: See this documentation.