Downloading Full Sample Apps for Android to Analyze - android

I've been trying to get a sample app off of http://f-droid.org/repository/browse/ for some time. I just want to test the app to see how it works and understand it better. Every time I try to download one though, I click on "source code" and get a screen that looks similar to BitBucket (which I don't know how to download from) or I get a Command Prompt command that gets me the correct code, but the code won't run for one reason or another regarding R.java problems.
The code on the site is supposed to work already so I'm guessing its something I'm doing. I'm just copying the files into my IDE (Motodev Studio) and cleaning the project once I've tried to get rid of what seem like trivial errors. However, when I finish messing with it, the IDE states that R.java cannot be resolved. I know the question as to why that is the case has been asked many times on this site already so I'm just going to assume that the error is with me and not with the IDE. Is there a special way to get these full samples down from the site? Is there a site that is easier to get full samples off of? Please help!

After downloading tar.gz file
untar/unzip the file
In eclipse
File - > Import-> Existing Projects into workspace -> give the path and click browse and then click finish
A folder with project name will be crated in your workspace.
check the project properties by right click on the project and set target for the project
some error will arise due to #override. so remove it
Run the project

You do not mention anything about the sample app you are trying to download and compiler/run. Picking a random example from the page called Abstract Art, there is a Source Code link which takes you to the code repository. From the code repository (In this case Github), you can download a zipped folder with the source code. Unzip and import into your IDE. Motodev Studio should have tutorials that will help you import the code you downloaded and compile.

You are going to need to learn about source control as the various apps on that site either are using git or subversion or mercurial. Each of those version control systems have numerous tutorials so its worth your while to learn about it.
Alternatively download and untar the 'tarball' on each page which should have the source.

Related

Messed up in Eclipse after viewing a sample project

