Create Kotlin Library - android-studio

I am trying to achieve what is extremely simply in other languages, however I am new to Kotlin and Android Studio.
I wish, when creating a project, to reuse code by having it in a seperate directory to the project, but to be able to create instances of a Kotlin class in a given project, and also to be able to edit the class definitions and rebuild the 'library' in that open project
Before anyone shoots me I have read
Create a Kotlin library in Android Studio
this however does not work and simply results in

Related

How to create a standalone android aar library project?

I want to create a project that simply creates an aar library. Everything I see on google is about doing that from an 'existing project' which I do not want. That seems to tie into just that project. When I click new project in android studio, I don't see an option for 'library' and it creates an application every time :(.
How does one simply create a project that creates an aar artifact?
I stumbled upon a workaround since the answer to my question is NO :(. Wow!! Why in the world can you not create a library?
Anyways, the answer on this one is what I do now as it seems the cleanest
How to create new Android AAR in Android Studio

use intellij kotlin kt file in android studio

I have written a program using intellij and want to import the code into android studio but i can't find any tutorials that have this specifically.
I am only able to find using kotlin in andoid studio or convert from kotlin to java.
I know it will be easy and that I am not looking in the right places but could really do with a pointer, I have been trying to do it all day lol im starting to loose the will!
Thanks
Not sure if I understood your question correctly, but if you have a bunch of code files and wanna import your code into Android Studio, the easiest way is to just create a new Android Studio Kotlin project, copy your code files from your IntelliJ project to your new Android Studio project, then adjust the code for Android.
If you do it inside the programs instead of in the file explorer, it will even adjust the package names for you.
Here's what I mean exactly by inside the programs:
If you want to create an Android application with the code that you write in IntelliJ. You can create an app in Android Studio and paste the code in the right place(should be in onCreate method) and manage the way that you will show the result. Also you can create an Android application in IntelliJ with the Android plugin.

Cocos2dx can be used in android studio development with java?

I downloaded the cocos3.14.1 in the cocos2dx official website, and then use the online method to create a project structure, and then compiled out android
Studio version of "proj.android-studio", and finally with the android studio to the success of this project can also be run. But then how do I develop it? Map, event, interface, logic how to write?
After importing there will be an activty inheritance Cocos2dxActivity, and a package "org.cocos2dx.lib". But I do not know what to do
You have to write most of the game logic in C++ and keep your class files in "Classes" directory.
You would have to update the android project include these C++ files.
If you're using a mac, it is easier to develop it in Xcode, and build it for android in the last step. That way you can debug all the game logic in Xcode and simulator quickly.
In the project that is initially created, your game logic starts in the AppDelegate file (by setting things like the design resolution etc), and the first scene is the "HelloWorld" scene.
Since you're new to this, why not just purchase a book and get started, or read any of the many tutorials available online.

Sharing own module across projects Android Studio

I'm struggling badly with moving from Eclipse to Android Studio.
Basically, I get that an Android Studio project is more like a workspace and a module more like a project...
However, in the Android Studio start page you can only create projects, so how do you share a module (i.e. a project in eclipse terms) across projects?
Basically, I have a number of apps that use a shared library I've created, in Eclipse all I do is flag it as a library and in each project simply link to it.
I have absolutely no idea how to do this in Android Studio. The examples for creating modules seem to take you as far as creating a module for no real purpose other than to use it within one app.
I first imported my library as a project in android studio, but that proved pointless, thinking that was how to do it because I want it kept separate in my version control system.
I then created a temporary module inside my app, but then it stores it within the project and in my other apps I cannot find a way to import the modules, so I really don't see what the point of a module is when it's embedded in a project and can't be separated or referenced anywhere else.
Thanks for any help.
Consider your library project name common-lib
Open build.gradle of the projects to which you want to add library add add the following
dependencies {
compile project(':common-lib')
}
and sync gradle

Android Studio referencing library seems overly complicated. Is there an easier way?

I'm trying to migrate to Android Studio from Eclipse.
In reading a simple example of using a library within another app:
https://developer.android.com/sdk/installing/studio-build.html
In eclipse to achieve this all I would go to the properties of the project and add a reference to the project. Simple, through the IDE and easy to check the build settings at a later date.
In Android Studio I've got to add an entry to my referenced library using ALT-ENTER after getting autocomplete to find the library, which seems to add an entry to the file 'app.iml':
<orderEntry type="module" module-name="app2" />
Then I've got to edit the gradle file:
dependencies {
compile project(":lib")
}
Is there not a better way, i.e. using the IDE. I don't particularly want to have to remember about this xml iml file or have to manually edit build files every time I want to do something.
?
Sorry,
After browsing for a while with no answer I found it just after posting:
How to create a library project in Android Studio and an application project that uses the library project
Why can't Google update their documentation to use the more normal way (presuming this dialog is a new addition)....

Resources