Recovering my application project - java

I copied my Application Project Folder into another one to try a big change on my app.
The change was not what i wanted, so i deleted the current project folder.
I then wanted to use my TMP folder to recover my old project. I used "mv" to rename TMP into tho old name i used.
But when i came back to eclispe, i had a lot of bugs, and then all my files were deleted and are now empty...
All i have left is my app installed on a virtual device, and all my projects file with the right names but which are empty.
Is there any chance to get my code back using the apk installed on the device or something like that ?

I used this answer Is there a way to get the source code from an APK file? to decompile my app from the .pkg that was stored onto my virtual device !
I got all my drawables / assets / .xml files from this, but the code was unusable so i used what i found here ([your android projects folder]/.metadata/.plugin/org.eclipse.core.resources/.history) to bring back my java code using "grep -r" in the folder to find the pieces of code i needed !

Related

Renamed a project in my Eclipse workspace via the filesystem and now cannot open it.

I had a folder that I downloaded from GitHub which is a group project for college. I worked on it a bunch and added tons of code and then planned to reupload this big folder straight back up to GitHub (yeah, worst version control in the world I know). We were just incrementing the project folders by 1 each time so I renamed the folder in my Eclipse workspace to Project3. I then tried to reopen this folder in Eclipse and every time I selected it nothing happens. It has me very worried. Luckily most of my code was in a class file which I am still able to access however there are some changes here and there in other files that I made which ideally I would like back. Any idea what I should do to be able to open this project up in Eclipse again? I should also note that I tried renaming it back to the original name.

Android project, code got deleted during move of project folder

So Ive worked on a small android game for the past months and it was located on my desktop. I figured it would be good practice to keep it in my workspace folder instead! So I moved the project folder to the workspace, imported it back into eclipse and boom... all code was gone. The classes code, the manifest.. all that was left was the assets. In the projects folder when opening one of the classes in notepad it is also gone.
Is there a way to recover the lost code or something? I dont understand why the code would dissapear just because I moved the folder?
Eclipse keeps a history of all files worked on in the following directory:
Workspace\.metadata\.plugins\org.eclipse.core.resources\.history
You'll have to search through it to find all your file. They might also not be the latest revision, but it has saved me many times.
you can try with the Eclipse's Local History

Why does it keep say "Refactoring cannot be performed" when I copy a jar file into the lib folder in Android Studio?

I'm trying to just copy an external library .jar file into my libs folder. It keeps saying, that it's a read-only file. How do I go about doing this? Thanks :)
The problem isn't that your file is read only. It happened to me today on my iMac with *.png files that weren't read only. Instead of dragging it, try the old fashion way: copy your file and then paste it in your folder. It may work.
Apparently, it's a bug with the latest Android Studio
CTRL + Drag works for importing in Windows.
On a Mac you can hold down the Option key while dragging the files into Android Studio.
See the comment in this answer: https://stackoverflow.com/a/24053667/475217
Go into properties for your .jar and uncheck Read Only. Then switch over to the Android Development Bundle and never look back :)
Your error message gives you the reason. Your jar file is read-only and is not in your libs folder (right now it's in your Downloads folder).
Make sure you properly copy it to your libs folder, and try the re-factor again.

data/data/package/files/myfile.txt is not copied to apk file

I followed This thread
and copied "MyFile.txt" file to data/data/package/files/ through DDMS>File Explorer and hit run. The emulator displays the content of file, but, when I copy apk and run on device, it throws an exception java.io.FileNotFoundException: data/data/package/files/myfile.txt failed ENOENT.
Is it because data/data/package/files/myfile.txt is not copied to apk file?
I tried res/raw/myfile.txt it works well.
Also, if there is any way to read a file which is in the root?
Thanx.
Yes, your file wouldn't get copied to the apk this way.
The data directory is the runtime storage area for the app. It only gets created after you install your app on a device/emulator.
So, this kind of packaging your data would never work.
One way to package your data is by putting it into the assets folder. However, if you would like to edit/change the file once the application is installed, this method also would not work for your situation.
But, if you just want a read only version of this file, putting it into assets folder would work fine.

How to recover deleted java files on a mac?

Using Eclipse I accidentally deleted the wrong folder on my file system and lost hundreds of java files on my mac yesterday.
I am using a second mac to connect to my mac via firewire.
My mac appears as an external disk on the second mac.
I am running data recovery programs on the second mac to ensure that none of the deleted files are overwritten by writes to the file system on my mac.
I've tried a couple data recovery programs (Disk Drill, Data Rescue 3), but they don't seem to be able to recognize .java files.
Has anyone had a good experience recovering deleted .java files on a mac?
Eclipse usually keeps internal history. You should be able to restore the files using Eclipse itself, if the files were deleted in Eclipse: In context menu of you project you should see "Restore from Local History.." item.
On the other hand I would recommend to always use SCM tools (such as Git, Mercural etc). This way you will never lose your code. Practially every SCM tool this days has a very good Eclipse plugin.

Categories

Resources