TIPS: Android source code usage experience sharing, android Experience Sharing

Source: Internet
Author: User
Tags android sdk manager

TIPS: Android source code usage experience sharing, android Experience Sharing
I believe that many beginners will find the Android development source code on the Internet as often as I do, but it is often annoying to be unable to run it! This problem occurs when collecting App code during sex development websites. I believe that most of the source code on the network will be manually tested before release, and will be released only after normal operation, it must be impossible. How should we solve this problem? First, let's take a look at the causes of this problem. There may be many reasons why a source code cannot run normally. For example, some projects are time-sensitive, in layman's terms, the service that the project previously relied on can be used but cannot be used now. For example, the source code author has disabled the service, or the third-party jar package Built in the software is too old to normally return the data requested by the project, which may cause the project to open and run and report an error, A common phenomenon is that, after running, the interface is stuck in an initialization interface, or the interface will crash. In this case, you must change or block the code that requires online detection or service to solve the problem, the following are some situations where the android source code you downloaded from the Internet cannot be run in eclipse. It is not a solution for errors in the source code running. Next I will teach you how to troubleshoot it one by one.

Is there a problem with the downloaded file?

The solution is to use the decompressed software to open or decompress the file. If any error occurs, download the file again. Or go to another website to find related resources for download.

 

Find out the IDE version

If you are sure that the downloaded compressed package is correct, check whether the compilation Tools are different. Android Developer Tools Build is used for testing in the ideveloper App source code forum: v22.6.2-1085508 (if you do not know how to view the IDE version, please Baidu), in theory, adt22.6 and later versions can be imported to the project on this site. Adt22.6 and below cannot be guaranteed, but you can try to import several more projects to see if they all report errors. If they all report errors, it may be an IDE problem. If you use Android Studio or other tools, please solve the File Import problem on your own.


Check whether the project import is correct

The correct project Import procedure is: Open eclipse --> click File -- select --> Import --> click Existing android under Android... --> Click Browse to find your project. --> click "Finish" to Finish the project. (emphasize that your project must not be placed in the directory of the workspace generated by eclipse for the first time, otherwise, the import will not succeed... ) If you still don't understand it, read the Tutorial: here


SDK build

Many of my friends find one adt on Google's official website or on the Internet. By default, adt on Google's official website only comes with the latest sdk, for earlier versions of the sdk, you must use the Android SDK Manager provided by adt to download the sdk. If you do not know the sdk versions included in your adt, click Window-Preferences-Android (Chinese version: Window-Preferences-Android) in the menu above your adt) check which sdks are available in your environment. The sdks used to test the source code on this site are often used in versions 2.3.7, 4.2.2, and 4.4.2. Most of the old source code is tested using 2.3.7, most of the new source code is 4.4.2. If your sdk does not include 4.4.2 or 4.2.2, you can go to this website to find the sdks for these two versions and find instructions on how to use the downloaded sdks.


Project coding problems

Another problem is to check whether the project code is correct. If the source code you import has a red cross on the source code name, click the folder icon with a Red Cross to find a red cross on the folder icon named src, and open the folder or file with the Red Cross in turn, double-click the java file with an error. In the code editing window, click the Red Square on the right to quickly locate the wrong code line. Check whether the line of code contains garbled characters, right-click your project name and select the last menu Preferences (Chinese version: Preferences) (or click the project name and press the shortcut key Alt + Enter to achieve the same effect ), in the pop-up window, click "Text file encoding" (Chinese Version: Text file encoding) on the right. Select "Other" (Chinese Version: others ), if the GBK is displayed, replace it with UTF-8. If it is UTF-8, replace it with GBK (the two most commonly used encoding in mainland China), and click "OK. The Project will be automatically refreshed several seconds later. Check if the Red Cross is missing. if it still exists, select Project> Clean in the Project menu... -> Clean projects selected below


Dependency missing

Most of the large projects include subprojects or third-party library files. You can right-click your project name and select the last menu Preferences (the Chinese version is called Preferences) (or click the Project name and press the shortcut key Alt + Enter to achieve the same effect). Click the Android menu on the left and two small windows will appear on the right. One is Project Build Target (Project Build version) one is Library. If there is a Red Cross in the Library, place the mouse over this line of path for 2 seconds. The full name of the path will be displayed. Remember the name roughly, and click Add, eclipse will automatically list the libraries you have imported and see if there are any names that are similar to the ones you just noted. Double-click the libraries and add them. Then, Remove the wrong libraries, however, in most cases, there is nothing in the pop-up box after clicking "Add". At this time, you have to find the dependent Library by yourself. The source code of http://bbs.aiyingli.com/#if "librlibrary" is the same. If the source code of the Project is found elsewhere, the Library cannot be found.


Whether the jar package is missing

Many projects use third-party jar packages, but the jar packages used by the author may not be placed under the project directory, resulting in no package, if someone else imports this project, they will go to the Source Path to find this jar package, but the imported person's computer will certainly not have this jar package on this path, you can right-click your project name and select the last menu Preferences (Chinese version: Preferences) (or click the project name and press the shortcut key Alt + Enter to achieve the same effect ), click the Java Build Path menu on the left (Chinese version: Java Build Path). A window with four tabs will appear on the right. Click Libraries (Chinese version: library) in the window, check whether there is a red cross. Click Add JARs to open the project you are working on, and click the libs directory to see if there is a jar package with the same name, if yes, double-click it and select the jar package with a Red Cross. If you don't have one, you can find a way to create this jar. My approach is to search for the jar package name in Baidu to see if the file with the same file name can be found, put it in the libs directory of the project and reference it according to the above method. If you cannot find it, you will be happy. Click OK. The Project will be automatically refreshed several seconds later. Check if the Red Cross is missing. if it still exists, select Project> Clean in the Project menu... -> Clean projects selected below (Chinese version: Project-> clear the selected project below) then, if you select "OK" for the name of the project to be cleaned up, the project cache will be forcibly cleared. Finally, several amazing App source code download sites are recommended: Of course, there are a lot of high-quality code on CSDN, in addition, you can refer to the app source code forum. The above code is very comprehensive and can be run at the same time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.