Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use customized framework library(android.jar) within Android Studio

I had my own customized framework(android.jar) and want to use it within Android Studio. I had description in my build.gradle like:

dependencies {
     compile files('myandroid.jar')
}

But Android Studio still use the default framework(android.jar). Expected situation is like Eclipse, I can arrange the order of libraries. In Android Studio, I can only arrange external libraries' order and have nothing to do with the default framework library. Is there a way to let my customized android.jar had higher order than the default one?

Thanks a lot!

like image 600
superx3 Avatar asked Oct 28 '15 02:10

superx3


1 Answers

Place this line inside your dependencies:

provided files('libs/myandroid.jar')

If still not work, so we can add our library to build classpath. In application's build.gradle, add these:

allprojects {
    repositories {
        jcenter()
    }
    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs.add('-Xbootclasspath/p:app\\libs\\mylibs.jar')
        }
    }
}

I placed mylib.jar is in app/libs. There maybe some errors display on IDE, but application's build will be OK.

like image 95
anhtuannd Avatar answered Sep 28 '22 07:09

anhtuannd