Gradle android build for different processor architectures

As of Android Gradle Plugin version 13 you can now generate seperate APK’s using the new “split” mechanism. You can read about it here. The default file structure for placing your .so files is: src -main -jniLibs -armeabi -arm.so -armeabi-v7a -armv7.so -x86 -x86.so -mips -mips.so Note that the name of the .so file is unimportant … Read more

Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler

This problem occurs when there are multiple JDKs installed in your system, I had the same issue as I had mistakenly installed oracle-jdk-9 and Android studio requires oracle-jdk-8 If you are using Ubuntu you can install jdk-8 from this question. So, Make following changes as shown below: Press ctrl+shift+alt+s that will open project structure which … Read more

Gradle: add dependency for a specific flavour of the library

In your library you need to tell gradle to build every time every variant: android { publishNonDefault true } Then in your application, since recently I guess, you can do this: dependencies { (…) devCompile project(path: ‘:lib’, configuration: ‘devDebug’) // or ‘devRelease’ storeCompile project(path: ‘:lib’, configuration: ‘storeRelease’) // or ‘storeDebug’ } Found in the official … Read more

How to create android project with gradle from command line?

Similar to How to create Java gradle project suggest to create Android project with android create project than add build.gradle template for classic Android project gh.c/N/n-1/b/m/o.n.e.e.g/docs/android/build.gradle. (That would allow to develop in any IDE, as old structure is more widely adopted) Of course there will be some gradle init options or android create (from SDK) … Read more

How to make gradle generate a valid pom.xml file at the root of a project for maven users?

You can use the gradle maven plugin. This adds the pom convention method to your project, which you can use in a task to generate a pom.xml file, like task writeNewPom { doLast { pom { project { groupId ‘org.example’ artifactId ‘test’ version ‘1.0.0’ inceptionYear ‘2008’ licenses { license { name ‘The Apache Software License, … Read more

Multiple settings gradle files for multiple projects building

I was able to solve this problem in a relatively clean way. Improvements are certainly welcome! Although Gradle does not support multiple settings.gradle scripts out of the box, it is possible to create individual sub-projects each with their own settings.gradle file. Let’s say you have multi-project A that depends on multi-project B, each with their … Read more

Gradle not including dependencies in published pom.xml

I was able to work around this by having the script add the dependencies to the pom directly using pom.withXml. //The publication doesn’t know about our dependencies, so we have to manually add them to the pom pom.withXml { def dependenciesNode = asNode().appendNode(‘dependencies’) //Iterate over the compile dependencies (we don’t want the test ones), adding … Read more