首页 \ 问答 \ 为什么我的Gradle产品口味都在建设中?(Why are all my Gradle product flavors building?)

为什么我的Gradle产品口味都在建设中?(Why are all my Gradle product flavors building?)

我在一个用gradle构建的android项目中有两个产品风格。

其中一种口味声明了额外的依赖性,但实际上两种口味都使用了依赖性。 两种风格都会构建,因为其中一种风格依赖于仅为第一种风格声明的库,而不应该是这种情况。

由于其中一种口味是专业版,最终不应该在apk中有admob SDK我现在担心由于某种原因这两种口味添加了admob SDK。

我有以下build.gradle文件:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 18
    }

    productFlavors {
        Pro {
            packageName "de.janusz.journeyman.zinsrechner.pro"
        }
        Free { 
            dependencies {
                compile files('src/Free/libs/admob.jar')
            }
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile fileTree(dir: 'libs', include: '*.jar')
}

I have two product flavors in an android project that is build with gradle.

One of the flavors declares an extra dependency but actually the dependency is used in both flavors. Both flavors build, since one of the flavors depends on a library only declared for the first flavor that should not be the case.

Since one of the flavors is the pro version that in the end should not have the admob SDK in the apk I now fear that for some reason both flavors add the admob SDK.

I have the following build.gradle file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 18
    }

    productFlavors {
        Pro {
            packageName "de.janusz.journeyman.zinsrechner.pro"
        }
        Free { 
            dependencies {
                compile files('src/Free/libs/admob.jar')
            }
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile fileTree(dir: 'libs', include: '*.jar')
}

原文:
更新时间:2022-08-05 17:08

最满意答案

实现您正在使用的相同算法的更Pythonic方法是使用key函数调用min来替换循环:

closest = min(P, key=lambda p: sum((p - A)**2))

请注意,我使用**进行取幂( ^是Python中的binary-xor运算符)。


A more Pythonic way of implementing the same algorithm you're using is to replace your loop with a call to min with a key function:

closest = min(P, key=lambda p: sum((p - A)**2))

Note that I'm using ** for exponentiation (^ is the binary-xor operator in Python).

相关问答

更多
  • 您可以使用封面树来保存指向您的磁盘数据集的指针。 指针将包含相对记录编号以及来自记录的任何其他信息,以便您遍历树。 You could use the cover tree to hold pointers to your disk dataset. The pointer would contain the relative record number and whatever additional information from the record that allows you to traver ...
  • 您的解决方案很好,但它可以简化,同时提高效率。 如果您正在使用numpy数组,通常情况下,只需几行代码就可以替换那些小的内部for循环。 结果应该更短并且运行得更快,因为numpy使用编译的函数来完成它的工作。 可能需要一些时间来习惯这种编程风格 - 而不是循环遍历数组的每个元素,您可以同时对整个数组进行操作。 这将有助于阅读这个过程的例子; 寻找诸如“如何让XX在numpy中更有效率?”等问题。 以下是NN实现的示例: import numpy as np def NN(A, start): "" ...
  • Q1。 kd树明显效率低下的原因很简单:你要同时测量kd树的构造和查询。 这不是你应该或应该如何使用kd树:你应该只构造一次。 如果仅测量查询,则所花费的时间减少到仅几十毫秒(使用蛮力方法的秒数)。 Q2。 这取决于所使用的实际数据的空间分布和所使用的投影。 根据kd树的实现在平衡构造树的效率方面可能存在细微差别。 如果您只查询单个点,那么结果将是确定性的,并且不受点分布的影响。 使用您正在使用的样本数据(具有强中心对称性)和地图投影(Transverese Mercator),差异应该可以忽略不计。 Q3 ...
  • 与此类似的东西: class CustomDict(dict): def __getitem__(self, key): try: return dict.__getitem__(self, key) except KeyError: closest_key = min(self.keys(), key=lambda x: abs(x - key)) return dict.__getitem__ ...
  • 这是问题所在 tentativeDistance(theNetwork, nodeTable, nearestNeighbour) 应该 x = nearestNeighbour(nodeTable, theNetwork) tentativeDistance(theNetwork, nodeTable, x) 看一下错误,你会看到代码试图迭代一个不可迭代的对象。 这在Python for - in - syntax中是隐含的。 您可能还会考虑重命名变量名称或函数名称以避免混淆。 无论如何,这都是一 ...
  • 这个问题非常广泛,缺少细节。 目前还不清楚你做了什么尝试,你的数据是什么样的,最近邻居是什么(身份?)。 假设您对身份不感兴趣(距离为0),则可以查询两个最近邻居并删除第一列。 这可能是最简单的方法。 码: import numpy as np from sklearn.neighbors import KDTree np.random.seed(0) X = np.random.random((5, 2)) # 5 points in 2 dimensions tree = KDTree(X) ...
  • 找到了这个问题的一个很好的答案。 答案摘要:最近邻居和反向最近邻居不对称。 参考http://graphics.stanford.edu/courses/cs468-06-fall/Papers/19%20reverse%202.pdf Found a great answer to this question. Summary of the answer : The nearest neighbour and reverse nearest neighbour are not symmetric. Ref ...
  • 两条建议:首先,如@YvesDaoust所述,您应该使用编辑距离,也称为Levenshtein距离。 你可以在python-Levenshtein包中找到它。 其次,使用标准库中的unittest或doctest库来测试代码。 使用保存在外部文件中的示例来测试代码是一个坏主意,因为没有访问这些文件的第三个人(例如我们)无法知道输入是什么; 避免打印输出并手动检查它,因为这很慢,容易出错,而且其他人也无法检查。 Two pieces of advice: first, as noted by @YvesDao ...
  • 实现您正在使用的相同算法的更Pythonic方法是使用key函数调用min来替换循环: closest = min(P, key=lambda p: sum((p - A)**2)) 请注意,我使用**进行取幂( ^是Python中的binary-xor运算符)。 A more Pythonic way of implementing the same algorithm you're using is to replace your loop with a call to min with a key ...

相关文章

更多

最新问答

更多
  • python的访问器方法有哪些
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。
  • 响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
  • 在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
  • NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
  • 元素上的盒子阴影行为(box-shadow behaviour on elements)
  • Laravel检查是否存在记录(Laravel Checking If a Record Exists)
  • 设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
  • 想学Linux 运维 深圳有哪个培训机构好一点
  • 为什么有时不需要在lambda中捕获一个常量变量?(Why is a const variable sometimes not required to be captured in a lambda?)
  • 在Framework 3.5中使用服务器标签<%=%>设置Visible属性(Set Visible property with server tag <%= %> in Framework 3.5)
  • AdoNetAppender中的log4net连接类型无效(log4net connection type invalid in AdoNetAppender)
  • 错误:发送后无法设置标题。(Error: Can't set headers after they are sent. authentication system)
  • 等待EC2实例重启(Wait for an EC2 instance to reboot)
  • 如何在红宝石中使用正则表达式?(How to do this in regex in ruby?)
  • 使用鼠标在OpenGL GLUT中绘制多边形(Draw a polygon in OpenGL GLUT with mouse)
  • 江民杀毒软件的KSysnon.sys模块是什么东西?
  • 处理器在传递到add_xpath()或add_value()时调用了什么顺序?(What order are processors called when passed into add_xpath() or add_value()?)
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • SQL查询,其中字段不包含$ x(SQL Query Where Field DOES NOT Contain $x)
  • PerSession与PerCall(PerSession vs. PerCall)
  • C#:有两个构造函数的对象:如何限制哪些属性设置在一起?(C#: Object having two constructors: how to limit which properties are set together?)
  • 平衡一个精灵(Balancing a sprite)
  • n2cms Asp.net在“文件”菜单上给出错误(文件管理器)(n2cms Asp.net give error on Files menu (File Manager))
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的