Is it possible to get application’s context in an Android Library Project?

There is one more way, add application class in your library project: /** * Base class for those who need to maintain global application state. */ public class LibApp extends Application { /** Instance of the current application. */ private static LibApp instance; /** * Constructor. */ public LibApp() { instance = this; } /** … Read more

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader

I am currently working on an Android application which streams radio. I use native decoder library which is called aacdecoder. Everything was fine till app gets crash error on some Android devices. It was really annoying. Because app was perfectly plays radio streams almost all devices but Samsung S6 and S6 Edge. Crash report says … Read more

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

Is it possible to dynamically load a library at runtime from an Android application?

Sorry, I’m late and the question has already an accepted answer, but yes, you can download and execute external libraries. Here is the way I did: I was wondering whether this was feasible so I wrote the following class: package org.shlublu.android.sandbox; import android.util.Log; public class MyClass { public MyClass() { Log.d(MyClass.class.getName(), “MyClass: constructor called.”); } … 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

Require Gradle project from another directory

The simplest way is to make MyProject a multi project with the Logger project as a subproject. settings.gradle in MyProject directory: include “:logger” project(“:logger”).projectDir = file(“../logger”) In the build.gradle of MyProject you can now reference this lib as a project: dependencies { compile ‘com.android.support:gridlayout-v7:18.0.0’ compile ‘com.android.support:appcompat-v7:18.0.0’ compile project(“:logger”) }