What is CompositeDefinitionSource in Android Studio - android-studio

Recently after upgrading Gradle Android Studio automatically added this to my .idea/gradle.xml :
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
What is the purpose of this change?

First there is several points to understand:
The file .idea/gradle.xml is used by Android Studio to store the Gradle project settings.
According to the Gradle documentation:
A composite build is simply a build that includes other builds.
According to the documentation of IntelliJ IDEA on which Android Studio is based, there is two ways to define a Gradle composite build either through the IDE or through the settings.gradle file.
According to the source code of IntelliJ IDEA the value of compositeDefinitionSource can be either SCRIPT or IDE.
To answer your question, the purpose of the compositeConfiguration element in the .idea/gradle.xml file is to define as a default the Gradle composite build by script. If you set a Gradle composite build through the IDE this value will change.

Related

How to get Android Studio to recognize my plain Gradle Java project?

I have a simple multi-module Gradle project with Java code. When I import it in IntelliJ Community, it asks me to select the build tool from among Maven and Gradle, and will properly recognize the Gradle modules and show me a Gradle tool window.
When I do the same in Android Studio, I don't get the build tool question, and it won't recognize the projects or show me the Gradle tool window.
How do I get this to work in Android Studio?
Simply Try This,
Go to File -> Project Structure -> Sdk Location
This You will get a option menu like this (the given image)
there you can update your gradle settings.
The answer, as far as I've been able to find out, is: Don't even try. Use IntelliJ instead. Installing it is most certainly quicker than trying to get Android Studio to do this.
How do you open the project in Intellij? Do you open the folder? Or do you open the build.gradle?
Just like a maven project (where you should open the pom.xml, not the folder) you should open the project using the build.gradle, not the folder.
Intellij will then do what you expect and import your gradle project
The least required to make it recognize the project is to add AGP, the Android Gradle Plugin:
buildscript {
repositories {
google()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
}
}
Then one can define Android modules with:
apply plugin: "com.android.application"
apply plugin: "com.android.library"
apply plugin: "com.android.dynamic-feature"
Then it will recognize the android {} configuration block (without this Gradle DSL configuration block it would not know what or how to build for Android - as it isn't a sane Android project). Just see the documentation linked, this has little to do with the default Java tooling.
Gradle 7.2 is currently required to build. Even if one cannot mix the plugins per module, one can have different plugins per module - or use different IDE, depending on the tooling of the module. How compatible this really is, is being determined by the dependencies used in the Java module. The fact that one can only use either tooling per single module dictates the layout to be applied.
I suspect that you will have to manually move some code from the successful build files in intellij to the android build files.

Can scratches be shared between IntelliJ and Android Studio?

I'm working on a project in Android Studio 3.1. I first had to create a .jar file with dependancies in IntelliJ 2017.2. I chose to do my programming in the IntelliJ IDE because I knew that Android Studio is based on IntelliJ.
But now I have a bunch of scratches (lots of notes and code) for my project that I assumed would be available in Android Studio, but they are not.
Is there a way to tell Android Studio to use the scratches from IntelliJ? I will have to be jumping back and forth more and more between IDE's in the future as the project develops.
It's is possible to specify a location for scratches using Help | Edit Custom Properties... and adding the following property there:
idea.scratch.path=~/Scratches
It is necessary to restart the IDE after you make changes there. You could specify the same location in both IntelliJ IDEA and Android Studio. (You can of course choose your own path/location.) In this directory two further directories will be created by the IDE, "scratches" and "consoles". You can create these directories yourself if you already have scratches you wish to use.

Does Android Studio support Code completion for C/C++?

The code completion is fine on Android Studio java project. But I want to use Android Studio to edit some existing C file(.cpp).
for example, if i have declared some function, then i type the function in other section. But the android studio doesn't show up the code suggestion or some debugging.
Can Android Studio support Code completion for C/C++ like this:?
Yes it does, as long as the project is setup to use the NDK and the C/CPP sources are included in the project.
Try pulling the ndk sample repo and try opening one of the projects.
If you have a java project and want to edit some arbitrary C or C++ source, then no. It does not have enough information about the source file, include paths, compiler etc...
If your project uses Android.mk to build, it will be a bug of Android Studio. I have been reported.
Android.mk project cannot show code completion for cpp.
It seems that old version of Android Studio does not support code completion of jni native build (with Android.mk as configuration file), and that should already be fixed now.
But if you are using CMake in your project as external building tool and code completion still does not work, It's probably because you have more than one version of cmake installed. You can try to remove extra ones from SDK manager and restart Android Studio, it should work.
To see installed CMake version, you can open the SDK manager and check the 'show package details' on the right bottom. You can view cmake tools installed with different versions.

which method should I add?

I'm new to android studio. I have problem with syncing my project with this title "android studio “Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly”.
error message:
Gradle DSL method not found :'mavenCentral()'
Possible causes:
.The project may be using a version of Gradle that does not contain the method.
.The built file may be missing a gradle plugin.

How to know whether an existing project was made using android studio or eclipse?

I have got some open source projects which I want to have a try. But I want to use Eclipse if the project was made using eclipse; otherwise I would like to use Android Studio.
So how can I know by viewing the source code about the IDE used for the development of a particular project? Is there any metadata in any file which stores the IDE information?
I believe that Android Studio sometimes includes gradle related files. That's how I would check.

Resources