clojure-android / lein-droid

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

lein droid build fails on "Hello world" sample project #144

Open thefourhorsemen opened 8 years ago

thefourhorsemen commented 8 years ago

Hi,

I've created a new clojure android project using the following command: lein new droid my-droid my.droid

I've modified my-droid/project.clj, just to indicate the android-sdk path and when I tried to build the project using: lein droid build the following error occurs: error: package neko does not exist

I sure I doing something wrong but I didn't find any way to fix it.

I am using the following leiningen version: Leiningen 2.5.1 on Java 1.7.0_51 Java HotSpot(TM) 64-Bit Server VM

Please find hereafter the generated project.clj file:project.clj.txt

kenrestivo commented 8 years ago

In the past this was due to _a or (debug/_a) being included in the example.

Try removing all references to debug/*a and replacing it with "this" instead.

thefourhorsemen commented 8 years ago

Hi Ken,

Thanks for you answer, but it didn't solve the compilation error.

In fact the compilation error arise when trying to java compile the SplashActivity.java generated by the lein-droid plugin.

Hereafter the SplashActivity.java file:

package my.droid;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import neko.App;

import my.droid.R;

public class SplashActivity extends Activity {

    private static boolean firstLaunch = true;

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);

        if (firstLaunch) {
            firstLaunch = false;
            setupSplash();
            App.loadAsynchronously("my.droid.MainActivity",
                                   new Runnable() {
                                       @Override
                                       public void run() {
                                           proceed();
                                       }});
        } else {
            proceed();
        }
    }

    public void setupSplash() {
        setContentView(R.layout.splashscreen);

        TextView appNameView = (TextView)findViewById(R.id.splash_app_name);
        appNameView.setText(R.string.app_name);

        Animation rotation = AnimationUtils.loadAnimation(this, R.anim.splash_rotation);
        ImageView circleView = (ImageView)findViewById(R.id.splash_circles);
        circleView.startAnimation(rotation);
    }

    public void proceed() {
        startActivity(new Intent("my.droid.MAIN"));
        finish();
    }

}

The compilation error occurs at line 10 when trying to import neko.App class. However neko is included in project dependency. Hereafter the project .clj file:

(defproject my-droid/my-droid "0.1.0-SNAPSHOT"
  :description "FIXME: Android project description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :global-vars {*warn-on-reflection* true}

  :source-paths ["src/clojure" "src"]
  :java-source-paths ["src/java"]
  :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
  :plugins [[lein-droid "0.4.3"]]

  :dependencies [[org.clojure-android/clojure "1.7.0-r2"]
                 [neko/neko "4.0.0-alpha5"]]
  :profiles {:default [:dev]

             :dev
             [:android-common :android-user
              {:dependencies [[org.clojure/tools.nrepl "0.2.10"]]
               :target-path "target/debug"
               :android {:aot :all-with-unused
                         :rename-manifest-package "my.droid.debug"
                         :manifest-options {:app-name "my-droid (debug)"}}}]
             :release
             [:android-common
              {:target-path "target/release"
               :android
               {;; :keystore-path "/home/user/.android/private.keystore"
                ;; :key-alias "mykeyalias"
                ;; :sigalg "MD5withRSA"

                :ignore-log-priority [:debug :verbose]
                :aot :all
                :build-type :release}}]}

  :android {;; Specify the path to the Android SDK directory.
            :sdk-path "D:/Users/Frederic/Tools/android-sdk"

            ;; Try increasing this value if dexer fails with
            ;; OutOfMemoryException. Set the value according to your
            ;; available RAM.
            :dex-opts ["-JXmx4096M" "--incremental"]

            :target-version "15"
            :aot-exclude-ns ["clojure.parallel" "clojure.core.reducers"
                             "cider.nrepl" "cider-nrepl.plugin"
                             "cider.nrepl.middleware.util.java.parser"
                             #"cljs-tooling\..+"]})
thefourhorsemen commented 8 years ago

Hi,

After some tests using lein droid on Windows, I probably found the reason of the compilation issue.

The neko.jar can not be resolved because my .m2 directory (i.e. the directory containing artefacts downloaded by leiningen) is located in a parent directory which name contains some characters with accent. When I try to do the same on an other account (which username doesn't contain accented characters), the compilation completes without any error.

alexander-yakushev commented 8 years ago

Doh. I'm not sure how to fix that because I use standard Java utilities for calling shell binaries. You can try to google for similar issues for plain java and tell us about the possible solutions.

thefourhorsemen commented 8 years ago

I'd fork lein-droid repo yesterday, and I'll try to find how to fix it in the next days. If it works I'll send you a pull request. Unfortunately I pretty new in Clojure (my background is mainly Java) and I don't know the way lein-droid plugin is structured.

alexander-yakushev commented 8 years ago

This should help a bit: https://github.com/clojure-android/lein-droid/wiki/Hacking-the-plugin