I encountered a lot of problems in the process of learning Android development. Fortunately, I finally got the solution through online queries. Now, I want to sort out some of the problems I encountered during the Android development process and the solutions as follows.
1. R. java cannot be updated in real time
Problem description: The new variables in the res file cannot be displayed in R. java in real time.
Solution: select "Project" in the menu bar and check the "Build Automatically" option.
2. The LogCat window is not displayed.
Problem description: The LogCat window is not displayed at the bottom right of Eclipse.
Solution: select "Windows" in the menu bar, select "Show View", and then select "LogCat.
3. Solution to the error "android library projects cannot be launched" prompt during compilation
Problem description: The error "android library projects cannot be launched" is prompted during compilation.
Solution: select "Project" in the menu bar, and then select "Properties". In the displayed window, select "Android" to remove the check box before the is library option.
4. After the EditText control is added to the xml file, the message "This text field does not specify an inputType or a hint" is returned.
Problem description: add the EditText control to xml. The control information is as follows.
<EditText
Android: id = "@ + id/editText"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"> </EditText>
During compilation, the message "This text field does not specify an inputType or a hint" is returned.
Cause Analysis: android: hint and android: inputType are missing in the control. Android: hint is used to set the default text prompt information displayed when EditText is null. Android: inputType is used to set the text type of EditText. It is used to help the input method display the appropriate keyboard type.
Solution: Add android: hint and android: inputType information to the control. The added control information is as follows.
<EditText
Android: id = "@ + id/editText"
Android: hint = "0"
Android: inputType = "number"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"> </EditText>
5. How to eliminate the warning message "Hardcoded string" xxx ", shocould use @ string resource"
Problem description: Add a Button control in xml. The control information is as follows.
<Button
Android: id = "@ + id/mButton_mc"
Android: text = "mc"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content">
</Button>
During compilation, the warning "Hardcoded string" mc ", shocould use @ string resource" is displayed.
Cause analysis: the String mc is used in android: text. The String should be defined in String. xml, and then call String. the Resource Name of the string in xml to use the string resource. The advantage of this solution is that it can be completely changed, and it is also useful in supporting multiple languages.
Solution: Add the following information to res> values> String. xml in the project directory.
<Resources>
<String name = "mc"> mc </string>
</Resources>
Then, in the xml using the Button control, use the string by calling the Resource Name of the string, as shown below.
<Button
Android: id = "@ + id/mButton_mc"
Android: text = "@ string/mc"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content">
</Button>
6. How to eliminate the warning message "Nested weights are bad for performance"
Cause Analysis: When the layout is nested, android: layout_weight is used for both the parent layout and sub-layout, but the warning information shown in the figure is displayed if it is not required.
Solution: Remove unnecessary android: layout_weight in the sub-layout based on the actual situation.
7. Solution to the error message "Please ensure that adb is correctly located at: XXXXX" when starting the simulator
Symptom: when the source code is correct, the following error message "Please ensure that adb is correctly located at 'd is displayed when the simulator is started: \ AndroidSDK4.0 \ android-sdk-windows \ platform-tools \ adb.exe 'and can be executed."
Solution: Add D: \ AndroidSDK4.0 \ android-sdk-windows \ platform-tools to the system environment variable PATH.
8. The solution of "Waiting for HOME ('android. process. acore') to be launched..." is always displayed when the simulator is started.
Symptom: When the simulator is started, it cannot be started for a long time (more than five minutes) and the system always prompts "Waiting for HOME ('android. process. acore') to be launched... "Information.
Solution: Delete the current simulator and create a new simulator.