How do i open a sample Android SDK app in Eclipse - android

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.

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

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.

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

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

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.

If you want to import sample projects into Eclipse, do the following:
Click the File menu on the top left of the Eclipse screen.
Select Import.
In the pop-up menu, select Existing Projects into Workspace.
In the next pop-up menu where it says Select root directory, click the Browse button
Browse to the folder where your sample projects are located. Each project should be inside a folder by itself.
Select the folder.
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.

Related

How to switch Workspace in AndroidStudio?

Can't find the option in Android Studio to switch between workspaces like in Eclipse.
Is there only way to add path when creating Project? Or any other way?
you can open a separate window that how it goes in android studio since this is based on IntelliJ IDE,
click on
File-->open-->open and select the project, this will ask you in a window saying do you want to open in new window or same click on new window.
Before start exploring Android Studio please read Project and File Structure
You can try with -> Press Cntrl+Shift+F Then change Directory Location .
Change default save location of projects (or Workspace ) in Android Studio
Just follow this steps given below, because the Android Studio doesn’t work quite like Eclipse does. It's simpler: if you create a project at, say /home/USER/Projects/AndroidStudio/MyApplication from there on all new projects will default to /home/USER/Projects/AndroidStudio. So, your current directory will be your current workspace.
1- Open new project
2- Change project location name by typing and not browse button
3- Next button will appear now
And if you want to change current then rename current directory and reopen that project.

I dont see the option for Android type under create new project in intelliJ

I Installed Android SDK and JDK.
In SDK Manager I installed the packages (Android 5.1.1 API(22), Everything under 'tools' and every thing under'extras').
I open IntelliJ , Click on 'Create New Project' Here i dont see any option for Android...
Screenshot:
http://screencast.com/t/z2yv2HkCi
Also if i go to some project's structure It never show me the option for adding Android SDK..
http://screencast.com/t/z2yv2HkCi (no option to add android SDK)
I am using IntelliJ IDEA 14 Ultimate.
Try to enable 'Android Support' plugin by going to Settings->Plugins->Enable Android Support
Do one of the following:
If you are going to create a new project: click Create New Project on
the Welcome screen or select File | New | Project.
As a result, the New Project wizard opens.
If you are going to add a module to an existing project: open the project you want to add a module to, and select File | New
| Module.
As a result, the New Module wizard opens.
Also check this out :
On the first page of the wizard, in the left-hand pane, select
Android. In the right-hand part of the page, select Gradle: Android
Module. Click Next.
Specify your Android module settings, and click Next.
Specify the settings for your Android-Gradle Foreground
configuration, and click Next.
Select an Android application template from the list, and click
Next.
Specify the settings for the selected Android Activity template, and
click Next.
Specify the name and location settings.
Click Finish.
Also check this out :
How do I set up IntelliJ IDEA for Android applications?

Cannot import com.google. .... why?

I am simply trying to compile and run the example project from: http://developer.android.com/training/location/geofencing.html
I get the following errors:
package com.google.android.gms.common does not exist
package com.google.android.gms.location does not exist
package android.support.v4.app does not exist
I have tried the following already:
I have download Google API already, see screenshot of my SDK Manager window.
I saw different related posts but have not been successful in compiling this yet - even tried restarting computer.
Screenshot of my SDK Window showing Google API Installed: http://postimg.org/image/xf64h3fu3/
You need to add the Android Support library to your project.
http://developer.android.com/tools/support-library/setup.html
"In order to use a Support Library, you must modify your application's project's classpath dependencies within your development environment."
Please find below Steps to need to follow after downloading it:
Right Click on your Project Explorer.
Select New-> Project -> Android Application Project from Existing Code
Browse upto this path only - "C:\Users*your path*\Local\Android\android-sdk\extras\google\google_play_services"
This will add google play service project into eclipse
Now, Right click on your project (not google play service project) and select "Java Build path".
Select Libraries Tab and click on "Add Jars" button. Locate google_play_service project(NOTE: google play service project should not be closed in pkg explorer window) and add libraries from lib folder and click ok.
(if still not appearing libs then follow this steps) Again right click on your project, select properties and select "Android" option.
From left panel, select "Android" option.
Under "Library" section, you will see "Add" button. Click on that button and locate "google-play-services_lib".
Then click on Apply. It will be added to your project. :)

"Selection cannot be launched and there are no recent launches” when Eclipse for Android Project Dev

