zoukankan      html  css  js  c++  java
  • Android Project和app中两个build.gradle配置的区别

    一般创建一个android项目后回出现两个gradle:一个build.gradle(app),一个build.gradle(Project),顾名思义就是一个是用来配置整个工程的的一个是用来配置app的。

    一、gradle中dependencies 的区别:
    下面英文就是对compile和classpath区别的解释:

    I’m going to guess that you’re referencing compile and classpath
    within the dependencies {} block. If that is so, those are dependency
    Configurations.

    A configuration is simply a named set of dependencies. The compile
    configuration is created by the Java plugin. The classpath
    configuration is commonly seen in the buildSrc {} block where one
    needs to declare dependencies for the build.gradle, itself (for
    plugins, perhaps).

    classpath的作用:

    buildscript itself needs something to run, use classpath

    complie的作用:

    your project needs something to run, use compile

      在Project中的gradle的dependencies 指添加依赖是使用classpath的,classpath一般是添加buildscript本身需要运行的东西,那么buildscript是用来什么呢?buildScript是用来加载gradle脚本自身需要使用的资源,可以声明的资源包括依赖项、第三方插件、maven仓库地址等。
      在app中的gradle中dependencies 中添加的使应用程序所需要的依赖包,也就是项目运行所需要的东西。

    二、compile有哪几种?
    Compile
    compile是对所有的build type以及favlors都会参与编译并且打包到最终的apk文件中。

    Provided
    Provided是对所有的build type以及favlors只在编译时使用,类似eclipse中的external-libs,只参与编译,不打包到最终apk。

    APK
    只会打包到apk文件中,而不参与编译,所以不能再代码中直接调用jar中的类或方法,否则在编译时会报错

    Test compile
    Test compile 仅仅是针对单元测试代码的编译编译以及最终打包测试apk时有效,而对正常的debug或者release apk包不起作用。

    Debug compile
    Debug compile 仅仅针对debug模式的编译和最终的debug apk打包。

    Release compile
    Release compile 仅仅针对Release 模式的编译和最终的Release apk打包。

  • 相关阅读:
    java的装箱和拆箱详解
    java语法基础
    java变量与内存深入了解
    java的配置环境简介
    Python脚本--利用运算符重载简化MongoDB的命令
    Python多线程编程,线程锁
    Python多进程,同步互斥,信号量,锁补充上一篇文章
    Python多进程编程及多进程间的通信,数据传输
    Jmeter深度学习第一天——简单请求、带header请求、返回值乱码问题
    JAVA Spring工程一些配置问题的解决
  • 原文地址:https://www.cnblogs.com/coffee520/p/10118777.html
Copyright © 2011-2022 走看看