简体   繁体   English

无法使教程应用程序正常工作-Android

[英]Cannot get tutorial app to work - Android

So I am following this tutorial to create my first "hello world"-type app and there is something that's not right. 因此,我正在按照本教程来创建我的第一个“ hello world”类型的应用程序,其中有些不正确。

At first everything was working (somewhat). 起初,一切都在工作(某种程度上)。 I was able to successfully add a TextEdit and a Button to my app, compile and debug it on my device. 我能够成功将TextEdit和Button添加到我的应用程序,然后在我的设备上对其进行编译和调试。 But even after precisely following the steps in the tutorial, the button was not aligned as they said it should be. 但是,即使严格按照本教程中的步骤操作,按钮也并没有按照他们所说的对齐。 It was overlapping the TextEdit. 它与TextEdit重叠。 But that's not the main issue. 但这不是主要问题。

Tha main issue is this. 主要问题是这个。 After completing the tutorial, I can no longer compile or debug my app because it throws exceptions: 完成本教程后,我将无法再编译或调试我的应用程序,因为它会引发异常:

Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Notes:compileDebug'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

and: 和:

Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.

Why isn't this working? 为什么这不起作用? I have followed all steps exactly as they're written and I just can't make any sense of it. 我完全按照编写的所有步骤进行操作,但我对此毫无意义。 There are other "First tutorial app problems" on here for the same tutorial but after reading them they all have their own different problems. 对于同一教程,这里还有其他“第一个教程应用程序问题”,但是阅读它们后,他们都有各自不同的问题。

Update 更新

After posting this question, I found anothe link in the related section, saying to run gradlew compileDebug in the root folder command line so I did and it returned: 发布此问题后,我在相关部分找到了anothe链接,说要在根文件夹命令行中运行gradlew compileDebug ,所以我这样做了,然后返回了:

在此处输入图片说明

Based on this information below in the image, does this mean that I should just replace TaskContainer.add() with create() and it'll be fine? 根据图像中的以下信息,这是否意味着我应该将TaskContainer.add()替换为create() ,这样就可以了吗?

As eclipse user I am not familiar with android studio, but according to your screenshot it actually seems to be caused by the deprecated method you're using. 作为eclipse用户,我对android studio不熟悉,但是根据您的截图,它实际上似乎是由您使用的不赞成使用的方法引起的。

I guess you can't "just" replace te name of the method you're using, because create will most likely work a little different. 我猜您不能“仅”替换所用方法的名称,因为create很可能会有所不同。 But yeah, if you work it out to do the same in the end you should be fine. 但是,是的,如果最终进行同样的操作,您应该会很好。

EDIT: 编辑:

Oh, and what I just saw: Did it already work before? 哦,我刚才看到的是:它以前已经起作用了吗? Because if not, look at the error about the missing Java compiler. 因为如果不是,请查看有关缺少的Java编译器的错误。 Look up, how to add this to your HOME Path variable! 查找,如何将其添加到您的HOME Path变量!

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

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