I am looking to use Gradle's new composite build feature in an Android Studio project called MyProject that includes both an Android Archive library (.aar) called DroidLib and a Java library (.jar) called JavaLib. These libraries are currently checked into version control due to my inability to get Gradle to pull dependencies from our internal Artifactory. That is, the DroidLib project has the JavaLib.jar checked into git under the libs folder and the MyProject project has the DroidLib.aar checked into git under its libs folder. I would like to make changes in both DroidLib & JavaLib while debugging and consuming the changes in MyProject w/o manually rebuilding from the dependency projects.
The new Composite build feature in Gradle offers just the thing I need however it looks to be something triggered from the command-line via a flag such like this:
--include-build ../DroidLib
In the Gradle docs it looks like this flag allows Gradle to override a dependency declared in the local project with a similarly the project declared in the included build. This would make sense since they both would use the same group/name/version scheme. I'm having trouble trying to understand how I would use this from Android Studio where my DroidLib dependency is declared as a local filesystem based dependency:
compile(name:'DroidLib-1.19', ext:'aar')
How would the command line flag tell Gradle which dependency is overridden since there is no apparent group/name/version declared on DroidLib? Also how could I make use of this in my app launch run config which uses the Gradle-aware make feature? Is there a way to pass add'l options to the Gradle-aware make or am I over-thinking what has to happen here?
Short answer
It is not available yet (it is in IntelliJ 2016.3).
More details
According to this blog post, the feature is in IntelliJ 2016.3:
With composite builds, everything is much, much simpler. All you have to is to attach the Gradle projects of these libraries via the Add button in the Gradle tool window (my-utils in our case), and then select Compose Build Configuration from the context menu for the original project.
Unfortunately, according to this release note, Android-Studio 2.3 is based on IntelliJ 2016.2. So we'll have to wait for IntelliJ 2016.3 to be merged into Android Studio =/.
Related
Since Unity 2019.3 the Android build process has changed and now the gradle project contains two modules - a unityLibrary module and launcher module.
I am having trouble uploading native symbols as I cannot apply the plugin to the unityLibrary module, and only works in the launcher. Is there a certain way I can achieve this?
When I run uploadCrashlyticsSymbolFileRelease task that is only present on the launcher module, I receive this error:
Could not find the file generated by Google Services. Please check your Firebase project configuration
The configuration file is in the unityLibrary module.
Is there any way to move the task to the unityLibrary module? If I move the crashlytics plugin to the unityLibray module the error changes into:
Crashlytics was applied to a project without an Android plugin. Please make sure the Crashlytics plugin is applied after the appropriate Android plugin for your project.
The tricky bit is that Firebase is still compatible with versions of Unity that do not support gradle integration. Because of this, the build pipeline in Unity re-implements the functionality of the google services plugin (namely generating the values.xml file).
I've personally put some effort into massaging the mainTemplate.gradle file to work with gradle plugin, but haven't gotten the NDK upload to work yet. Some notes that may help:
The External Dependency Manager for Unity (EDM4U) will both update the mainTemplate.gradle file if available but will also process google-services.json and drop the output into Assets/Plugins/Android. You'll likely want to run it once to generate the dependencies, delete the values.xml, and then disable EDM4U to prevent it from regenerating that file.
The Unity SDK is based on C++, and the aar archives that bind C#, C++, and Java are packaged into local maven repository in your Assets directory. This will make it hard to relocate your project after generating it (ie: try to do all your work Unity side if possible).
Because you'd be short-circuiting Firebase's processing of values.xml to use the plugin, you'll need to make sure google-services.json actually makes it into your Android sourcetree. Assets/StreamingAssets might do this automatically but you may have to write a build script to copy it over.
Finally, the team is aware of the desire to debug NDK code in the Unity Crashlytics plugin. There aren't any public timelines available, but in lieu of a good answer opening an issue on the quickstart or posting to the mailing list might could be a good way to try to work through the process.
I am very new to Mobile Development especially with the use of Android Studio and Java (but i'm familiar with the language already as i came from C#). But the challenge is i don't yet how to configure the project itself unlike what i can do in VS.
Basically i am trying to include a downloaded SDK, the package looked like it is the same as my project (contains Gradle, etc, etc, so i've thought this is Gradle Project).
What i have tried
is going to file -> Project Structure -> Dependencies -> Add Dependency. Which is basically including a Gradle Project from the options.
It went a-okay but i'm not aware yet it this was right? I checked the Docs from android studio and included the dependency in my Gradle.
It goes like this: implementation project(":MyDownloadedProject")
I know this is pretty simple but i've been checking out stuffs for a long time already but unable to find any useful resource.
Thanks a lot!
Add build dependencies with autolinking or by manually adding to build.gradle
see https://developer.android.com/studio/build/dependencies
I've recently ran into this problem, and would like to know, if possible, whether there's a solution for it.
Basically in the project I'm currently working, there used to be some legacy class files that were deleted in a past commit, but sometimes I need to look them up for quick reference, so I just reverted them back to my local changelist and set them as unversioned.
Now, the problem is that due to the legacy nature of these files, some of them don't compile anymore, but the gradle build attempts to compile them although they're unversioned.
So, my question here is: Is there a way to make gradle ignore unversioned files, just stop contemplating them for the build?
No, there is no such way. Gradle cannot exclude files from build based on their version control status. If you only need to use those classes for reference, move them to a directory outside of your project root directory.
I understand this might be an extremely obvious and ridiculous question to ask, but please excuse me as I'm a beginner. I want to integrate this file into my project so I can call its methods:
https://github.com/RomainPiel/Shimmer-android
The question is, what do I do with it? Is it considered a "module", "library" or "file"? Should I manually copy the source files and create new classes in my project, and then call the methods from there? This would be the most straight-forward but in the "how to use" section in that package, it was mentioned "compile 'com.romainpiel.shimmer:library:1.4.0#aar'"
What I tried:
I downloaded the file as a .zip and then File->New->Import Module then navigated to the unzipped file. I believe I'm then supposed to add "compile 'com.romainpiel.shimmer:library:1.4.0#aar'" so I went to the gradle file to try to add it.
There are two: build.gradle (Module:app) and (Project:ProjectName).
I've tried adding to either and\or both and got this error: (Error:9,0) The project 'ProjectName' may be using a version of Gradle that does not contain the method. Did I do something wrong? Is it supposed to be this easy?
I would be extremely grateful to anyone who can point me in the right direction :)
You have three option
Using the GitHub Desktop you can clone the project and open it like a local project. Every change you make will be tracked. You can then commit and push using the GitHub Desktop. It's all UI and simple to use.
https://desktop.github.com
On Android Studio, when you open it, you'll see this, select GitHub and continue by adding your credentials.
You can then commit and push directly from that.
Using the terminal / command line.
If you are new, I recommend the first. It's simple to use and you get a hang of using it as it is the same steps with any project on any IDE you use.
Note: Downloading it as zip and then using it a bad idea because you're making it difficult on yourself because you can't keep track of changes and you'll have to re-upload everything every time. Which defeats the purpose of version control
If that GitHub account is not yours, then you'll have to fork the project, this way you'll have a separate version of the code on you GitHub on which you can modify. If it is yours then you're good.
Typically, you do not want to include external source code manually. This inhibits your build tool's (i.e. Gradle's) ability to manage that source code. It's very easy in Gradle to, say, set the version (like you have done by specifying "1.4.0") and then later remind yourself what version you have by merely looking at your build.gradle file. However, how would you go about doing that with raw source code? Typically developers do NOT put the version number of the source code in the actual source code - that's what they use their version control system (e.g. git) for, usually with tags.
Another aspect of Gradle is downloading and caching (and compiling) the external project for you. So that's nice.
With that said, you typically want to put that "compile..." line in your module's build.gradle file. Not the Project's build.gradle.
A module corresponds to your application (or library) that you are building or using. Some project's have multi-module configurations, where one module acts as a dependency for another (or several others). A Project in gradle is more of a 'meta' configuration that you can apply to all of your modules. The gradle docs recommend you focus on your module's configuration first and adjust the Project's configuration only if you have a specific need and reason to do so.
For the error you mentioned, you might have some unnecessary configurations in your build.gradle file, or the tool version numbers might not reflect what's on your system - if you copied and pasted from the internet, you might want to correct this by letting your IDE generate that file (the brute-force approach would be to create a new project entirely, and use its build.gradle files as a reference). Before you do that, you might want to check if your IDE provides any warnings inside that file.
You have to add the dependency to your module's gradle file.
There are two gradle file present in an android project. One is the project gradle and the second is the module gradle for each individual module.
You just have to copy the given
compile '......' in the dependency block.
EDIT:
When I use the response of How to manually include external aar package using new Gradle Android Build System I have an error.
BASE:
I never use AAR file, with the release of Android Studio we can use it.
But I don't find any explanation to use it.
Do you know how to use it?
It's necessary to make some things like ask for the permissions or create the dependencies?
Thanks
AAR format is a jar file containing a compiled Android Library project. Here's some info on what is inside an AAR file
What this means for app developers is that instead of (the old way):
Downloading the source code of a library project
Building it in eclipse
Setting your application project to depend on the local library project
You can instead add the dependency specification to your project/app/build.gradle's dependencies block: compile 'fr.baloomba:viewpagerindicator:2.4.2'
Then gradle (on the next build) searches for the aar file in a central binary repository, downloads the library and allows you to use it's functionality in your project. ( ex: http://search.maven.org/remotecontent?filepath=fr/baloomba/viewpagerindicator/2.4.2/viewpagerindicator-2.4.2.aar )
You can also search the central repository's web interface for libraries to depend on. Once you've clicked on a library to add to the project, click "Gradle/Grails" under "Dependency Information" to copy the line to add to build.gradle.
In my opinion this is a huge improvement.
You don't need to add any permissions to the app, either way, adding a Library project dependency is a compile time thing, not runtime or user-facing.