Create an Android sample project #2
Comments
I've tried to run
Also, in the Release Notes, I've found this information:
This probably makes it impossible to build any Android project. Even “kotlin-plugin-1.1.0-dev-372.zip” is not compatible with Android Studio 2.1.1 (latest version, downloaded today). |
There are a couple of reasons that writing Android builds in Kotlin won't work yet (as of 1.0 M1):
So at the moment, the best answer I can give you is: stay tuned. We're already in communication with the Android team about this work, and I'll update this issue as the next steps toward Android support become clearer. |
Android +1 |
It turns out that the Android plugin's limitation on Gradle 2.10 can be worked around by adding the following to your build: buildscript {
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
...
} See this bug report for more information: https://code.google.com/p/android/issues/detail?id=211462&thanks=211462&ts=1464346630 |
I've just updated the title and description of this issue to make it about demonstrating support for Android builds via a sample project. As mentioned in the comments above, the major limiting factor in being able to use Gradle Script Kotlin to write Android builds is being able to actually get the Android plugin on the build script classpath in the first place (#29). Once that's done, we'll start working on putting together an Android sample. |
@cbeams Here is the issue I am seeing. Error message:
Error:
|
Superseded by #83. |
I got the hello-android kotlin sample app to build with AndroidStudio 3.0 by adding the old style
into the settings.gradle pluginManagement/Repositories block. You can't add google() there but you can add this older style maven url declaration. |
@MonteCreasor You should not have to. You can use |
I wasn't talking about build.gradle, I was referring to settings.gradle. I have no problems with declaring google() in the build.gradle.kts, only in the settings.gradle. If you try and add google() to the repository block in settings.gradle, it won't get resolved. And, you can't import RepositoryHandler. I tried to add import org.gradle.api.artifacts.dsl.RepositoryHandler at the top of settings.gradle and that didn't help. |
That is right. That is not supported yet: https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_management. |
I like your android-gif-example though. The kotlin gradle setup is great. |
@MonteCreasor Thanks! Feel free to contribute. I want to keep it up to date with the latest Kotlin DSL. |
@jaredsburrows How do you get your kotlin dsl scripts to not have all sorts of parsing conflicts between Java and Kotlin. The project compiles and runs fine using AndroidStudio 3.0, but if I open any of the .kts files, I get all sorts of errors all to do with the parser not being able to find java objects (String, Object, etc.). This also happened with the hello-android app in the Kotlin samples. |
@MonteCreasor It happens in this file: https://github.com/jaredsburrows/android-gif-example/blob/master/gradle/project-schema.json. When you add a plugin to your |
@jaredsburrows Shouldn't that just work already in your project? I just ran kotlinDslAccessorsSnapshot in your project and it ran without any errors, but it doesn't resolve all the errors in the .kts files. I'm not adding any plugins because I'm just trying to get your project to run. Well, it does run, but if you saw the errors I have in the .kts files, you would be amazed that it builds and runs anyway. |
@MonteCreasor Ideally it should. But when I apply a new plugin and add it's extension it always complains. What errors are you seeing? If you are using Android Studio 3.0.0, there is a bug for this here: #584. |
@jaredsburrows Ya, I saw that exact bug earlier today when I was trying to get the hello-android app to compile. Those are the exact type of errors I'm getting. I'm running AndroidStudio 3.0.0 on Ubuntu 16.04 LTS. Why the heck is it working for you? Is this a Windows/Linux issue maybe? |
It should work for you as it works for the CI. The IDE just "complains" because Android Studio is always being Jetbrain's normal Intellij IDEA IDE. |
Same problem in IDEA 2017.2 |
You are right. I see the same thing. |
Thanks for all the help @jaredsburrows. I think I'll wait until things are more stable and go back to boring Groovy for now. |
If you apply all your plugins using the Named repositories (e.g. |
@eskatos This is very exciting news! Thank you! |
@anokmik originally wrote:
This issue is now about creating a sample project that will demonstrate how to write an Android-based build using Gradle Script Kotlin.
The text was updated successfully, but these errors were encountered: