首页 \ 问答 \ 谷歌地图Android V2 - 调试时的空白屏幕(Google Maps Android V2 - Blank Screen When Debug)

谷歌地图Android V2 - 调试时的空白屏幕(Google Maps Android V2 - Blank Screen When Debug)

我有一个奇怪的问题。

我尝试使用Android SDK中的标准Google Maps V2示例。 但我将其导入Android Studio。

我为此示例应用制作了Google API密钥,然后我签署了该应用。

奇怪的是,当我尝试从Android Studio调试我的设备上的应用程序时 - 然后我得到一个空白屏幕而不是地图。 但是当我制作一个签名的apk然后手动将它安装在我的设备上时 - 没关系,我可以看到地图。

调试模式有什么问题?


I have a strange problem.

I try to use standard Google Maps V2 sample from an Android SDK. But I import it to Android Studio.

I made Google API key for this sample app and I signed the app.

Strange is that when I try to debug the app on my device from Android Studio - then I get a Blank Screen instead the map. But when I make a signed apk and then install it on my device manually - it's all right, I can see the map.

What's wrong with the debug mode?


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

最满意答案

tl; dr:您似乎在Groovy的运行时参数重载评估中发现了一个错误。

回答:

map[gString]在运行时通过Groovy的运算符重载机制直接计算为map.getAt(gString) 。 到目前为止,这么好,但现在一切都开始出错了。 Java LinkedHashMap类在其类型层次结构中的任何位置都没有getAt方法,因此Groovy必须使用动态关联的mixin方法(实际上该语句有点颠倒。在类层次结构中使用声明的方法之前, Groovy使用mixin方法。)

因此,长话短说,Groovy解析map.getAt(gString)以使用类别方法DefaultGroovyMethods.getAt() 。 轻松,对吧? 除了这个方法有大量不同的参数重载,其中有几个可能适用,特别是考虑到Groovy的默认参数强制。

不幸的是,Groovy选择DefaultGroovyMethods.getAt(Object,String)而不是选择DefaultGroovyMethods.getAt(Map<K,V>,K) ,这似乎是一个完美的匹配,它将GString键参数强制转换为String 。 由于实际的键实际上是GString ,因此该方法最终无法找到该值。

对我来说真正的杀手是,如果参数重载决策是直接从代码执行的(而不是在运算符解析和类别方法选择之后),那么Groovy会做出正确的重载选择! 也就是说,如果替换此表达式:

map[gString]

用这个表达式:

DefaultGroovyMethods.getAt(map,gString)

然后正确解析参数重载,找到并返回正确的值。


tl;dr: You seem to have discovered a bug in Groovy's runtime argument overloading evaluation.

Answer:

map[gString] is evaluated as map.getAt(gString) at runtime straightforwardly via Groovy's operator overloading mechanism. So far, so good, but now is where everything starts to go awry. The Java LinkedHashMap class does not have a getAt method anywhere in it's type hierarchy, so Groovy must use dynamically associated mixin methods instead (Actually that statement is sort of reversed. Groovy uses mixin methods before using the declared methods in the class hierarchy.)

So, to make a long story short, Groovy resolves map.getAt(gString) to use the category method DefaultGroovyMethods.getAt(). Easy-peasy, right? Except that this method has a large number of different argument overloads, several of which might apply, especially when you take Groovy's default argument coercion into account.

Unfortunately, instead of choosing DefaultGroovyMethods.getAt(Map<K,V>,K), which would seem to be a perfect match, Groovy chooses DefaultGroovyMethods.getAt(Object,String), which coerces the GString key argument into a String. Since the actual key is in fact a GString, the method ultimately fails to find the value.

To me the real killer is that if the argument overload resolution is performed directly from code (instead of after the operator resolution and the category method selection), then Groovy makes the right overload choice! That is to say, if you replace this expression:

map[gString]

with this expression:

DefaultGroovyMethods.getAt(map,gString)

then the argument overloading is resolved correctly, and the correct value is found and returned.

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)