简体   繁体   English

既然 Android Studio 不再创建 R.java,如何找到资源 ID #s?

[英]How to find resource ID #s now that Android Studio no longer creates R.java?

I am trying to debug the following warnings:我正在尝试调试以下警告:

03-13 16:27:13.248 6636-6636/sleepfuriously.com.warningtest W/Resources: Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f09002a}
03-13 16:27:13.248 6636-6636/sleepfuriously.com.warningtest W/Resources: Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f090028}

(26 more similar cut for brevity) (为简洁起见,还有 26 个类似的剪辑)

It looks like I am using some resource as a String which should be something else.看起来我正在使用一些资源作为字符串,它应该是别的东西。 Normally I'd just pull open the R.java file and see what these numbers refer to and voila, there are the problem resources.通常我只是打开 R.java 文件,看看这些数字指的是什么,瞧,有问题的资源。

But the new version of Android Studio bypasses creation of R.java.但是新版本的 Android Studio 绕过了 R.java 的创建。 So I have no way of knowing which resources are causing these warnings.所以我无法知道是哪些资源导致了这些警告。 Any clue on how to debug this?关于如何调试这个的任何线索?

While tedious, you could use the APK Analyzer in Android Studio.虽然很乏味,但您可以在 Android Studio 中使用 APK 分析器。 You can get to this via Build > Analyze APK from the main menu.您可以通过主菜单中的构建 > 分析 APK 来实现。

After choosing your APK, click on the resources.arsc entry in the upper pane.选择您的 APK 后,单击上方窗格中的resources.arsc条目。 This will then give you a lower pane showing you the different resource types.这将为您提供一个较低的窗格,向您显示不同的资源类型。 Selecting a type gives you the resources for that type, including the hex value for the resource ID:选择类型将为您提供该类型的资源,包括资源 ID 的十六进制值:

Android Studio 中的 APK 分析器

There is no search-by-resource-ID option, but you could rummage through the resources and try to find out where these IDs are coming from.没有按资源 ID 搜索选项,但您可以翻阅资源并尝试找出这些 ID 的来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM