发表文章

[Java] 2章 Chapter 2[HeadFirstAndroid2ndEdition]

lyvunny 2017-10-9 27

你好

我不知道为什么我的应用程序不希望运行, 即使我把精心的代码在 Android 工作室。

Hello 世界应用程序工作正常, 但一旦我已经取代了网址
android: "http://schemas.android.com/apk/res/android"
xmlns: 工具 = "http://schemas.android.com/tools"
加上添加微调框的代码, 运行应用程序将完成错误。

我不知道为什么, 布局标记根本不被识别。

我使用的是最新版本的 Android 工作室。

原文:

Hi,

I don't know why my app don't want to run even I have put meticulously the code in Android Studio.

The Hello world App works fine, but once I have replaced the URLs by
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
. . . plus the code for adding the Spinner, the Run App finishes with error.

And I don't know why, the LinearLayout tag is not recognized at all.

I'm using the latest version of Android Studio.

相关推荐
最新评论 (12)
croworc 2017-10-9
1

您好@lyvunny,

你能上传你的回购到 GitHub (或谷歌驱动器或任何适合你), 也张贴相关部分与错误信息从 LogCat, 请?
在代码中直接发现错误比猜测报告的症状更容易。
谢谢!

原文:

Hi @lyvunny,

could you upload your repo to GitHub (or maybe Google Drive or whatever suits you) and also post the relevant part with the error message from LogCat, please?
Its easier to spot an error directly in the code than guessing from reported symptoms.
Thanks!

lyvunny 2017-10-9
2

您好@croworc
谢谢你的回信。正如你可以看到我是新的 Android 开发, 那么我不知道什么是 LogCat。你能详细说明一下吗?否则我会附上代码和截图。顺便说一下, 代码是完全一样的书。所以我想我有一个问题, 我的 Android 工作室配置。它是如此令人沮丧, 因为我理解的代码在书中, 但我不知道为什么它不运行。欢呼!

原文:

Hi @croworc
Thanks for your reply. As you can see I'm new in Android dev, then I don't know what is LogCat. Could you elaborate please ? Otherwise I'm going to attach code and screenshots. By the way the code is exactly the same as the book. So I guess I have a problem with my Android Studio Configuration. It's so frustrating because I understand the code in the book but I don't know why it doesn't run. Cheers !

dogriffiths 2017-10-9
3

你好,

你有什么错误?

dg

原文:

Hello,

What error do you get?

DG

croworc 2017-10-9
4

您好@lyvunny,
没有汗水-我们都有点 "新" 的 Android, 只是因为它的发展如此之快, 一旦你学会了一些东西, 他们已经想出了一些新的, 伟大的, 闪亮的, 像建筑组件!
:-)

好的, Logcat 是 Android 工作室内置日志设备/监视器的名称。您将在 Android 工作室 "工具窗口栏" 的底部 (默认情况下) 找到其窗口面板的选项卡:
androidstudiologcat
在这里你会发现所有的警告-, 错误, 信息, 调试消息, 每个运行的应用程序或 Android 本身可能要记录。在本书中, 您将学习如何利用它, 从您自己的应用程序中。这是一个非常有用的工具!

如果应用程序在运行时遇到错误, 通常会在此处找到导致错误的堆栈跟踪。
在 Logcat 的右上角, 您将找到一个下拉框, 它允许您过滤这些日志输出的源 (因为通常会有很多, 从其他运行的应用程序以及操作系统)。

当您在中生成和运行项目时, 它应该默认为 "只显示选定的应用程序", 即您的应用程序。
logcatsourcefilter

另一方面, 编译时错误将被生成系统 (即 Gradle) 输出到 Messages 窗口中, 在工具窗口栏的底部默认情况下, 您还将发现该选项卡。
点击一个错误会让你在源代码中的相应行。
gradlebuilderror

祝你好运!

原文:

Hi @lyvunny,
no sweat - we're all somewhat "new" to Android, just because its evolving so fast that once you've learned something, they've already come up with something new, great and shiny, like Architecture Components!
:-)

OK, Logcat is the name for Android Studios built-in logging facility/monitor. You'll find the tab for its window panel at the bottom (by default) of the Android Studio "tool window bar":
androidstudiologcat
Here you'll find all the warning-, error-, info-, debug-messages that every running app or Android itself might want to log. You'll learn somewhat later in the book how to make use of it, from within your own apps. It's a really helpful tool!

If your app encounters an error while its running, you'll typically find the stack trace that led to the error here.
In Logcat's upper right corner, you'll find a dropdown box that allows you to filter the source of these log outputs (because typically, there will be quite many, from other running apps as well as from the OS).

