Java 如何避免在运行我的第一个 Android 应用程序时发生错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22280434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 14:43:18  来源:igfitidea点击:

how can i free from errors occurred while running my first android app?

javaandroid

提问by user3398035

i'm getting errors while running my first app on real device in eclipse.I 've enabled USB Debugging on my device and pressed "RUN AS" in eclipse then i got 7 errors

我在 eclipse 中在真实设备上运行我的第一个应用程序时遇到错误。我在我的设备上启用了 USB 调试并在 eclipse 中按下了“RUN AS”然后我得到了 7 个错误

Description Resource    Path    Location    Type
Invalid layout param in a LinearLayout: layout_alignParentTop   abc_action_bar_decor_overlay.xml    /appcompat_v7/res/layout    line 32 Android Lint Problem
Wrong orientation? No orientation specified, and the default is horizontal, yet this layout has multiple children where at least one has layout_width="match_parent"    abc_action_bar_decor_overlay.xml    /appcompat_v7/res/layout    line 25 Android Lint Problem
The following unrelated icon files have identical contents: abc_textfield_search_selected_holo_dark.9.png, abc_textfield_search_selected_holo_light.9.png   abc_textfield_search_selected_holo_light.9.png  /appcompat_v7/res/drawable-mdpi line 1  Android Lint Problem
The resource R.dimen.abc_search_view_preferred_width appears to be unused   dimens.xml  /appcompat_v7/res/values    line 53 Android Lint Problem
The resource R.bool.abc_action_bar_expanded_action_views_exclusive appears to be unused bools.xml   /appcompat_v7/res/values    line 19 Android Lint Problem
The resource R.integer.abc_max_action_buttons appears to be unused  dimens.xml  /appcompat_v7/res/values    line 22 Android Lint Problem
The following unrelated icon files have identical contents: abc_list_pressed_holo_dark.9.png, abc_list_pressed_holo_light.9.png abc_list_pressed_holo_light.9.png   /appcompat_v7/res/drawable-hdpi line 1  Android Lint Problem
The resource R.bool.abc_action_bar_embed_tabs_pre_jb appears to be unused   bools.xml   /appcompat_v7/res/values    line 18 Android Lint Problem
The resource R.dimen.abc_action_bar_stacked_tab_max_width appears to be unused  dimens.xml  /appcompat_v7/res/values    line 27 Android Lint Problem
The resource R.layout.abc_action_bar_tab appears to be unused   abc_action_bar_tab.xml  /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.dimen.abc_action_bar_stacked_max_height appears to be unused dimens.xml  /appcompat_v7/res/values    line 44 Android Lint Problem
Nested weights are bad for performance  abc_search_view.xml /appcompat_v7/res/layout    line 90 Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_search_view.xml /appcompat_v7/res/layout    line 64 Android Lint Problem
Use a layout_width of 0dip instead of wrap_content for better performance   abc_search_view.xml /appcompat_v7/res/layout    line 78 Android Lint Problem
The resource R.layout.abc_list_menu_item_icon appears to be unused  abc_list_menu_item_icon.xml /appcompat_v7/res/layout    line 1  Android Lint Problem
The abc_list_divider_holo_dark.9.png icon has identical contents in the following configuration folders: drawable-hdpi, drawable-mdpi   abc_list_divider_holo_dark.9.png    /appcompat_v7/res/drawable-mdpi line 1  Android Lint Problem
Nested weights are bad for performance  abc_search_view.xml /appcompat_v7/res/layout    line 80 Android Lint Problem
Attribute is missing the Android namespace prefix   abc_search_dropdown_dark.xml    /appcompat_v7/res/drawable  line 19 Android Lint Problem
The resource R.anim.abc_fade_out appears to be unused   abc_fade_out.xml    /appcompat_v7/res/anim  line 1  Android Lint Problem
The resource R.layout.abc_action_bar_view_list_nav_layout appears to be unused  abc_action_bar_view_list_nav_layout.xml /appcompat_v7/res/layout    line 1  Android Lint Problem
Use a layout_width of 0dip instead of wrap_content for better performance   abc_search_view.xml /appcompat_v7/res/layout    line 54 Android Lint Problem
The resource R.layout.abc_action_bar_decor appears to be unused abc_action_bar_decor.xml    /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.anim.abc_slide_out_top appears to be unused  abc_slide_out_top.xml   /appcompat_v7/res/anim  line 1  Android Lint Problem
The resource R.layout.abc_action_menu_layout appears to be unused   abc_action_menu_layout.xml  /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.anim.abc_slide_in_bottom appears to be unused    abc_slide_in_bottom.xml /appcompat_v7/res/anim  line 1  Android Lint Problem
The resource R.layout.abc_action_mode_bar appears to be unused  abc_action_mode_bar.xml /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.layout.abc_action_bar_title_item appears to be unused    abc_action_bar_title_item.xml   /appcompat_v7/res/layout    line 1  Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_action_bar_title_item.xml   /appcompat_v7/res/layout    line 25 Android Lint Problem
The following unrelated icon files have identical contents: abc_textfield_search_right_selected_holo_dark.9.png, abc_textfield_search_right_selected_holo_light.9.png   abc_textfield_search_right_selected_holo_light.9.png    /appcompat_v7/res/drawable-xhdpi    line 1  Android Lint Problem
The resource R.layout.abc_expanded_menu_layout appears to be unused abc_expanded_menu_layout.xml    /appcompat_v7/res/layout    line 1  Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_activity_chooser_view_include.xml   /appcompat_v7/res/layout    line 54 Android Lint Problem
Duplicate id @+id/image, already defined earlier in this layout abc_activity_chooser_view_include.xml   /appcompat_v7/res/layout    line 55 Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_activity_chooser_view_include.xml   /appcompat_v7/res/layout    line 31 Android Lint Problem
"action_settings" is not translated in af, am, ar, bg, ca, cs, da, de, el, en-rGB, en-rIN, es, es-rUS, et-rEE, fa, fi, fr, fr-rCA, hi, hr, hu, hy-rAM, in, it, iw, ja, ka-rGE, km-rKH, ko, lo-rLA, lt, lv, mn-rMN, ms-rMY, nb, nl, pl, pt, pt-rPT, ro, ru, sk, sl, sr, sv, sw, th, tl, tr, uk, vi, zh-rCN, zh-rHK, zh-rTW, zu   strings.xml /MyFirstApp/res/values  line 5  Android Lint Problem
The following unrelated icon files have identical contents: abc_textfield_search_right_selected_holo_dark.9.png, abc_textfield_search_right_selected_holo_light.9.png   abc_textfield_search_right_selected_holo_light.9.png    /appcompat_v7/res/drawable-mdpi line 1  Android Lint Problem
"app_name" is not translated in af, am, ar, bg, ca, cs, da, de, el, en-rGB, en-rIN, es, es-rUS, et-rEE, fa, fi, fr, fr-rCA, hi, hr, hu, hy-rAM, in, it, iw, ja, ka-rGE, km-rKH, ko, lo-rLA, lt, lv, mn-rMN, ms-rMY, nb, nl, pl, pt, pt-rPT, ro, ru, sk, sl, sr, sv, sw, th, tl, tr, uk, vi, zh-rCN, zh-rHK, zh-rTW, zu  strings.xml /MyFirstApp/res/values  line 4  Android Lint Problem
"hello_world" is not translated in af, am, ar, bg, ca, cs, da, de, el, en-rGB, en-rIN, es, es-rUS, et-rEE, fa, fi, fr, fr-rCA, hi, hr, hu, hy-rAM, in, it, iw, ja, ka-rGE, km-rKH, ko, lo-rLA, lt, lv, mn-rMN, ms-rMY, nb, nl, pl, pt, pt-rPT, ro, ru, sk, sl, sr, sv, sw, th, tl, tr, uk, vi, zh-rCN, zh-rHK, zh-rTW, zu   strings.xml /MyFirstApp/res/values  line 6  Android Lint Problem
Attribute is missing the Android namespace prefix   abc_search_dropdown_light.xml   /appcompat_v7/res/drawable  line 19 Android Lint Problem
This tag and its children can be replaced by one <TextView/> and a compound drawable    abc_activity_chooser_view_list_item.xml /appcompat_v7/res/layout    line 26 Android Lint Problem
This LinearLayout layout or its LinearLayout parent is useless  abc_activity_chooser_view_list_item.xml /appcompat_v7/res/layout    line 26 Android Lint Problem
The resource R.layout.abc_popup_menu_item_layout appears to be unused   abc_popup_menu_item_layout.xml  /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.layout.abc_activity_chooser_view_list_item appears to be unused  abc_activity_chooser_view_list_item.xml /appcompat_v7/res/layout    line 1  Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_activity_chooser_view_list_item.xml /appcompat_v7/res/layout    line 31 Android Lint Problem
The resource R.layout.abc_activity_chooser_view appears to be unused    abc_activity_chooser_view.xml   /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.layout.abc_search_dropdown_item_icons_2line appears to be unused abc_search_dropdown_item_icons_2line.xml    /appcompat_v7/res/layout    line 1  Android Lint Problem
The following unrelated icon files have identical contents: abc_list_pressed_holo_dark.9.png, abc_list_pressed_holo_light.9.png abc_list_pressed_holo_light.9.png   /appcompat_v7/res/drawable-xhdpi    line 1  Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_action_mode_close_item.xml  /appcompat_v7/res/layout    line 27 Android Lint Problem
The resource R.layout.abc_action_mode_close_item appears to be unused   abc_action_mode_close_item.xml  /appcompat_v7/res/layout    line 1  Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_search_dropdown_item_icons_2line.xml    /appcompat_v7/res/layout    line 49 Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_search_dropdown_item_icons_2line.xml    /appcompat_v7/res/layout    line 29 Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_search_dropdown_item_icons_2line.xml    /appcompat_v7/res/layout    line 38 Android Lint Problem
The resource R.layout.abc_action_bar_decor_overlay appears to be unused abc_action_bar_decor_overlay.xml    /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.layout.abc_search_view appears to be unused  abc_search_view.xml /appcompat_v7/res/layout    line 1  Android Lint Problem
The following unrelated icon files have identical contents: abc_list_pressed_holo_dark.9.png, abc_list_pressed_holo_light.9.png abc_list_pressed_holo_light.9.png   /appcompat_v7/res/drawable-mdpi line 1  Android Lint Problem
Possible overdraw: Root element paints background ?attr/actionBarItemBackground with a theme that also paints a background (inferred theme is @style/AppTheme)  abc_action_bar_home.xml /appcompat_v7/res/layout    line 21 Android Lint Problem
The resource R.dimen.abc_config_prefDialogWidth appears to be unused    config.xml  /appcompat_v7/res/values    line 28 Android Lint Problem
The resource R.layout.abc_list_menu_item_checkbox appears to be unused  abc_list_menu_item_checkbox.xml /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.anim.abc_slide_out_bottom appears to be unused   abc_slide_out_bottom.xml    /appcompat_v7/res/anim  line 1  Android Lint Problem
The resource R.layout.support_simple_spinner_dropdown_item appears to be unused support_simple_spinner_dropdown_item.xml    /appcompat_v7/res/layout    line 1  Android Lint Problem
The abc_list_divider_holo_light.9.png icon has identical contents in the following configuration folders: drawable-hdpi, drawable-mdpi  abc_list_divider_holo_light.9.png   /appcompat_v7/res/drawable-mdpi line 1  Android Lint Problem
The resource R.bool.abc_config_allowActionMenuItemTextWithIcon appears to be unused config.xml  /appcompat_v7/res/values    line 23 Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_list_menu_item_icon.xml /appcompat_v7/res/layout    line 17 Android Lint Problem
The resource R.layout.abc_list_menu_item_radio appears to be unused abc_list_menu_item_radio.xml    /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.layout.abc_action_menu_item_layout appears to be unused  abc_action_menu_item_layout.xml /appcompat_v7/res/layout    line 1  Android Lint Problem
The resource R.layout.abc_list_menu_item_layout appears to be unused    abc_list_menu_item_layout.xml   /appcompat_v7/res/layout    line 1  Android Lint Problem
This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) MyFirstApp      line 1  Android Lint Problem
The resource R.anim.abc_fade_in appears to be unused    abc_fade_in.xml /appcompat_v7/res/anim  line 1  Android Lint Problem
The resource R.string.abc_shareactionprovider_share_with appears to be unused   strings.xml /appcompat_v7/res/values    line 46 Android Lint Problem
The resource R.string.abc_activitychooserview_choose_application appears to be unused   strings.xml /appcompat_v7/res/values    line 40 Android Lint Problem
Missing the following drawables in drawable-xhdpi: abc_ic_clear_normal.png (found in drawable-hdpi, drawable-mdpi)  MyFirstApp      line 1  Android Lint Problem
The resource R.anim.abc_slide_in_top appears to be unused   abc_slide_in_top.xml    /appcompat_v7/res/anim  line 1  Android Lint Problem
The resource R.string.abc_shareactionprovider_share_with_application appears to be unused   strings.xml /appcompat_v7/res/values    line 44 Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_action_bar_decor_overlay.xml    /appcompat_v7/res/layout    line 47 Android Lint Problem
The resource R.bool.abc_config_showMenuShortcutsWhenKeyboardPresent appears to be unused    bools.xml   /appcompat_v7/res/values    line 22 Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_action_bar_home.xml /appcompat_v7/res/layout    line 22 Android Lint Problem
The resource R.bool.abc_split_action_bar_is_narrow appears to be unused bools.xml   /appcompat_v7/res/values    line 20 Android Lint Problem
The resource R.layout.abc_action_bar_tabbar appears to be unused    abc_action_bar_tabbar.xml   /appcompat_v7/res/layout    line 1  Android Lint Problem
[Accessibility] Missing contentDescription attribute on image   abc_action_bar_home.xml /appcompat_v7/res/layout    line 29 Android Lint Problem
The resource R.string.abc_action_bar_up_description appears to be unused    strings.xml /appcompat_v7/res/values    line 23 Android Lint Problem
The resource R.string.abc_action_bar_home_description appears to be unused  strings.xml /appcompat_v7/res/values    line 21 Android Lint Problem
The resource R.string.abc_activity_chooser_view_see_all appears to be unused    strings.xml /appcompat_v7/res/values    line 42 Android Lint Problem
The resource R.string.abc_action_menu_overflow_description appears to be unused strings.xml /appcompat_v7/res/values    line 25 Android Lint Problem

