oppia / oppia-android

A free, online & offline learning platform to make quality education accessible for all.
https://www.oppia.org
Apache License 2.0
320 stars 521 forks source link

Add documentation for Android Studio with Bazel on all OS's [Blocks: #2745] #2746

Open BenHenning opened 3 years ago

BenHenning commented 3 years ago

We should expand our Bazel documentation to include:


Also, per #3371 Bazel development support is very limited on Windows. Per #3437 we should investigate the viability of setting up a VM and running both Android Studio and Bazel from the same Unix-based environment (to avoid a bifurcation where the repo lives in Windows and the user does development via Windows Android Studio, but uses Bazel within an Ubuntu subsystem). This involves documenting the steps below for Windows:

FareesHussain commented 3 years ago
  • Installing the Bazel plugin in Android Studio

Regarding this, I've followed these steps.

But on selecting the bazel on the option disappears. I guess we need to import the project as a bazel project for that.

  • Importing the project as a Bazel project

For this after installing the BAZEL plugin

But there are a bunch of error in the bazel console (bazel sync fails and I guess we can't proceed after this) I think it is using the default installed bazel and we need oppia-bazel here

@BenHenning @fsharpasharp Do we have to wait for a new release for this or make changes in the plugin or Am I using a wrong approach here.

Making oppia-bazel default as bazel does work but is this a correct solution

FareesHussain commented 3 years ago

But there are a bunch of error in the bazel console (bazel sync fails and I guess we can't proceed after this) I think it is using the default installed bazel and we need oppia-bazel here

To fix this I've replaced the installed bazel with oppia-bazel and then when I try to sync the project I get this error tried with both check and uncheck Expand Sync to Working Set

Created a gist of the targets which gives the error (errors encountered while analyzing target)

ERROR: command succeeded, but not all targets were analyzed
INFO: Elapsed time: 1.092s, Critical Path: 0.01s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
INFO: Build Event Protocol files produced successfully.
FAILED: Build did NOT complete successfully
build invocation result: build_error
Sync was successful, but there were Bazel build errors. The project may not be fully updated or resolve until fixed. If the errors are from your working set, please uncheck 'Bazel > Sync > Expand Sync to Working Set' and try again.
BenHenning commented 3 years ago

There's a new issue affecting Android Studio: https://github.com/bazelbuild/rules_proto/issues/78 (see linked protoc issue for details). I might try sending a patch to rules_proto to see if it's an easy fix just to bump the version to 3.14.

BenHenning commented 3 years ago

Confirming this is an issue with version 2021.01.06.0.1 of the Bazel plugin. Updating rules_proto to a later version doesn't seem to fix the issue. I think the issue is actually within the Bazel plugin--it's not being built with compatibility for JDK 8. In the meantime I'm going to see if downgrading to an earlier version of the plugin fixes the issue.

BenHenning commented 3 years ago

https://github.com/bazelbuild/intellij/issues/2265 is tracking the plugin-specific issue.

BenHenning commented 3 years ago

Confirming that the custom plugin suggested in that thread does work for us: https://github.com/hedronvision/bazelbuild-intellij/releases/tag/v2021.02.03.

@fsharpasharp FYI since this is definitely going to cause some friction when trying to get Bazel working in Android Studio.

FareesHussain commented 3 years ago

I've tried using the latest version of bazel plugin (2021.04.27.0.0) for the to build using bazel.

I've created a gist for the errors I've encountered.

BenHenning commented 3 years ago

Ah, that might be a different error @FareesHussain. Could you add your .bazelproject file to a Gist & link that here? Also, which Android SDK do you have installed on your system?

FareesHussain commented 3 years ago

Here is the gist

the plugin showed SDK 29 and 30 as available and I selected 30

FareesHussain commented 3 years ago

Confirming that the custom plugin suggested in that thread does work for us: https://github.com/hedronvision/bazelbuild-intellij/releases/tag/v2021.02.03.

@fsharpasharp FYI since this is definitely going to cause some friction when trying to get Bazel working in Android Studio.

image

I was trying to install from disk by downloading the build but it gives the above error