When you build and run your project in AS, it should default to "Show only selected application", i.e. your app.
logcatsourcefilter

Compile time errors, on the other hand, will be spit out by the build system (i.e. Gradle) into the Messages window, the tab for which you'll also find by default at the bottom of the tool window bar.
Clicking on an error there will get you into the respective line right in your source code.
gradlebuilderror

Good luck!

dogriffiths 2017-10-9
5

您能否将版式文件的内容粘贴到此处?

原文:

Could you paste the contents of your layout file here?

lyvunny 2017-10-9
6

嗨, 格里菲斯先生,

首先, 即使我开始你的书, 我很喜欢它。不幸的是我被阻止了:-)

我将在这里附上所有的信息, 我可以提供, 但我不在家。那我会尽快的

谢谢你的关心

原文:

Hi mr Griffiths,

First, even if I'm starting your book, I like it very much. Unfortunately I'm blocked :-)

I'm going to attach here all the informations I can provide, but I'm not at home. Then I'll do it as soon as possible.

Thanks for your interest.

lyvunny 2017-10-9
7

这是我的文件夹..。
BeerAdviser 邮编
linearlayout
在布局, 我们可以看到不承认布局
beer adviser has stopped since you click on run app
messages gradle build
运行 message.txt
真奇怪我找不到 logcat..。

原文:

This my folders . . .
BeerAdviser.zip
linearlayout
In the linearlayout.jpg we can see AS doesn't recognized LinearLayout
beer adviser has stopped since you click on run app
messages gradle build
run message.txt
It's Strange. I don't find the logcat . . .

lyvunny 2017-10-9
8

我终于找到了 logcat
Logcat.txt

原文:

Finally I've found the logcat
Logcat.txt

lyvunny 2017-10-9
9

还行。最后, 我找到了它不起作用的原因。我很惭愧我想躲在洞里微调框未正确写入。没有大写的微调框。没有提到这个标签的问题。这就是为什么我认为这是一个不同的问题, 直到我发现 logcat 感谢@croworc。非常感谢您@croworc !!!

顺便问一下, 我不明白为什么布局在红色下划线, 为什么在这一时刻, 网址是不被接受的..。奇怪.但这是一个幸福的结局。

原文:

Ok. Finally I have found the reason why it didn't work. I'm ashamed. I want to hide in a hole. Spinner was incorrectly written. spinner without upper case. AS didn't mention a problem with this tag. That's why I thought it was a different problem until I have discovered logcat thanks to @croworc. Thank you very much @croworc !!!

By the way, I don't understand why LinearLayout was underlined in red, and why for during one moment the urls was not accepted. . . Strange. But it's a happy end.

lyvunny 2017-10-9
10

原因: java.lang.ClassNotFoundException: 在 Logcat 没有找到 "android.view.spinner" 类。

原文:

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.spinner" in Logcat.

croworc 2017-10-9
11

@lyvunny
抓得好!这当然是困难的, 因为你刚刚开始与 android 的android 工作室!帽子小费!

顺便说一句: 看着你的屏幕打印, 我注意到你已经在文件夹中使用你的布局
BeerAdviser/app/build/intermediates/res/merged/debug/layout/activity_find_beer.xml
但是, 这是一个 Gradle 将生成中间文件的路径, 这不是您将使用布局文件的位置。生成的文件将在生成时生成, 您的更改将被丢弃!
您的版式文件位于:
BeerAdviser/app/src/main/res/layout

在一旁注意: 当前版本的 Android 工作室是:
Android Studio 3.0 Beta 5
快乐编码!
:-)

原文:

@lyvunny
Good catch! That was certainly difficult, given that you're just starting out with Android and Android Studio! Hat Tip!

Btw: Looking at your screen prints, I noticed that you've been working with your layout in folder
BeerAdviser/app/build/intermediates/res/merged/debug/layout/activity_find_beer.xml
This, however, is a path where Gradle will generate intermediate files - this isn't the location where you will work with your layout file(s). Generated files will be re-generated upon builds and your changes there would be discarded!
Your layout file(s) are located in:
BeerAdviser/app/src/main/res/layout

On a side note: the current version of Android Studio is:
Android Studio 3.0 Beta 5
Merry coding!
:-)

dogriffiths 2017-10-9
12

很高兴你把它分类:-)。谢谢 Ingo!

原文:

Glad you got it sorted :-). And thanks Ingo!

返回
发表文章
lyvunny
文章数
1
评论数
6
注册排名
60727