回答by aprados

It seems that you have selected to create a project API 10 compatible (appcompat_v7 in your log).

您似乎已选择创建一个与 API 10 兼容的项目(日志中为 appcompat_v7)。

Be sure that Eclipse creates two folders in the project tree (nameofyourproject and appcompat_v7). If appcompat_v7 exists, you only have to select properties (right button in nameofyourproject folder / properties), then to Android and finally add appcompat_v7 project.

确保 Eclipse 在项目树中创建了两个文件夹(nameofyourproject 和 appcompat_v7)。如果 appcompat_v7 存在,你只需要选择属性(在你的项目文件夹名称/属性中的右键),然后到 Android 最后添加 appcompat_v7 项目。

Clean your bild (project/clean) and... it should be ok.

清洁您的图片(项目/清洁)并且...应该没问题。

If this doesn't work, please, verify Window/Android SDK Manager (install all the needed packets).

如果这不起作用,请验证 Window/Android SDK Manager(安装所有需要的数据包)。

Good luck!

祝你好运!

回答by Ewoks

Most of the errors here are coming from Lint.. They will not break the app but those are errors that you should correct before release. If you want to run app despite those errors, turn Lint checkoff for project for a moment but don't forget to fix these issues. Clean project will remove reported Lint errors.

这里的大多数错误都来自Lint.. 它们不会破坏应用程序,但这些是您应该在发布前更正的错误。如果您想在出现这些错误的情况下运行应用程序,暂时关闭项目的Lint 检查,但不要忘记修复这些问题。Clean 项目将删除报告的 Lint 错误。