How to run example Android code - android

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

Related

How to run an Android Studio project directly from the Finder?

How to open an Android Studio project from the Finder? I see the below list of files. Is it possible to double-click one of them to get it opened by Android Studio?
Sorry, but there is no one-click run solution like I expect you have with some IDEs like Visual Studio or CodeBlocks.
All you need to do is open your Android Studio and then import a project.
EDIT: I've already run Android project in Android Studio using Terminal (using Ubuntu 14.04LTS). This is my full command:
./android/android-studio/bin/studio.sh workspace/Android/glucosio-android/
Hope you find it useful
You can create command line launcher Tools > Creat Command-line Launcher
If you are using macOS then create an Automator Quick action.
Configure like following
Add a run shell script, then paste /usr/local/bin/studio $#. Make sure pass input is changed to as Arguments.
Save it (say Open with Android studio), then right click on the studio project folder > Quick actions > Open with Android studio. Or if you don't have much quick action this will list in the bottom of the context menu itself.
No, You need import the project from the Android studio.
There isn't a way to open directly from finder. What you need to do is:
On Android Studio go to File Menu -> New... -> Import Project
In Finder, select the ListView_Ex2.iml file.
Right click, and select Get Info
Under Open with: select Other and choose Android Studio, then Always Open With, and click Add.
Click Change All...
You can now double-click any IML file to open that project.

How to create a new PhoneGap Android project in Eclipse "Juno" on Mac?

I recently reinstalled my OS, and used to have a PhoneGap / Android project. Now I want to use it again, so I reinstalled Eclipse and the ADT plug in. So far so good. Now the instructions say:
"Choose New > Android Project"
However, Android Project doesn't show up under new projects, like it used to.
http://www.adobe.com/devnet/html5/articles/getting-started-with-phonegap-in-eclipse-for-android.html
I downloaded phonegap-2.6.0, but perhaps it isn't connected to Eclipse... what do I do at this stage to get Android Project to show up?
If there is no 'Android Project' under the menu it is not about PhoneGap it is maybe about ADT, are you sure you installed it correctly ?
And, also you can create Android Project with PhoneGap by using 'command line', then you just go to the same menu:" New > Project " then choose Android Project with existing source choose the path you created before by command line and that's it.
edit1: Make sure you locate true directory for 'android-sdk-mac_x86'
edit2:this is how you create Android project by using Terminal
/path/to/cordova-android/bin/create /path/to/my_new_cordova_project com.example.cordova_project_name CordovaProjectName
I had a similar problem. For me, Eclipse wouldn't respond when I clicked Finish when importing source from a phonegap project.
I later found that I had mentioned an incorrect path to the android-sdk.
Check if that is your problem.
If it is, here is how you change it:
In Eclipse IDE, click on the Window menu and then Preferences.
A pop-up will be opened.
On the left pane, click on Android (click on it, not on the + sign beside it).
In the field SDK Location, click Browse and point to the location of your android-sdk.
You are done!
Hope that helped.
EDIT:
I am using Eclipse Juno, but the options must hopefully be pretty much the same for other versions too. Please comment if this is incorrect.

how to open projects from developer.android.com?

I downloaded the "LocationAware.zip" from http://developer.android.com/training/basics/location/geocoding.html. How to open this project in Eclipse now?
I would like to open it in Eclipse and then hit run to see how to run this app in the Emulator.
(new to Android - so sorry if the question is too basic)
To run the project you mentioned in Eclipse, hit
- File->New->Project
- Choose "Android Project From Existing Code"
- Choose the root directory, hit finish.
Some extra steps you might need to take care after creating project (if there are errors)
1. Click Project->Clean (so that Resources "R" will be automatically generated)
2. If there are some XML errors, try to change Android Build Target (right click on project folder->Properties->Android)

"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 do i open a sample Android SDK app in Eclipse

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.

Categories

Resources