I am trying to open an unzipped Android Project using Eclipse but every time I try to run or debug it show this error: "selection cannot be launched and there are no recent launches".
So I looked it up and tried creating a new project from an existing source but opens with errors and I open the src etc folders. I also tried importing the project which didn't work either. There are no run as options and changing the run configuration didn't really help. I couldn't find any option to open it as an Android project.
Could you please help me to run this project.
(Since I unzipped this project there is a _MACOSX folder when I import and I am not sure if that matters or should I remove that folder.)
I am running Eclipse Juno SR 2
I had a similar problem. To fix the issue go to Run-> Run Configurations...
If there isn't create a new run configuration (top left)
Under Android tab: browse and select the project you want to run
Under Target tab: select Always prompt to pick device (or) you can pick automatic launch.
Similar solution can be applied to the Debug by going to Run-> Debug Configurations...
Update:
I realize this is beyond the scope of the question but if any new developers are coming to answer then I would suggest switching to Android Studio from Eclipse. AS is the official Google supported IDE for Android development and much nicer to use.
In the Package Explorer (the left column), right-click on the name of the project (the top item). In the menu that appears, select "Run as"; then choose "Android Application".
I fixed it for Version: Luna SR2 (4.4.2)
select run configurations from right side dropdown of run button.
double click on android application.
get changing window, select your project name by browsing button of "android" tap(there are 3 tabs).
from "target" tab select ADT or your device, in which you want to run.
then press "run" at right -bottom button, left-side of "cancel".
after few moment, you will get new windows. from there you can select your connected device or ADT.
If this file is and .apk, you should install it on emulator using following command:
adb install /path/myfile.apk
For more informations, you can chek following link: http://developer.android.com/guide/developing/tools/adb.html#move
Generally this error comes in eclipse IDE when you don't have a main() function in your code.
Check whether your program has public static void main(String [] args) in it or not.
I'm using a mac and this answer is for Kotlin inside Eclipse
I installed Kotlin from Eclipse MarketPlace, clicked the perspective tab , opened Kotlin, created a new Kotlin project named FirstProject and then clicked src and created a Kotlin file named FirstFile (it had the .kt extension) and typed in
func main(args : Array<String>) {
println("Helooooooo")
}
I pressed the green Run button but kept getting this screen.
To fix it, follow these steps:
Right next to that green run button is a drop down arrow, press it then choose Run Configurations
On the left side of the accompanying screen click Kotlin Script Launch Configuration and in the drop down click New_configuration then select Run
After the screen disappeared when I pressed the Run button again I got the same exact "This selection cannot be launched ..." screen. I deleted the project FirstProject and created another one SecondProject > src > Kotlin file > named it SecondFile, typed in the println("Heloooooooo") code and a screen popped up
I choose OK and the project ran fine.
For steps 1 & 2 I also did the same thing and choose Gradle (you can see it the picture) but I don't think that made any difference.

How to run example Android code

I'm going through some of the Android tutorials and am having trouble running on of the example projects. This page explains how to put ads in a project and it links to an example project (http://dl.google.com/googleadmobadssdk/examples/android-banner-essentials.zip). I downloaded the project, but I don't know how to run it. I tried "Import" in Eclipse, but I couldn't find any way to do it. I also tried making a new project, then deleting all the files and replacing them with the files from the example, but then it says "Resource is out of sync with the file system: '/AndroidBannerXML/AndroidManifest.xml'".
In Eclipse :
From the Eclipse menu, click File > New > Project...
From the Select a wizard window, select Android > Android Project from Existing Code, click Next.
From the Import Projets window, set Root directory to where the samples are (normally C:\Android\adt-bundle-windows-x86\sdk\samples\android-17\ ); check Copy projects into workspace; click Finish.
The sample application will appear as a project in the Package Explorer.
Run the package as you would any Android project (Run > Run As, ...).
Ok, in Eclipse, click
File
New
Project
select Android Project
Then check the radio button labeled "Create Project from Existing Source"
Then just browse to the project. It will fill in most of the data needed like API level.
PS: For a good tutorial on adding adds, see the link, there is about 6 videos elling you how to add admob and publish your app.
http://www.youtube.com/user/thenewboston#p/search/0/8IerupLaakE.
try to right click on project and refresh to sync files
If you don’t install any ADB Driver then you need to download it first from the link here : click here:
http://developer.samsung.com/android/tools-sdks/Samsung-Andorid-USB-Driver-for-Windows
Install the driver in you windows.
Now you open your android code and right click on the project you have made or create a new project and make a program that you want to run. I have already made a SilentToggleMode code. Just right click and go to Run As > Run Configurations.
Then you can see a configuration window. You need to expand Android Application > SilentToggleMode. On the right, you go to Target and enable by click Always prompt to pick a device.
After that click Apply from the bottom of the window. Now you can click Run from the window bottom or close the window and click Run from the eclipse menu bar and choose your application. Then you can see a window from which you can choose your android device, you select it and click OK.
You will be happy now to see that your program is running in your device.
For details, Please follow the link below:
Run Android Program on Android Device

Categories

Resources