如何在两种不同的产品口味中使用两个不同版本的GooglePlayServices库?(How To Use Two Different Versions of GooglePlayServices libs in Two Different Product Flavors?)
由于特定于我的应用的原因,我想在两个不同的productFlavors中使用两个不同版本的Google Play服务库。 但是Gradle给了我熟悉的错误信息:
请通过更新google-services插件的版本来修复版本冲突(有关最新版本的信息, 请访问https://bintray.com/android/android-tools/com.google.gms.google-services/ )或将com.google.android.gms的版本更新为10.2.4。
通常我会通过使用一致的GPS库版本来解决这个问题。 但是,在这种情况下,我认为不一致会好,因为我正在将应用程序编译为两种不同的版本。 这不是工作:
应用程序build.gradle
apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion '25.0.2' defaultConfig { applicationId "com.albertcbraun.googleplayservicesversionconflicttestcase" minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { flavor1 { applicationId 'com.albertcbraun.flavor1' } flavor2 { applicationId 'com.albertcbraun.flavor2' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' // these are the problematic lines. GPS versions differ: flavor1Compile 'com.google.android.gms:play-services-identity:10.2.4' flavor2Compile 'com.google.android.gms:play-services-identity:9.6.1' } apply plugin: 'com.google.gms.google-services'
项目build.gradle
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.google.gms:google-services:3.0.0' } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
Gradle版本: 3.3
Android Studio版本: 2.3.1
For reasons particular to my app, I'd like to use two different versions of a Google Play Services library in two different productFlavors. But gradle gives me the familiar error message:
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.2.4.
Normally I'd fix this by using consistent versions of GPS libraries. But, in this case I thought the inconsistency would be ok because I'm compiling the app into two separate flavors. It's not quite working:
app build.gradle
apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion '25.0.2' defaultConfig { applicationId "com.albertcbraun.googleplayservicesversionconflicttestcase" minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { flavor1 { applicationId 'com.albertcbraun.flavor1' } flavor2 { applicationId 'com.albertcbraun.flavor2' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' // these are the problematic lines. GPS versions differ: flavor1Compile 'com.google.android.gms:play-services-identity:10.2.4' flavor2Compile 'com.google.android.gms:play-services-identity:9.6.1' } apply plugin: 'com.google.gms.google-services'
project build.gradle
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.google.gms:google-services:3.0.0' } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
Gradle Version: 3.3
Android Studio Version: 2.3.1
原文:https://stackoverflow.com/questions/43729454
最满意答案
如果我的理解正确,你试图测试是否实例化一个类导致异常。 你只需要这样做:
describe MyClass do it "doesn't raise an exception when instantiated" do expect { subject }.not_to raise_error end end
If I'm understanding correctly, you're trying to test if instantiating a class causes an exception. You would just do this:
describe MyClass do it "doesn't raise an exception when instantiated" do expect { subject }.not_to raise_error end end
相关问答
更多-
正如我可能预料的那样,特别是一旦我发现问题是该行按预期插入但后来不久用UPDATE函数调用,问题就是一些相关的代码。 我将结果作为project_id返回(正如您在上面的代码中看到的那样),并且由于完全不相关的原因(与Blinker信号有关),该方法再次被调用,返回值为project_id ,我已设置从而: project_id = result.inserted_primary_key if result.is_insert else id_ 这一行的正确版本只是略有不同: project_id = r ...
-
为什么只有在调试时才会引发跨线程异常?(Why the cross-threading exception raises only when debugging? [duplicate])[2023-11-19]
只有在调试器附加到进程时,才会检查这些异常,所以在没有调试的情况下运行进程时(或VS之外的独立进程),它们不会显示出来。 这种行为可以通过CheckForIllegalCrossThreadCalls来控制,这是Control类中暴露的一个静态属性。 我强烈建议禁用它,但是这些异常会引发开发人员知道其多线程可能存在非常大的错误( Control派生类不是线程安全的) Those exceptions are only checked is the debugger is attached to the pr ... -
dequeueReusableCellWithIdentifier:引发异常(dequeueReusableCellWithIdentifier: raises an Exception)[2022-03-02]
您是否在Interface Builder中正确设置了正确的标识符字段(它应该是LocalPostsCell )? 另一种可能性是您正在使用不同的表。 通常,使用协议方法中的tableView变量,而不是像self.postsTable那样自己的引用。 您还应该阅读错误消息并查看问题所在。 您可以通过按调试器中的继续按钮获取更多信息。 顺便说一句,你可以隐式检查nil这样你就可以更加简洁。 nameLabel.text = name ? name : @""; descriptionLabel ... -
好的,所以我浏览了wiki并在定义块时看到accessible_by不起作用。 似乎有点奇怪有这个限制,并没有在自述文件中提及它,但至少我知道这是图书馆的限制,而不是我的或瑞安贝茨的代码中的错误。 对于那些感兴趣的人,上面定义我的能力的正确方法如下: # will fail can :index, Product do |product| product && product.approved_at.nil? end # will pass can :index, Product canno ...
-
下载文件会引发异常(Downloading a file raises exception)[2022-05-11]
我认为你可以使用Response.WriteFile,你应该使用你已经创建的FileInfo对象。 码: LinkButton btnTemp = (LinkButton)sender; GridViewRow row = (GridViewRow)btnTemp.NamingContainer; HiddenFieldFullFileName.Value = row.Cells[1].Text; FileInfo file = new Fi ... -
如果我的理解正确,你试图测试是否实例化一个类导致异常。 你只需要这样做: describe MyClass do it "doesn't raise an exception when instantiated" do expect { subject }.not_to raise_error end end If I'm understanding correctly, you're trying to test if instantiating a class causes an e ...
-
这是有效的解决方案,但我试图避免,因为它很丑陋,并且在大多数情况下浪费时间,其中缓存对象没有任何问题。 在某些情况下,GetSerializedRisk需要15秒才能返回,即使返回值是无效登录名或错误请求ID。 Private Function GetMRLDIntegrationService() As Object Const ServiceAddress = "service:mexAddress=""net.tcp://hydfwdvweb001/Integration/MrldIntegr ...
-
发件人必须具有特权或者是登录用户。 所以subhranath@gmail.com应该拥有您所在位置的管理员权限,或者是登录用户来运行您的代码。 最基本的例子就是HTTP发送电子邮件: def get(self): message = mail.EmailMessage(sender='subhranath_app_admin@gmail.com', subject='Email') message.to='any...@gmail.com' message.body = ...
-
您可以捕获异常对象并对其进行检查。 try: res = f(arg1) except TypeError as e: if "f() missing 1 required positional argument" in e.args[0]: res = f(arg1, arg2) else: raise 坦白地说,尽管如此,如果错误发生在f()内部,调试应该不成问题,但是不要花费额外的时间来分类异常应该可以正常工作,因为您应该同时获得原始跟踪和次 ...
-
你的程序的前几行是打开一个套接字发送数据,一切正常。 但sock.recvfrom行没有与之关联的绑定。 换句话说,当你使用UDP发送时,你不应该期望收到任何回应。 如果您想发送消息,然后等待回复(不会自动从远程系统回复),则需要将套接字绑定到侦听端口。 这个网站: https : //wiki.python.org/moin/UdpCommunication有一些很好的参考。 I found solution here Windows UDP sockets: recvfrom() fails with ...