How to build Android apps using Cursive in Android Studio - android

I'd like to do Android development in Clojure, using the Cursive plugin in Android Studio. I've seen several posts where people have stated that it is possible, but I haven't been able to get it working.
When I try to build, I get errors reported where I'm trying to call Clojure from Java:
Error:(6, 18) error: package com.domain does not exist
Error:(15, 49) error: cannot find symbol variable tiny
Here's what I tried:
I already have Cursive running in IntelliJ with leiningen, building and running standalone Clojure apps
Start Android Studio, version 1.5.1
Create a new Android project. Selected API level 15, Empty Activity
Install Cursive plugin, as per this post:
Is it possible to get the Cursive Plugin installed with Android Studio?
Add clojure jar to classpath: Open module settings, dependencies, +Library Dependency, search for and select org.clojure:clojure:1.8.0-RC5
Switch from Android view to Project view, to create Clojure src directory: select app/src/main and create new directory clojure
The next step is to create a Clojure source file, which can be called from Java, using the example in this post: Calling clojure from java
Select src directory clojure, right-click New Clojure Namespace and enter: com.domain.tiny (to match the ns used in the example)
Paste the code from the example above into the new file (note that the ns in the new file was tiny and should have been com.domain.tiny)
It will say File tiny.clj is not under a source root so click on Add source root. Now we have both src/java and src/clojure set as src roots
Build the project. At this point it looks like everything is happy, no syntax errors in either the Java or Clojure code. We can deploy and run the (almost) empty Android project, and run a local REPL to load and test our Clojure code.
We want to call some Clojure code from Java, so add the following code to MainActivity (again, from the example above):
System.out.println("(binomial 5 3): " + tiny.binomial(5, 3));
System.out.println("(binomial 10042, 111): " + tiny.binomial(10042, 111));
Android Studio can find the package com.domain.tiny and the tiny class, no syntax errors, so looks good
Now try and build the project - at this point I get an error:
Error:(6, 18) error: package com.domain does not exist
Error:(15, 49) error: cannot find symbol variable tiny
At this point, I'm stuck. I'm guessing that even though the compiler is seeing the Clojure code ok, there's still something missing in the build process. Does leiningen need to be involved? If so, I don't know how, or what I might have to put in the project.clj configuration file.
Anyone have any ideas? Thanks!

Edit:
This appears to not be possible right now. This is because Android Studio requires projects to use Gradle, and the Clojure Gradle plugin is incompatible with the Android one. This may work in the future, but we couldn't make it work right now.
Original answer:
Thanks for the detailed issue. I guess that your Clojure code has to be AOT compiled for this to work. To enable this, check the settings under Settings->Build, Execution, Deployment->Compiler->Clojure Compiler. If you enable compilation for your Clojure namespaces, does that help?

Related

Include External Source Code Library for Android Studio 1.4.1

I'm attempting to create an Android app with Android Studio that uses source code from:
https://github.com/mapbox/mapbox-gl-native/
I will need to modify the source code, build and debug the changes, and commit those changes back to the forked repository I've made from mapbox-gl-native.
It appears much of the library code is in C++, while the project that uses the code will be in Java (if that makes a difference).
I've tried a bunch of things (mostly ignorant) and keep getting the following message:
Gradle 'name' project refresh failed
Error: Configuration with name 'default' not found.
Newbie on Android Studio, so please be as descriptive as possible. I'm using Android Studio 1.4.1, as other similar questions seem to have version specific answers.
Is there a description on how to set up an Android Studio project to include source code and how to structure such a project?
or
Can you tell me what the message means and how to fix it?
Thanks.

How to add Crosswalk project to Android studio?

