Using the new “manifestmerger” property in Android

Add the following line to your project.properties file of your application project. manifestmerger.enabled=true Introduced with Android SDK Tools, Revision 20 (June 2012): https://developer.android.com/studio/releases/sdk-tools Build System     * Added automatic merging of library project manifest files into the including project’s manifest.       Enable this feature with the manifestmerger.enabled property.

Convert existing project to library project in Android Studio

In your module’s build.gradle file (not the root project, if you use modules!), simply replace: apply plugin: ‘com.android.application’ // or, if you’re on an old version apply plugin: ‘android’ // note: this one is deprecated …with: apply plugin: ‘com.android.library’ // or, if you’re on an old version apply plugin: ‘android-library’ // note: this one is … Read more

Android support multidex library implementation

The Blog was the old solution. With Android Studio 0.9.2 & Gradle Plugin 0.14.1, you only need to: Add to AndroidManifest.xml: . android:name=”android.support.multidex.MultiDexApplication” or Add MultiDex.install(this); in your custom Application’s attachBaseContext method or your custom Application extend MultiDexApplication add multiDexEnabled = true in your build.gradle . android { defaultConfig { … multiDexEnabled = true } … Read more

Debug native code in Android Library

I was able to set breakpoints and debug native code in an android library on eclipse by adding the directory of the unstripped shared library/libraries to the debugger in the debug configurations dialog: Go to “Run” menu-> “Debug Configurations” Under “Android Native Application” in the left pane, select your application Under the “Debugger” tab click … Read more

Proguard ignores config file of library

You typically should not enable ProGuard in the library project. ProGuard processes the application and the library together in the application project, which is the most effective approach. In the library project, you can specify any library-specific ProGuard configuration in build.gradle, e.g.: defaultConfig { consumerProguardFiles ‘proguard-rules.txt’ } This file is then packaged in the library … Read more

BuildConfig.DEBUG always false when building library projects with gradle

With Android Studio 1.1 and having also the gradle version at 1.1 it is possible: Library android { publishNonDefault true } App dependencies { releaseCompile project(path: ‘:library’, configuration: ‘release’) debugCompile project(path: ‘:library’, configuration: ‘debug’) } Complete documentation can be found here http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication EDIT: The issue has just been marked as fixed for the Android Studio … Read more

Publish an Android library to Maven with AAR and sources JAR

Current answer With Android Gradle Plugin 7.1 it is now very simple to do this without needing any complicated scripts. AGP now also handles creating source and javadocs jar. You don’t need any separate scripts, just write everything into your build.gradle file of your module: plugins { … id ‘maven-publish’ } android { … publishing … Read more