I imported a sample 4.0.3 project and after deleting it from the Project Explorer list every thing is lost, now there are none of the projects that I was working before in Package Explorer??
Moreover now on importing these old project For Example name "On" are coming with the name "OnActivity" but still not able to run.
Else in workspace every file is ok, I tried to CLEAN but still no effect.
I'm new to devlopment kindly guide me.
Recover the source code from your workspace in the Windows file browser. If all attempts to recover fail, you can just create the projects from existing (recovered) code.
And what project are you trying to run? If APIDemo or QAActivity, the log shows you why you can't run them.
And instead of using the Play button (start) to launch, use the dropdown triangle and select the project to run, else the XML will be run (obviously that won't work).
Furthermore, make sure Eclipse knows it's a Android Project you're trying to run.

How do I make a basic App Engine Connected Android Project?

I'm new to this, so please bear with me. I simply want to get the basic App Engine Connected Android Project to work in eclipse.
I first downloaded Eclipse 3.7 and the Android SDK. I installed the ADT plugin through eclipse. I configured eclipse to point to the sdk and created an android project. I added some widgets, messed around with SMS messages, and ran it on my phone. Worked like a charm.
Then I decided it was time to work with app engine. I downloaded the Google plugin for eclipse from within eclipse using this link http://dl.google.com/eclipse/plugin/3.7. I also downloaded the Google App Engine Java SDK from that link.
Ok, here's where it gets more fun. I created a new app engine connected android project and named it "TestProjectThree". I then clicked "Debug as->local app engine connected android project". On the console I got a url, but on my phone I got a black screen. I then noticed that there was nothing in the android/gen folder, so I did a clean build of both projects. Suddenly, it gave me 10 warnings.
"Cannot fully validate context since domain type com.testprojectthree.server.HelloWorldService is not available.
You must run the ValidationTool as part of your server build process."
I googled the problem and found this link http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation.
I began following the instructions. I tried to enable annotation processing, but it was already enabled. I tried to add the requestfactory-apt.jar to the factory path, but it was already there too.
Apparently now I need to run something called an Annotation Processor. I've never used Maven before but I right click on my android project->configure->convert to Maven project. I do a clean build and a POM file appears. I then copy all of the XML from that link to the line right above the /project line in the POM file. I copy the second bit too because I'm using indigo. Clean and build again. New error.
"/TestProjectThree-Android/gen already exists but is not a source folder. Convert to a source folder or rename it."
No idea what that one means either, but I see right click gen->build path->convert to source folder so I click that too. Clean and build again. NO ERRORS!! YAYAYAY!!!
Debug as local app engine connected android project. Got a black screen on the phone, and some sort of error in eclipse. “Source not found”. Looked for a more detailed error message but the console just has the app engine url on it and logcat looks empty.
I went back to the link about the validation tool and read all the comments. A lot of people seemed confused. I have no idea if I did it right, or did any of it right, and am very lost now. Please please please help me!!!
This sounds very similar to a problem I had, although not exactly.
I think the code generated by the AppEngine project that is used by the Android project is either not generated correctly, or needs a refresh.....and clean doesn't do it.
Try this:
First, make sure the requestfactory-apt.jar was in the "Factory Path" of "Annotation Processing" in the "Java Compiler" section of Project Properties.
In AppEngine project.
Properties-> Java Build Path, Source section. Select the ".apt_generated" entry and then "edit…" and rename it, by putting a "1" at the end of the name (or whatever).
Project -> Clean
then in Android Project
Properties-> Java Build Path, Source section.
Select the "apt_generated" source folder that is linked to the ".apt_generated" source folder in the AppEngine project.
"Edit…", then in the first line "Linked Folder Location" navigate to the NEWLY named folder in the AppEngine project (the one with the "1" at the end……)
Then Project -> Clean
Then build & run your Android project, it should now have newly generated RequestFactory code from AppEngine project and validate OK at runtime.
It's possible that closing and opening projects and cleans were also required.
Use parse. I tried using AppEnging for my app's backend, but parse seems to take care of a lot of backend jobs and makes life extremely easy https://parse.com

Error found after importing archive file in eclipse

I am a very beginner in android development using eclipse..
I have given an assignment to modify the android application made by a professor..
so I downloaded the file and imported it to eclipse.
My professor can normally run the program..
however, when I tried to test it before modication using simulator, " the application is forced to stop unexpectedly" is shown..
Moreover, I found that all .java file in src contained "x" ...and the codes in the .java file, like "import android.graphics" or "private class xxx" all contained error..which i have been told that "import andorid.graphics" cannot be resolved..
Could anyone tell me what's wrong with the codes...
and kindly provide me the procedures to fix this problem?
is it possible for me to send the zip file to someone..so that he/she can help me find out the problem??
Make sure the Android sdk and ADT are configured properly in Eclipse and you have updated the relevant packages using SDK Manager. Best way to test this is to create a HelloWorld Android app
http://developer.android.com/sdk/installing.html
Assuming that you have correctly installed the same Android SDK that your professor is using, the first thing to try is to right click on the project name, then select Android > Fix Project Properties.
I've often found that importing existing Android projects into a workspace can be problematic, especially when the project comes from a different machine. A work-around is to create a new Android project, then copy all the sources and resource files into the new project. It's a pain, but it avoids many problems that arise due to different development configurations.

Why does Android Eclipse constantly refresh external folders and take forver?

Just my a new Android phone and I've been tinkering with some basic apps. It's been driving my crazy that the Android plugin for Eclipse refreshes externals folders whenever I save ANYTHING. Normally I wouldn't mind but when it takes 10s to refresh I start to notice.
I already searched and other people have this problem, but there are no solutions.
If it matters, Eclipse 3.5 running on a 64bit jvm on Ubuntu 9.10
If you have references to external sources put them in a zip file:
YourProject->rightClick->Properties->Java Build Path->libraries->..., and then most notably android.jar, but other libs can be the culprit too. Expand it and and select Source attachment, and then (if it doesn't say 'None') press the 'Edit...'-button. If that points to a directory waht you should do is compress that source-directory into a zip file and make the source attachment point to that file.
Apparently eclipse/adt feels the need to refresh sources on the file-system. When they're in a zip-file it seems confident that they have not changed....
You could try disabling "Build automatically" from the Project menu.
First of all Eclipse has a cool feature called a Preferences menu which is located under the window menu located at the top of the screen. Inside there are all sorts settings for pretty much anything you could want to adjust, including the option to turn off Native file system hooks and polling (under General -> Workspace). This is the actual solution to your problem as disabling build automatically doesn't solve the external folders issue, as soon as you build your project it starts right back up with refreshing them. Just keep in mind that if you update your Android SDK at all you will probably need to right click on the root directory of your project and hit refresh after the update finishes.
Secondly, as far as Netbeans is concerned there are at least a half a dozen pages worth of forums posts and various methods for using the Android SDK with it that are also available through Google, I'd give it a look.
I generally do the above step of turning off Automatic build and also try to have not more then 1 open project in my project list.
I myself am fed up of Eclipse from this. Importing a big android project 'ALWAYS' hangs my eclipse and i have to force close it and restart it.
P.S. I really wish google would create an Android plugin for Netbeans =(

When you get a stack trace in Eclipse with SDK classes in the stack, how can you see the SDK sources?

When you are developing an Android application with the Eclipse plugin and debugger, and get a stack trace, you will not see any of the SDK source code. What steps do you need to make to fix this? Assume beginner Java programmer.
To clarify, I want Eclipse to automatically show me the correct source files and lines when I jump into a stack frame. I assume I would need to find the correct SDK sources, put them on my local system and then tell Eclipse how to find and use them. The question is, how exactly do I do these steps.
Thanks to lukehutch on #android IRC channel I got pointed to a blog post that describes how to fix the problem.
The reason why this is even a problem is because Google did not include the sources with the SDK. There is a bug to get this fixed.
The workaround, as described in more detail in the blog post, is to get the sources with git (I specified release-1.0 branch for repo command which I hope corresponds with SDK 1.0-r2), collect all the java source files and put them in the correct directory structure under sources/ directory (which goes right next to your android.jar from the SDK), and refresh the jar in Eclipse at which point you can browse the SDK class sources.
Finally, run your application in the debugger until you get a stack trace from an SDK class, and you will see a button to configure your sources: add the sources directory you created.
The blog link above has a small Python script that can collect all the java files and create the correct directory structure out of them.
If you look at your launch configuration in Eclipse (Debug->Run as...),
you will see a tab called "sources"
If you choose "add" and then supply an archive or file system directory with the relevant sources, the debugger is supposed to allow you to trace into them.
You can get the sources of the SDK from the Android site, just make sure your Jar and your sources version are the same.
Some nice people have now put up the source zips (up to 2.3.3) in a Google Code project, so just do this:
cd path\to\android-sdk\platforms
svn checkout http://fanfq-android-demo.googlecode.com/svn/trunk/android-sdk-src/ .
Then, go into Eclipse, and:
Click on an SDK class and hit F3
Click the "Attach Source" button > External File
Select path\to\android-sdk\platforms\android-x.x.x-y-src.zip
You should now have source visible when hitting F3 on any Android class, and in the debugger etc.

Categories

Resources