How do i open a sample Android SDK app in Eclipse

2020-01-30 06:54发布

问题:

I have created a basic program in Eclipse for Android 2.1. then I wanted to look at some of the samples, and import sample projects which are in the SDK directory. I have tried opening a new project and 'create project from existing source', I browse and can select a project, all the details come up and I can click finish, but I receive an error message saying 'could not write file', and if I click on details, it says "access is denied" I have tried copying a project folder into my own workspace but it still does the same thing.

回答1:

Right click in the package explorer window.

Select New -> Other

Under the Android folder select Android Sample Project

Choose the build target and then the sample project



回答2:

In the new android project window there should be three options:

1.  Create new project in workspace
2.  Create project from existing source
3.  Create project from existing sample

(The third one is a bit hidden, as there is a text box, and check box below the second item before the third one.

Select #3, then select the api level you want the sample for (in the list below), then you can select a sample from the now non-grayed out list.



回答3:

This is security issue:

  1. Go to you android SDK directory in my case (windows 7, 64 bit) its "C:\Program Files (x86)"
  2. Right click on Android directory and choose 'properties'.
  3. Go to 'security' tab and click on 'Edit'.
  4. Choose Users from the list and tic on 'full control'.
  5. Apply.


回答4:

1- In Eclipse->Window->Preferences->Android, make sure you have set the SDK Location then Apply and press OK
2- Select File->New->Android Project
3- Click on Create project from existing samples
4- Select the SDK version and select the sample you want



回答5:

Try this in ADT.

File --> New --> Project.. --> Android Sample Project(Inside Android) --> (Select your build target) and finish. If you installed the sample projects, it will show the list of projects. Select and open.



回答6:

If you want to import sample projects into Eclipse, do the following:

  1. Click the File menu on the top left of the Eclipse screen.
  2. Select Import.
  3. In the pop-up menu, select Existing Projects into Workspace.
  4. In the next pop-up menu where it says Select root directory, click the Browse button
  5. Browse to the folder where your sample projects are located. Each project should be inside a folder by itself.
  6. Select the folder.
  7. Click the OK button.

If it is a complete project, it will be imported into Eclipe where you can run it, and modify it if needed.