Attempting Android Notepad Tutorial - Exercise 1 - More problems - android

This maybe a continuation from 2 of my previous question, or maybe it's a completely unconnected problem.
Previous questions were
Questions on Notepad Tutorial:
Can't read ... AndroidManifest.xml - while attempting Android Notepad Tutorial - Exercise 1
The tutorial asked you to select "Create project from existing source". My 1st original question was where to copy the template (original source) to and from the answers I received, It looks like I should copy the directory-structure/source under the C:/Development/Eclipse/ directory, so it would look like this
_ C:/Development/Eclipse/Notepadv1/... _
I did that, and then tried to continue the tutorial, but when I got to the part that says to select "Create project from existing source", I received a pair of errors
C:\Andriod\Andriod-SDK-Windows\AndroidManifest.xml: java.io.FileNotFoundException: C:\Andriod\Andriod-SDK-
(Same error prints twice in the Console & WorkSpaceLog
So I posted a second question about the FileNotFoundException:, and received an answer saying to ignore the message, happens all the time... so I deiced to plow forward again. Now I have 2 problem. One of the problems may well be of my own doing, trying to run threw this tutorial dozens of times, and attempting to back out my changes over and over again.
Problem # 1:
I once again start to create the Notepadv1 project using "Create Project from Existing Source" (The cant-read-androidmanifest-xml error still appears), but as suggested I just ignore it. I next select "Android 1.5/Platform 1.5 as the Build Target, BUT the field where you enter the Min SDK Version is grayed out, and you can't enter the number 3 there.. The tutorial says to put the number there, but it seems to become grayed out at the same time I select "Create Project from Existing Source" and get the "cant-read-androidmanifest-xml" error.
Problem # 2:
If I click on [Next] twice, or [Finish] once, I get a pop up box with the message "Invalid project description" - - "Reason: Invalid project description"
[Details>>] "Invalid project description.
C:\Development\Eclipse\Notepadv1 overlaps the location of another project: 'Notepadv1'
".
This did not originally happen. There is no mention of the "Notepadv1" in the Package Explorer or Navigator windows, so I can't find any way to remove it, and I have run Clean Projects, exited eclipse and rebooted the machine a few time... in a few different ways.
Any suggestions? Joe
P.S. I have not yet accept any of the answers to my last question, because the juries still out. I'm not yet sure they were correct. I'll will make sure I go back and accept an answers, once I figure out what the correct answer is - Joe

I had the same issue, and just got it working!
I have no idea how to fix, I'm still getting the error, but It's not hindering me from continuing, so I'm not worried about it.
Is very simple, you shouldn't have copied the Notepadv1 directory into your C:/Development/Eclipse directory, because, when you "Create project from existing source" it copies it there for you. So, the one it's trying to copy from is getting in the way of where it's trying to copy to.
Hopefully that makes sense, and helps.

Problem 1 is because the androidmanifest.xml is missing.
Problem 2 Notepadv1 already exists in your workspace.
If I were you I would change your workspace to your Documents/My Documents or equivilant folder depending on your OS. You can do that under File->Switch Workspace->Other. Then delete what you have under the Eclipse directory. It could get messy if you update Eclipse or have multiple versions of Eclipse.
Where is this Notepad project? Is is part of the SDK? If it is I would use File->Import to copy over to your workspace rather than mess with the SDK copy. That is probably why the manifest is missing.
If you would like more help let me know.
PS. You will probably want to reinstall the SDK if the Notepad manifest is missing.
EDIT:
#Joe. I couldn't say why other tutorials worked and others didn't for definite but using the SDK as a workspace is definitely going to end up being programmatic when you are learning. My SDK is separate from my workspace. So, in a brief summary, I would keep the SDK, the Eclipse source and your project workspace in entirely different locations. And we can start from there if you want more help.

Very Simple, you need to clear the workspace... to do this adopt following 2 steps
Right click on your project and select Android Tools and now select Fix project properties
Select Project from menu and now click on clean.
This will work for sure

Re: problem #2...
My apologies if it's inappropriate to cross-post an answer in multiple threads, but it was asked in a couple of places so in the interest of helping novices with the Android environment (of which I'm one) I'm posting it here as well.
I'm using Vista, Eclipse 3.7.0
I don't know what "File | New | Project | Android Project | Create project from existing source" is supposed to do but I couldn't get it to work for a set of unzipped files of a project tutorial I got from elsewhere. I kept getting that error.
I found what did work is:
1) Copy the unzipped file tree for the project to wherever you want it to eventually reside.
2) File | Import | General | Existing Projects into Workspace | Select root directory:
and point it to wherever you put the zipped files, check-box on for the Project that is the one you want, then Finish
Step 2 seems to not actually move the files anywhere (even though the term 'import' implied that to me), but it seems to just make Eclipse aware of where the project is located and it uses the project from that directory.
That seems to work at least for me.

