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

Consider making check for ANDROID_HOME a warning instead of an error #90

Closed
aginiewicz opened this issue Aug 6, 2014 · 9 comments
Closed

Comments

@aginiewicz
Copy link

Would it be possible to make check for ANDROID_HOME a warning instead of an error - and fail only when someone actually uses some Android related commands like android:package-debug?

I ask because I work on cross-platform application - we use Libgdx and build for Desktop, Android and iOS using same source and very thin layer (like few classes) of platform dependent code. Unfortunately, putting android-sdk-plugin in forces everyone to have Android SDK installed - even if they only want to build iOS or Desktop version. This was a big complain from people who make our iOS and Mac builds.

We mostly use libgdx-sbt-project.g8 template and the issue is tracked there as well: ajhager/libgdx-sbt-project.g8#65 (it dated back to when libgdx-sbt-project.g8 used another Android plugin - and this idea is duplicated there as jberkel/android-plugin#199).

Anyway, thanks for great plugin! It really helps us in getting things done!

@pfn
Copy link
Member

pfn commented Aug 7, 2014

This really isn't an easy problem to solve. If a project in particular makes use of the android build, it will pull in the android plugin settings (and trigger the error on sdkPath lookup failure).

The best approach that I can think of is to make sure absolutely common code (i.e. pure-java, no android libraries, or at worst, with a maven android sdk reference) is in a plain-java project.

If you do not apply Plugin.androidBuild, sdk-path will not raise an error.

@pfn
Copy link
Member

pfn commented Aug 7, 2014

Looking at the libgdx template in particular, if you work with the desktop and core projects only, it should not trigger an error. If you're using the aggregated tasks on all-project it should rightfully fail.

@aginiewicz
Copy link
Author

I agree things like compile should fail on all-platforms.

if it worked with "only desktop", it would be cool - but I wasn't able to run it. I've tried both sbt desktop/run and sbt "project desktop" run and it fails if there is no ANDROID_HOME. Seems like it is checked before SBT sets current project. Below is sbt "project desktop" run with ANDROID_HOME:

[info] Loading global plugins from /home/giniu/.sbt/0.13/plugins
[info] Loading project definition from /home/giniu/dev/my-game/project
[info] Set current project to all-platforms (in build file:/home/giniu/dev/my-game/)
[info] Set current project to desktop (in build file:/home/giniu/dev/my-game/)
[info] Running my.game.pkg.Main 

(project changed in 4'th line) and without

[info] Loading global plugins from /home/giniu/.sbt/0.13/plugins
[info] Loading project definition from /home/giniu/dev/my-game/project
java.lang.RuntimeException: set ANDROID_HOME or run 'android update project -p /home/giniu/dev/my-game/android'

that's why I asked if the check could be delayed - or at least made into warning using some options - so people will be aware that commands that actually do something with android will fail.

@pfn
Copy link
Member

pfn commented Aug 7, 2014

I'm confused. Your log messages don't really indicate what you're doing or what's happening. Can you include more detailed logs? Use 'last' if necessary.

@aginiewicz
Copy link
Author

Sure, there are more details.

Complete log from zero to working project: http://pastebin.com/PE6ypCPF
Same command - desktop/run - with ANDROID_HOME unset: http://pastebin.com/kNVRqzHu

same when using sbt "project desktop" run - desktop depends only on core, not on android subproject - yest still fails.

@pfn
Copy link
Member

pfn commented Aug 7, 2014

I see, sbt is eagerly loading the project and settings even when it's not directly referenced.

For now, you can just workaround by specifying a bullshit ANDROID_HOME, e.g. ANDROID_HOME=/

@pfn
Copy link
Member

pfn commented Aug 7, 2014

Or rather, that should probably work ;-)

@pfn
Copy link
Member

pfn commented Apr 15, 2016

this has probably been made worse by recent changes, all of the android SDK stuff is now loaded eagerly

@pfn pfn closed this as completed in 7b32e55 Apr 28, 2016
@pfn
Copy link
Member

pfn commented Apr 28, 2016

a fallback value will be used if ANDROID_HOME is not set. If android packages are not present when the build is run, they will be auto-installed.

As long as android tasks are not executed, nothing will get installed to the fallback directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants