Use customized framework library(android.jar) with

2020-06-19 04:43发布

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!

4条回答
我欲成王,谁敢阻挡
2楼-- · 2020-06-19 04:48

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.

查看更多
Fickle 薄情
3楼-- · 2020-06-19 04:53

Try this ,In your modules's build.gradle file .

dependencies {
    compile files('libs/myandroid.jar')
}
查看更多
唯我独甜
4楼-- · 2020-06-19 04:55

What you can do is adding your .jar in your libs folder, then right clic on it and select add as a library.

Then if it doesnt work already, try to right clic on your project folder and select Open Modules settings. You can manage your dependency and your libraries there.

查看更多
▲ chillily
5楼-- · 2020-06-19 05:10

Try this:

allprojects {
    gradle.projectsEvaluated {
       tasks.withType(JavaCompile) {
           options.compilerArgs.add('-Xbootclasspath/p:/mylib.jar')
       }
    }
}

http://www.jianshu.com/p/a25a85b6372d
How to put my libraries in front of android.jar by editing build.gradle in Android-Studio

查看更多
登录 后发表回答