I am trying out android crosswalk project. I am having problems adding crosswalk webview to andriod studio though. I am not sure where I am going wrong nor do I understand most terminology yet.
I read https://crosswalk-project.org/documentation/embedding_crosswalk.html but I refers to https://developer.android.com/tools/sdk/eclipse-adt.html which is no longer supported. This seems to be outdated but I tried anyway with Android Studio 1.2.2.
I tried making a project with https://crosswalk-project.org/documentation/downloads.html Android webview (ARM) 13.42.319.11 as told in the documention. I am not sure what is meant with 'open ADT' but I assumed Android Studio instead of the plugin of eclipse. I opened from an 'existing android studio project' (the download unzipped). But didn't come across the option 'set root directory'.
I then tried to create a new android studio project and ran it. It showed the basic hello wold example on my phone. Then I followed the remaining steps by pasting in the code they provided. I ran it again and got 3 errors:
Error:(3, 22) error: package org.xwalk.core does not exist
Error:(9, 13) error: cannot find symbol class XWalkView
Error:(15, 23) error: cannot find symbol class XWalkView
I am not sure what to do from here as this is all very new to me.
Basically I am trying to run there example but can't figure out why the import isn't working.
I am having the same problem but I finally fixed it by placing the xwalk_core_library.jar in the libs folder, together with arm64-v8a and x86_64 subfolders and I have removed compile 'org.xwalk:xwalk_core_library:x.x.x.x' from dependecies.
Updated Links 19-07-2016
maven {
url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
}
And In dependencies add this
compile 'org.xwalk:xwalk_core_library_beta:9.38.208.8'

SignalR in Android Studio

I'm trying to make use of SignalR in Android Studio and while it apparently has added the projects and dependencies to my application project I'm getting constant
Error:(11, 39) error: package microsoft.aspnet.signalr.client does not exist
The import for these packages was dynamically added by Android studio as I started typing code to make use of it
Platform.loadPlatformComponent(new AndroidPlatformComponent());
So there is something there.
However when I try and actually build my main project I keep getting the package error.
I've run out of ideas now as to why it can know enough about the project to build it and reference the packages but then not actually find those packages for the main project to use.
Any ideas?
I never did find out how to do it via Android Studio. In the end I had to use Eclipse (and don't forget to change your workspace to use Java 1.6 or greater)

Libgdx setup UI gives 2 unexpected errors in new GWT project

I have run the setup ui, however, I get two different errors in the -html project than what is described in the tutorial: libgdx tutorial
The tutorial error stated is as follows (which is an error I do not see):
To fix the error of the HTML5/GWT project, go to the "Problems" view, right click the error message "The GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory" and select "Quick Fix". Click "Finish".
The errors I have are:
The project was not built since its build path is incomplete. Cannot find the class file for com.google.gwt.core.client.EntryPoint. Fix the build path then try building this project ...
The type com.google.gwt.core.client.EntryPoint cannot be resolved. It is indirectly referenced from required .class files
Is there anyway i can fix this? I just updated my eclipse, I also downloaded Version 18 ADT, revision 19 for Android SDK Tools, and revision 11 for Android SDK Platform-tools.
I had the same problem a couple of weeks ago and got around it by installing the GWT SDK.
I know that the post is old, but while the answer of #Rod was close to resolve my problem, it didn't fully. After installing the plugin in his answer I got 3 error messages instead of two: the same previous ones and a new one.
Looking inside the class that was giving the problem made Eclipse to point straight to the problem: the compiler compliance required to be 1.5 or greater but Eclipse had by default 1.4. I changed it through Window > Preferences > Java > Compiler > Compiler compliance level, where I put the correct one, 1.7, and everything compiled cleanly.
PS: Thanks #Rod
use the http://dl.google.com/eclipse/plugin/4.2 to install plugin on eclipse
instead of http://dl.google.com/eclipse/plugin/4.4 or 4.3

What could be causing the "OutputPath property is not set for project ProjectName.csproj" error in my MonoDevelop project

On Windows 7 (64 bit) with the Android SDK working perfectly with Eclipse - my first android application, using the first "Hello World" sample (found here - http://docs.xamarin.com/android/getting_started/hello_world - from Xamarin)
fails with the error "the OutputPath property who is not set for project NameProject.csproj".
I have tried re-runing the installation program from Xamarin and this error still occurs.
Could someone please suggest what may be causing this problem?
Thanks a lot.
the exact error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(9,9):
Error: The OutputPath property is not set for project 'helloWorld3.csproj'.
Please check to make sure that you have specified a valid combination of
Configuration and Platform for this project.
Configuration='Debug'
Platform='BPC'.
This error may also appear if some other project is trying to follow a
project-to-project reference to this project, this project has been
unloaded or is not included in the solution, and the referencing project
does not build using the same or an equivalent Configuration or Platform.
(helloWorld3)
I think we've seen this before. Your system manufacturer installed an environment variable called Platform onto your system. This breaks all msbuild based stuff, since msbuild automatically imports that as $(Platform), conflicting with the real $(Platform) that msbuild uses to compile.
Try removing the environment variable and try again.

Categories

Resources