How do I use Clojure in Android Studio using Graclj? - android

My ultimate goal is to be able to write Clojure apps for Android, using Android Studio and Cursive. I started with leiningen but found out that it is a build system that is independent of what Andoid Studio uses ie Gradle. So I tried leiningen with Intellij, but couldn't get Android deploys to work except from the command line. Since I wanted to integrate with Android Studio, I decided to try Graclj: https://github.com/graclj/graclj which is a Gradle plugin for Clojure.
I can get the Graclj tutorial running in Android Studio, as per this guide:
https://github.com/graclj/learning-graclj/tree/learning-0.1.0
However:
Graclj expects the Clojure src and built classes and jars to be in the root project
Android Studio expects src and classes to be in the app subproject
After the tutorial I end up with separate Gradle build tasks for Graclj and Android Studio but I don't know how to integrate them
So, can anyone suggest a way that I can hook into Andoid Studio's build process?
Do I need to change some settings to the Graclj plugin to do this? If so, how?
Do I need to change some Android Studio plugin settings?
Do I need to add/change something in the Gradle build scripts?
Am I heading down a dead end? ;-)
I have looked at the Android Studio build process: http://developer.android.com/tools/building/configuring-gradle.html
but I don't know enough about Gradle to know what I'm supposed to be doing here.
If I need to supply any more info, just ask.
Any help appreciated!

Unfortuantely, I don't have any Android (let alone Android Studio) experience. However, I'll do my best to answer based on Gradle/Graclj knowledge.
Graclj does not require you to use the root project. You can apply the plugin(s) in any of the projects that you have in your build. However, I don't know how well a model-based plugin like Graclj will work with the "traditional" Android plugin. You could try the "experimental" one that's using the model approach, though there's a decent chance that it won't be compatible unless there's one that works with Gradle 2.12.
Alternatively, you might be able to add a dependency to the Android app project on the JAR produced by Graclj (which you may still want to put in a project besides the root). Not sure if there's a very good way to do this (haven't tried myself).
dependencies {
// my-other-proj being whichever one you use Graclj in
compile project(':my-other-proj')
}
Or maybe you would need to add it to a configuration first in the my-other-proj to interop with traditional plugins:
artifacts {
archives createMainJar
}
It is possible that you're at a dead end (for now). Graclj is very new, so this stuff should all be possible eventually.

Related

How do i prepare my ambient for a Android Studio Native project?

I have a problem and I would like your help :)
I received a native Java project from Android Studio and I want to know how I can configure my environment, the first time I tried I had a lot of errors with gradel.
Is there a way to know exactly what settings are needed to start project maintenance?
As long as you have installed Android Studio and are able to create sample projects, you should be set up.
Gradle should show you all the problems which your legacy project has. I assume, that you will see a lot of warnings which can be ignored at first.
You might have problems with a missing key.properties file.
Some dependencies might not be available anymore.
You have to resolve all the issues manually. There aren't any special settings.

Is it possible to run the same source code in eclipse and android studio?

I am new to android development, So I am not sure if this question is very silly
I was wondering if the same source code can run in both eclipse and android studio
If this is possible how to do it, and what points should be considered?
If not what are the road blocks to accomplish this.
Simple answer: Yes, you can "write" (not run) in both IDE's.
Aside: You really don't even need an IDE. If using Gradle, you can write code using any text-editor, then compile, build, test, and install all using Gradle.
If this is possible how to do it?
Well, Android Studio can import Eclipse projects. That is pretty well documented.
Eclipse (unofficially) has an Andmore project and also supports Gradle projects.
what are the road blocks to accomplish this
If using Eclipse, it's not supported by the Android team anymore, and you'll likely be missing out on features that are actively added to Android Studio.

Google launcher building

I tried to build this project using JetBrains IntelliJ IDEA but it was unsuccessful (there were a lot of errors). The project has an Android.mk file, but I didn't see the C++ code.... How can I build this project? I've tried to use another IDE, then I tried building from the console but it was not useful. Perhaps, does Launcher3 need NDK to build it?
You'll need to isolate the launcher's code and then identify all of it's dependencies. If the code has any C++ code then it definitely requires the NDK and currently IntelliJ/Android Studio does not have any stable support for NDK based app development (though it is a work in progress) else if it is pure Java (most probably) then you'll have to manually add the classes and build the app from Android Studio! Either way you will have to dig deeper into the source and know for yourself. Unfortunately there seems to be no easier option, for now. I wouldn't mind being proved wrong for the matter.
EDIT :
I glanced through the code and I noticed there are no C++ source files or library (*.so) files. This isn't a gradle project and hence cannot be built as one. You'll need to setup a gradle based Android project and then begin adding the sources (src, tests etc.) and their dependencies (res etc.). You can start of here : Getting Started with Android development if you're new, else you can move to this : Gradle and Android

Can I use Android Studio when teammates uses Eclipse ADT?

Just a quick question I did not find a good answer on. We are currently working on an APP created with Eclipse ADT Bundle. I recently started exploring Android Studio, and like it. Is it possible to still collaborate with my mates using Eclipse with a shared GitHub repo?
I noticed Android Studio converts the project to its own file structure, so I guess this does not go well with Eclipse, and the repo.
Is there any solutions for this? So I can keep developing in Android Studio, push to GitHub, while the rest of the team use Eclipse?
I think you can do it, you'll just have to explicitly define a sourceSet that matches the Eclipse structure. If you use any other build variants, they can't have any sourceSets because you wouldn't be able to check those files in to source control. However, there are several useful things you can do with build variants just with the build file. I think you can check in the build.gradle and other gradle stuff and it won't mess up your coworkers.

Build Android project using AndroidProguardScala with Ant

i'm developing for Android in Scala following instructions from Eclipse, Android, Scala made easy but still does not work. Everything works great in my development machine, building within Eclipse.
But now i need to build the project with Ant, outside of Eclipse, and i'm lost.
I still want to use this method, don't want to use SBT. So i'm assuming i should do a "headless build" of the plugin... any hint?
You really should try and use SBT. There is a great plugin for sbt on github with a good getting started tutorial. Also, SBT's wiki has some really good information for how to go beyond the basic sbt.
The sbt-android plugin has a really nice feature where it adds Typed Resources to your android build so you can do something like:
var button:Button = activity.findView(TR.myButtonInTheLayout)
Type safe layout management... its a pretty handy feature.
Sbt-android also supports using standard scala directory layout or standard android directory layout, whatever your comfortable with.

Categories

Resources