Trouble with Android tutorial

六月ゝ 毕业季﹏ 提交于 2020-01-06 06:42:30

问题


I think the people who write the tutorials forget that the people reading them are new to the topic. We're supposed to learn about those by stepping through things, but if something goes wrong we don't know where to look for the error.

I have Windows 7 Pro, I have not attempted any eclipse development for android on this machine (though I use eclipse for other things). I downloaded the Android tutorial just now, installed it with defaults (I doubled the memory size from 2G to 4G on whatever component that was) and told it to start up after it had installed. "Help / About" says it's "Android Studio 1.3.1".

I followed the tutorial instructions for creating a new project, changing the names of the couple of files where it indicated. When I attempt to run it, the log file at the bottom of the AS window says:

Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widge.Button.Inverse'.

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

On poking around, I seed that the "MyActivity.java" file is underlined in red, and there are three references in it to "R", also red. If I hover over any one, it says it cannot resolve that symbol.

I also found a file named "v23\values-v23.xml" that has red text for what look like a couple of android components; one of them is the following:

<style name="Base.Widget.AppCompat.Button.Colored" parent="android:Widget.Material.Button.Colored"/>

and the value for 'parent' is underlined in red. Since this looks like it indicates an error with something called "parent" and my runtime error message says "parent", it seems logical they're related.

But I don't know where to go from there. I vaguely remember an instruction to download an Android SDK, but thought that was included with Android Studio (can't imagine why it wouldn't be). It was called the "Android Studio SDK Bundle", I figured that included what was needed.

Other SO questions on the subject are evidently too old, saying to click on menu options that no longer exist, etc., or say things like "open the gradle file" and I can't find one, or "be sure your target project version is set to 11", and I don't have any idea what that is or where to find it.

Please be explicit about menus to use and options to click on; remember that, though I'm an experienced Java programmer, I've not used IntelliJ and I've not programmed on Android, so I don't know the names of things specific to either environment.


回答1:


Daniel Nugent called this shot: at the bottom of the left-hand pane is an option called "Gradle Scripts". My first one was named build.gradle (Project: MyFirstApp), and my second build.gradle (Module: app). Double-clicked on the second one and changed "compileSdkVersion 22" to "compileSdkVersion 23", then attempted a rebuild which failed. The question Daniel Nugent referred to also mentions ensuring I have "Android M libraries" and points to a button on the Toolbar to start the SDK manager; that showed that an update "was available" for Android 5.1 (Lollipop). I couldn't figure out how to update from that window; I guessed at clicking on a link in that window (at the bottom) saying "Launch Standalone SDK Manager", and updated from there (which took a LONG time - 15-20 minutes).

Then the rebuild on Gradle succeeded and running the application (which took perhaps a minute or a minute and a half, longer than I expected) produced the expected window to pick a device, etc. The emulator then ran the "Hello, World" app as desired.

My thanks to all who responded; now if I can just figure out what's wrong with the debug driver for my Galaxy s5...



来源:https://stackoverflow.com/questions/32158274/trouble-with-android-tutorial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!