Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
BenHenning opened this issue Feb 19, 2021 · 10 comments
Open
Assignees
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Z-ibt Temporary label for Ben to keep track of issues he's triaged.

Comments

@BenHenning
Copy link
Member

BenHenning commented Feb 19, 2021

We should expand our Bazel documentation to include:

  • Installing the Bazel plugin in Android Studio
  • Importing the project as a Bazel project
  • Syncing (& partial syncing)
  • Building the app
  • Building & running tests through AS

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:

  • Using git to clone & modify Oppia Android
  • Running Android Studio
  • Building & running tests via Bazel (CLI)
  • Deploying the app binary & tests to a real device
  • Starting an emulator
  • Deploying the app binary & tests to an emulator
@BenHenning BenHenning changed the title Add documentation for Android Studio with Bazel Add documentation for Android Studio with Bazel [Blocks: #2745] Feb 19, 2021
@FareesHussain
Copy link
Contributor

FareesHussain commented Feb 27, 2021

  • Installing the Bazel plugin in Android Studio

Regarding this, I've followed these steps.

  • Downloaded plugin from jetbrains Version: 2021.01.06.0.1 (Latest versions gives errors)
  • Open Files -> settings -> plugin -> select the preferences icon on the top right -> install from disk -> select the downloaded plugin -> Restart IDE

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

  • Import bazel project (File -> Import Bazel Project ..)
  • Select oppia-android (~/opensource/oppia-android if followed the steps from the wiki)
  • Generate from BUILD file (~/opensource/oppia-android/BUILD.bazel)
  • Uncomment Kotlin and the one SDK platform
  • And a new project was opened (~/opensource/oppia-android/.aswb)

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
Copy link
Contributor

FareesHussain commented Feb 27, 2021

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
Copy link
Member Author

There's a new issue affecting Android Studio: bazelbuild/rules_proto#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
Copy link
Member Author

BenHenning commented Mar 15, 2021

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
Copy link
Member Author

bazelbuild/intellij#2265 is tracking the plugin-specific issue.

@BenHenning
Copy link
Member Author

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
Copy link
Contributor

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
Copy link
Member Author

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
Copy link
Contributor

Here is the gist

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

@FareesHussain
Copy link
Contributor

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

@Broppia Broppia added issue_type_infrastructure Impact: Low Low perceived user impact (e.g. edge cases). labels Jul 29, 2022
@BenHenning BenHenning added Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Z-ibt Temporary label for Ben to keep track of issues he's triaged. and removed Impact: Low Low perceived user impact (e.g. edge cases). labels Sep 16, 2022
@seanlip seanlip added bug End user-perceivable behaviors which are not desirable. and removed issue_type_infrastructure labels Mar 28, 2023
@seanlip seanlip changed the title Add documentation for Android Studio with Bazel [Blocks: #2745] Add documentation for Android Studio with Bazel on all OS's [Blocks: #2745] Jun 16, 2023
adhiamboperes pushed a commit that referenced this issue Jun 30, 2023
…ions for different Operating System (#4926)

<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation

Fix Part of #2746 : Added Bazel Installations instructions for different
Operating System

<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->

## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Z-ibt Temporary label for Ben to keep track of issues he's triaged.
Projects
Development

No branches or pull requests

6 participants