4

I have installed android with the latest stuff:

brew install ant
brew install maven
brew install gradle
brew install android-sdk
brew install android-ndk
brew install kotlin

I have a simple hello world example.kt file like this:

package foo.bar

fun ms() : Long {
  return System.currentTimeMillis()
}

And a test.kt like this:

package foo.bar

fun main(args: Array<String>) {
  println(ms())
}

which is compiled and run like this:

kotlinc src -include-runtime -d test.jar
kotlin test.jar

Next I would like to display a triangle using OpenGL on Android. A basic hello world example. I've checked through quite a few resources but haven't seen how to actually compile an Activity using kotlinc, which seems like the main "application object" in Android.

For reference, these imports seem relevant to android sdk OpenGL:

import android.opengl.GLES20
import android.opengl.GLES32
import android.graphics.SurfaceTexture
import android.opengl.GLSurfaceView

Anyways, basically what this boils down to is how to render an Activity using kotlinc, purely from the command line, without Android Studio or any UI/IDE. Once I get there then I can figure out how to do OpenGL.

So for example, this post shows this Activity boilerplate:

package me.mladenrakonjac.modernandroidapp

import android.support.v7.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}

I would like to just render a HelloWorld Activity (without any AndroidManifest.xml if possible, just Kotlin instead of XML, unless XML is required, I'm new to Android), from the command line. Not sure how to take that MainActivity snippet and compile it and render it, maybe add a textarea with "hello world" in it.

If not possible with Kotlin, then wondering how to do it with Gradle/Java.

Lance
  • 75,200
  • 93
  • 289
  • 503
  • ***WOW*** you have gone hardcore compliance (to be expected ;O)) Seems simple, you will get a lot of answers I'm sure ;o) – Jon Goodwin Mar 28 '19 at 14:26
  • Why not use Android Studio to write down the code? Feel free to use the command line for compilation and building afterwards. – Rahul Shukla Mar 29 '19 at 10:33
  • 1
    While you're trying to dig a channel with spoon, I'll tell you that even if you manage to build `apk` file `without AndroidManifest.xml` you won't be able to install and run the application without the `xml`. – Onik Mar 29 '19 at 16:47
  • 1
    My answer to the question [“Hello world” Android app with as few files as possible, no IDE, and text editor only](https://stackoverflow.com/questions/47167769/hello-world-android-app-with-as-few-files-as-possible-no-ide-and-text-editor/47251607#47251607) should help here. You can write in pure c/C++ no **java/kotlin** *at all* if your familiar with NDK/JNI. – Jon Goodwin Mar 31 '19 at 23:01

0 Answers0