什么是gradle这个功能的Andr​​oid使用的apk范围? [英] What is the use of apk scope in gradle-android?

查看:331
本文介绍了什么是gradle这个功能的Andr​​oid使用的apk范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该文档描述的apk范围,因为只有包时间依赖性,所以它不会被用于编译。

The documentation describes apk scope as package time only dependency, so it won't be used for compilation.

我不认为我需要在运行任何东西的情况,但并不需要编译。如果我使用一个jar(不是库项目.aar,只是一个库),我的code肯定还会有图书馆参考 - 如果在编译过程中没有发现库,我无法在设备上检查测试运行时的可用性库。

I cannot think of any scenario where I need something at runtime, but not needed for compilation. If I use a jar (not a library project .aar, just a library), my code will definitely have references to the library - and if the library is not found during compilation, I cannot test on a device to check for runtime availability of library.

PS:我理解APK的范围是一样的非Android项目的一揽子的范围。这将有助于即使有人可以从非Android的角度解释。

PS: I understand 'apk' scope is the same as 'package' scope for non-android projects. It would help even if someone can explain from a non-android perspective.

推荐答案

如果你有一个罐子中包含com.library.A,
您可以通过

If you have a jar contains com.library.A, you can use class A by

try{
   Object o = Class.forName("com.library.A").newInstance().
   if(o!=null){
   }
}catch(Throwable e){
}

您不需要有它的编译。

所以,你可以建立项目faster.When您生成APK,可以使用该库为正常。

So you can build project faster.When you generate an apk,you can use the library as normal.

这篇关于什么是gradle这个功能的Andr​​oid使用的apk范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