Related

Debug on many phones in Android Studio

Is it possible to debug an app on many phones at the same time in Android Studio? By this I mean launching multiple debug instances, each one on a different phone, like in Eclipse.
At the time of posting this question probably the only solution was the one posted by George V.M. Now, after several updates of Android Studio, this can be easily done by creating N copies of the same Debug configuration and launching each of them on a separate phone.
Update
You might want to take a look at Vlad's answer. This one is pointless for newer versions of Android Studio. In case anyone is still curious, this was my really hacky way of solving the problem
In case anyone out there is still looking for a solution to this, here's what I've found.
I'm working on a project that requires wireless communication between 2 instances of the same app running on 2 phones (actually, 2 or more). There were a lot of times where I wished I could debug 2 devices at a time. It wasn't until recently that I figured out how to do it.
It's actually quite simple: Have 2 instances of Android Studio open and you can debug multiple devices at once, (one device on each Android Studio instance) with breakpoints and everything!
Catch 1: You can't open two instances of the same project
I haven't been able to run two instances of Android Studio where both instances have the same project open. It will just redirect you to the already open project.
Solution:
The solution to this is to just make a copy of your project somewhere on your PC and open that project allowing you to have two copies of the same project open.
Catch 2: Changes have to be made on each copy manually.
Now here's a new problem. What if while debugging, you find a mistake in your code and amend it. Now you have to make sure you make that exact same amendment in your second copy of the project so that the second device doesn't have the same error if it hits those lines. This is annoying, having to remember to make a change twice; once in each copy of the project.
Solution:
My solution to this problem was to just make a 'symbolic link' of the project instead of a physical copy.
(A symbolic link is a 'nickname' or a 'reference' to a file. If you make a symbolic link fileB that points to fileA, although they seem like two distinct files to the OS, they in fact point to the exact same physical file. Any changes made on fileA will be reflected in fileB since they point to the same physical file/data on the disk. Instructions on how to create symbolic links are given below)
Now hold on just one second!!! Making a symbolic link of the entire project might not be a very smart idea since you'll have two Android Studios trying to edit the same files. This could lead to problems, especially in the case of build files and IDE files.
So what I did was make a symbolic link of only the source files, or any file which I'd be editing directly and which AS wouldn't normally touch, and make a physical copy of every other file.
The only thing you need to do is remember to hit Ctrl+S after making changes to your code in one AS instance so that the changes will be reflected on the second one. It might still take a couple of seconds for those changes to be reflected in the second instance but you can just click the "Synchronize" button (top left, next to "Open" and "Save") on your second AS which will cause all externally changed files, i.e., the file you just edited in your first instance, to be reloaded from disk.
You still need to be careful though. Every time you make a change in one AS, make sure you save all those changes and that those changes are reflected in the second AS before you try doing any editing in the second AS. Otherwise conflicts could cause you to lose the changes you made in one copy. One way around this is to force yourself to make changes to a file only on one AS and not the other.
Actual Instructions:
Okay that was a lot of talk. Here are the steps you can follow along with tips:
Close Android Studio and make a copy of your project into another folder on your PC
Go to your second copy and delete all your source code files since we're going to make symbolic links of them.
(these are the files I usually make symbolic links of instead of a copy:
all build.gradle files
the entire app/src folder
if you have any other loose source or resource files or othwerwise non IDE files that you might edit, make symbolic links of them as well
Make a symbolic link of all those non IDE files from the first project folder into your second project folder.
to make a symbolic link of a file in Windows, use
mklink path\to\symbolic\link path\to\original\file
to make symbolic link of a folder in Windows, use
mklink /j "path\to\symbolic\link" "path\to\original\folder"
to make a symbolic link of a file or folder in Linux, use
ln -s "path/to/original/file_or_folder" "path/to/link"
Open up Android Studio again. It will probably open the original copy of your project if that was the last project you opened in AS.
Go to File>Open and open up the second project copy on your PC.
You will now have 2 copies of your project running and you will be able to debug your app on 2 devices at the same time! (Remember that breakpoints won't be shared between the two copies)
If you are talking about attaching the debugger to several phones, I'm going to say no.
The port will be blocked with that traffic from one phone.
Unless someone figure out a hacky way to do this, atm It's not possible as far as my knowledge.
Android studio has its VM devices, but it requires installing Intel Accelerator because it's too slow until it show up. alternatively, I recommended "Genymotion" for running multiple instances and different devices. I'm using it and its working perfectly.
It may takes a while for setup and installing but once its installed it will be light weight and I promise you'll be pleased while working on it =)
Here is the link:
genymotion intallation user guide,
genymotion website

Android studio does not create files

I added a new fragment to my project in Android studio like the way I did it a couple of times before, but now it says that this file das not exist (and is read only). I cannot edit a thing in it but also do not know how to correctly close it, so I can't use the name, which I really want...
I cannot find the file anywhere within my project and it is also not listed in the project+path (Name/App/src/main/...) but in the entire windows location (E:/...).
And how can I create a permanent file, or better, why does it not work any more?
This must be a fault on your side. Are you sure you are in the right folder? This is the only explanation I could think of. So you creat the files but outside of your project's folder, so you cannnot edit them or anything else, but read them...
Bene
Make sure that you have no LINT ERRORS.
For checking it:
Go to the bottom right side of Android Studio. Tap on "Gradle Console" tab.
If you have some errors(red text) - remove them and try again.

Eclipse can see resources which do not exist

I am new to Android development.
I created an Android project, and imported some images as resources.
Unfortunately, one of them contained a capital letter, which is illegal. I have first renamed, then removed the offending image. Then I delete all images, but Eclipse still insists they are there after clicking refresh refreshing and running clean several times.
Could anyone tell me how to fix this?
If the file actually exists in your workspace . Just Right Click the file and select Validate . It should be alright

Questions on Notepad Tutorial:

URl of page - http://developer.android.com/resources/tutorials/notepad/index.html
Under "Preparing for the Exercise" the instructions say to
Download the project exercises archive (.zip).
Unpack the archive file to a suitable location on your machine.
Open the NotepadCodeLab folder.
QUESTION 1 - What is considered a suitable location?
I unpacked the samples to.
- *c:\Development\NotePadTutorieal* -
BUT I don't want to modify the files here. Sometimes I need (or just want to) work the tutorial 2 or 3 times from scratch, and would prefer my base files serve as an untouched template, so I can restart from scratch if necessary. I'd like to have the working code for the tutoriel end up where all my other Android Projects are stored at c:\Development\eclipse... but weather I select "Create Project from from existing source" - or - "Create project from existing sample" it seems to leave the files where they are, and work on them in suite (modifying what I'd like to keep as a reusable template) - Am I missing something?
Thanks in advance for any helpful comments.
Joe
Why don't you just keep two copies? Work on one, and let the other serve as your untouched template.
EDIT: Make a copy of the entire NotePadTutorial folder in c:\Development\eclipse\ and work on it there. Leave the other one untouched.
A suitable location is anywhere on your system where you have read and write permissions. If you want them in the same place as your other project files, copy the sample project directory to wherever you want it and then select "Create project from existing source".

Cannot find the culprit file in my android project even after expanding the main folder

The side bar in eclipse shows a red cross on the title of my project folder but there are no such signs in the directories below it in hierarchy. In which particular file does error exist? How can I know that?
Error log shows: Current file is not a match for the given config.
Sorry I just came across this now, but I've had the same error too, so I'm sure others have. There was a quite a bit easier solution than what you had to do, at least in my case. I had the exact same problem, where my main project said there was an error, so I couldn't debug or run, but there was no apparent error, other than the red X on my main folder.
In order to solve this, I simply closed the project by right-clicking on the main folder, and selected "Close Project". Then, I right-clicked on the closed project, and selected "Delete". Don't worry, this will not delete any files, it will only remove it from the workspace, and will make sure you really want to do that by asking you to confirm. Now, just click on File->Import and select "Existing Projects into Workspace". Choose your parent folder for your app that was erroring, and import it. The few times I've had the phantom error on my main app, this has fixed it each time.
Whether there is an underlying cause and this process simply refreshes something in the workspace, I'm not sure, but at this point this fix is fast enough for me to use it.
Hope this helps next time!
Project -> Clean
Closing project and opening it again fixed it for me.
formed a new workspace and formed a new project. Added each file individually. Now it shows no error.. but still can't figure out what was wrong with thr previous code..? :=(
I faced the same issue..
there was a problem in manifest xml..
the path was not set properly. there may be space in the path..
I just copied the activity tag from other project and pasted in my project and just edited the path in android:name. it worked fine..

Categories

Resources