Closed Bug 1123013 Opened 9 years ago Closed 9 years ago

IntelliJ needs Project SDK set due to dynamic code in android.gradle

Categories

(Firefox Build System :: Android Studio and Gradle Integration, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: nalexander, Assigned: nalexander)

References

Details

Attachments

(1 file, 1 obsolete file)

Sigh.  IntelliJ fishes the Project SDK versions, including the Java language, Android platform, and build tool versions, manually from build.gradle.  That's right, it parses it in some separate ad-hoc manner, rather than interrogating the Gradle model.  I hope the reason justifies the clown shoes.

What this means is that the dynamic settings we apply from mobile/android/gradle/android.gradle are not seen by the IDE (they are seen by the Gradle build just fine).  That in turn means that the user needs to set the Project SDK, and that appears to race against reading the Gradle configuration on some platforms, namely Linux (as reported by mcomella).

The fix is to hard-code the relevant settings (duplicated, sigh) into every build.gradle file.  That's tricky, because we haven't yet pinned the versions (see Bug 1108782), so we may trample local developer choices.  Overall, I think it's worth it.
Attachment #8551417 - Flags: review?(michael.l.comella)
/r/2673 - Bug 1123013 - WIP on hard coding Android versions.

Pull down this commit:

hg pull review -r a51d6904bab9ba063b5c871bd137b112d9787d2b
Comment on attachment 8551417 [details]
MozReview Request: bz://1123013/nalexander

Looks like Review Board doesn't let you ask for feedback.  This is a hack but will help us understand if the simple thing is sufficient for your case, mcomella.  Apply the patch and then re-import into IntelliJ.  You should see the "root project" have no SDK, but all the "child projects" should have the Android 21 SDK.  If you look at the patch, I'm hard-coding the build-tools to be "21.1.1" as well.  You'll need that (and android-21); install with the |android| tool if necessary.  Thanks!
Attachment #8551417 - Flags: review?(michael.l.comella) → feedback?(michael.l.comella)
Comment on attachment 8551417 [details]
MozReview Request: bz://1123013/nalexander

It appears to be working for me - the only red squiggles I see are for API version mis-matches (e.g. API level for call is 10, minimum set is 9). The class files in the project view do not indicate failures so it looks like they've otherwise compiled successfully.

The .gradle directory is red in the project view, but it doesn't seem to be negatively affecting anything.

(In reply to Nick Alexander :nalexander from comment #3)
> You should see the "root project" have no SDK, but all the
> "child projects" should have the Android 21 SDK.

Not sure what you mean by this.

Thanks Nick!
Attachment #8551417 - Flags: feedback?(michael.l.comella) → feedback+
(In reply to Michael Comella (:mcomella) from comment #4)
> Comment on attachment 8551417 [details]
> MozReview Request: bz://1123013/nalexander
> 
> It appears to be working for me - the only red squiggles I see are for API
> version mis-matches (e.g. API level for call is 10, minimum set is 9). The
> class files in the project view do not indicate failures so it looks like
> they've otherwise compiled successfully.
> 
> The .gradle directory is red in the project view, but it doesn't seem to be
> negatively affecting anything.

I think that's "light pinky red" for not included in the project (automatically), not "dark red/squiggly" for causing problems.  That's appropriate; .gradle is just a cache directory.

> 
> (In reply to Nick Alexander :nalexander from comment #3)
> > You should see the "root project" have no SDK, but all the
> > "child projects" should have the Android 21 SDK.
> 
> Not sure what you mean by this.

If you look in "Project Structure", the project as a whole and the "gradle" project may have no SDK, but all the other projects ("base", "stumbler", etc) will have SDKs.  It's not a big deal.

Thanks for testing!
https://hg.mozilla.org/mozilla-central/rev/21ab618e06ad
Assignee: nobody → nalexander
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Attachment #8551417 - Attachment is obsolete: true
Component: Build Config → Build Config & IDE Support
Product: Core → Firefox for Android
Target Milestone: mozilla38 → ---
Product: Firefox for Android → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: