clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

multidex library missing if :sdk-path is a relative path #133

Closed nablaa closed 8 years ago

nablaa commented 8 years ago

If you set :sdk-path in the project project.clj to be a relative path (e.g. :sdk-path "../mysdk"), lein droid fails to find multidex library when executing 'lein droid doall`:

Could not find artifact com.android.support:multidex:aar:1.0.0 in central (https://repo1.maven.org/maven2/)
Could not find artifact com.android.support:multidex:aar:1.0.0 in clojars (https://clojars.org/repo/)
Could not find artifact com.android.support:multidex:aar:1.0.0 in android-support (file://../mysdk/extras/android/m2repository)
Could not find artifact com.android.support:multidex:aar:1.0.0 in android-play-services (file://../mysdk/extras/google/m2repository)
Could not find artifact com.android.support:multidex:aar:1.0.0 in maven-snapshots (https://oss.sonatype.org/content/repositories/snapshots)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.

On the other hand, if the :sdk-path is set to an absolute path to the same directory (e.g. :sdk-path "/home/user/mysdk"), the project will build successfully. Curiously enough, it seems that lein droid finds the SDK even in the relative path case, but it doesn't find all the multidex library. Because if you set the :sdk-path to an invalid value, you will get a different error:

Build tools not found. Download them using the Android SDK Manager.

Therefore it looks like there is something wrong in the path parsing when it comes to relative :sdk-path paths.

Note: in order to reproduce this problem, you need to remove the m2 cache directory (rm -rf ~/.m2) before executing lein droid commands. Otherwise the problem may not appear as there might be cached multidex libraries in ~/.m2/repository/com/android/support/multidex.

alexander-yakushev commented 8 years ago

Good catch! I know what's going on, the local repository resolution now happens in the middleware, before plugin kicks in, and I forgot to absolutize the sdk-path there. I will fix this very soon, thanks for reporting!

alexander-yakushev commented 8 years ago

Fixed in 0.4.2. Thank you!

nablaa commented 8 years ago

Thank you for the quick response!

Unfortunately, there seems to be some regression with 0.4.2 -- I get the following error when compiling projects with 0.4.2:

java.lang.NullPointerException: null
 at leiningen.droid.utils$absolutize.invoke (utils.clj:93)
    leiningen.droid.utils$android_parameters.invoke (utils.clj:146)
    lein_droid.plugin$middleware.invoke (plugin.clj:11)
    clojure.lang.Var.invoke (Var.java:379)
    leiningen.core.project$apply_middleware.invoke (project.clj:745)
    clojure.lang.ArrayChunk.reduce (ArrayChunk.java:58)
    clojure.core.protocols/fn (protocols.clj:136)
    clojure.core.protocols$fn__6478$G__6473__6487.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invoke (protocols.clj:31)
    clojure.core.protocols/fn (protocols.clj:101)
    clojure.core.protocols$fn__6452$G__6447__6465.invoke (protocols.clj:13)
    clojure.core$reduce.invoke (core.clj:6519)
    leiningen.core.project$apply_middleware.invoke (project.clj:740)
    leiningen.core.project$activate_middleware.invoke (project.clj:772)
    leiningen.core.project$init_project.invoke (project.clj:885)
    leiningen.core.project$read.invoke (project.clj:953)
    leiningen.core.project$read.invoke (project.clj:954)
    leiningen.core.main$_main$fn__6480.invoke (main.clj:386)
    leiningen.core.main$_main.doInvoke (main.clj:383)
    clojure.lang.RestFn.invoke (RestFn.java:457)
    clojure.lang.Var.invoke (Var.java:394)
    clojure.lang.AFn.applyToHelper (AFn.java:165)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.core$apply.invoke (core.clj:630)
    clojure.main$main_opt.invoke (main.clj:316)
    clojure.main$main.doInvoke (main.clj:421)
    clojure.lang.RestFn.invoke (RestFn.java:512)
    clojure.lang.Var.invoke (Var.java:409)
    clojure.lang.AFn.applyToHelper (AFn.java:178)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)

The above log is from a build where I just updated the lein-droid version: https://github.com/nablaa/android-briefmuter/commit/1477bd144e71aa877a1f79581ada2b8e9ae03f12 Full build log can be found here: https://travis-ci.org/nablaa/android-briefmuter/builds/77700528