How to create a standalone android aar library project? - android-studio

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

Related

Create Kotlin Library

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

Incorporate 3rd Party Native Libs into Android Studio project

I am trying to setup an NDK library module structured very similar to the gen-libs module in the Android-NDK sample project. It identifies what I want in an Android NDK library module to allow me to incorporate 3rd party Native Libs:
src/main/cpp
CMakeLists.txt
Android manifest
build.gradle
I am NOT looking to add C or C++ source files to my app module.
Instead, I am looking to create an Android-NDK library module within Android Studio, so that I can incorporate 3rd Party Native Libs.
However, I am Unable to easily reproduce the structure of the gen-libs module in Android-NDK sample hello-libs.
More specifically, Android Studio does not provide any option to create a "New => Module => Android Library => Add NDK/C++ support"
I suppose I can recreate this NDK module manually, but before I do that, I would like to ask the community if, for a brand new project, is there any easy way to auto-create the gen-libs module structure from hello-libs beside manual method?
Feel free to use your copy/paste skills to produce the project manually. The wizard won't do it for you, at least for now.
You can also create an app project and switch it to library by changing one line in build.gradle.
You can also create a library module, right click on this module, and choose 'Link C++ Project with Gradle' from the popup menu (or from File menu).

How to import unity project into existing Android studios projecT?

I am having problems importing unity project into Android Studios. I already have a Android studio project (for menu and other things), and i want to add a scene from Unity 5 3D, as a second activity (not the main activity).
I want to call unity scene when user clicks the button.
I know how to export it from unity but it automatically sets it as MainActivity, and i cant find a way to manually overwrite it.
Edit:
I want to do it in Android Studios and not Eclipse. I just want to know if there is an easy way to do it, or at least a hint for how to do it.
Had the same requirement and successfully imported the Unity project into an existing Android Studio project. As mentioned the first thing will be to export the Unity project. I used Unity version 2017.1. Rough steps below:
Export Android project via Unity build settings
You can simply select the folder where your existing project is located. Unity should add a sub folder with an Android Studio format project and all dependencies and everything it needs to run.
Now we need to convert this "Application" project to a "Library" project. This is simply done by changing the build.gradle file. Replace apply plugin: 'com.android.application' with apply plugin: 'com.android.library'.
You also need to remove the applicationId and change the compile versions to match your project's versions.
Also make sure to modify the Unity module AndroidManifest.xml file. You will need to remove the LAUNCHER intent-filter as the UnityPlayerActivity will not be the main activity anymore.
android.intent.action.MAIN
android.intent.category.LAUNCHER
Also need to remove the Application node attributes so it won't conflict with your project's manifest.
Finally in your settings.gradle add the module and then add the Unity project dependency on your "app" module: compile project(':UnityFolder')
Build and now you should be able to start the Unity Scene by calling:
Intent intent = new Intent(this, UnityPlayerActivity.class);
startActivity(intent);
yes we can start another activity before unity Activity
1 step-create java class and add it in manifest and like in image
2nd step- create onClick in java class
link to unity game class s you can see in amage
see pic, you can choose button also
3rd step- in manifest replace Intent in own java class it will work [3]
From this link: https://nevzatarman.com/2015/01/04/unity-android-tutorial-opening-unity-scene-from-an-activity/
Add android:process=":UnityKillsMe" to the unity activity GameActivity.

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