Get previous code in android studio
Solution 1
Android Studio has a code history feature which allows you to see previous versions of a corresponding file. Just right click on a file in the IDE's file explorer and you will see this option.
Solution 2
Right click the file in android studio, Local History -> Show History. Maybe you can see old version of file.
If not, here is the certain solution: download old apk from Play store, use Dex2jar to decompile old .dex file and see codes with JD-GUI.
Or you can use Jadx too.
Solution 3
You could try googling for an .apk decompiler and try to decompile your old .apk. You may get mixed results but if you are desperate that is one option.
But from now on, make sure to use git for source control in your apps. Android Studio makes it really easy to use git.
Related videos on Youtube
AxeManTOBO
Updated on June 16, 2022Comments
-
AxeManTOBO almost 2 years
Hey i have this issue where I first created an app, put it on playstore and then i tried to integrate google adsense into it later. I had to change some code in the build file which has now completely ruined my project and i can't even revert back my changes since i had closed android studio.
I've spent hours trying to fix the code but it just wouldnt work. I need to see what have i done wrong. In the previous version it was working fine. Is there any way to see the code in the previous apk? or reset changes or anything like that in android studio?
-
Marcin Orlowski almost 8 yearsImpressive some people still does not use VCS these days. Please read: en.wikipedia.org/wiki/Version_control and learn from your failure.
-
-
AxeManTOBO almost 8 yearsRight click on which file?
-
Ozgur almost 8 yearsYour possible Java files that contains problems.
-
Ranjithkumar almost 8 years@AxeManTOBO Android studio -> Right click on your project folder -> you can see local history
-
Ranjithkumar almost 8 years@OzgurGUL for decompiling easy process check my answer - stackoverflow.com/a/27981520/3879847
-
Ozgur almost 8 years@Ranjith Kumar, Sometime learning the hard way is better :)
-
Ranjithkumar almost 8 yearsbut if we get the same output in easy way why we stay with hard way??
-
AxeManTOBO almost 8 years@RanjithKumar is there any way to see the changes in the build.gradle? The ways you've mentioned in the answer dont have a way to get gradle file of the app
-
Ranjithkumar almost 8 years@AxeManTOBO yes.. that give the partial files(java,xml,manifest) only.. not entire project..
-
Ranjithkumar almost 8 years@AxeManTOBO but local history is good idea.. r u try this?
-
AxeManTOBO almost 8 yearsThank you all so much. Checking local history worked for me
-
Shounak Ray about 5 yearsYou, sir, are a LIFE SAVER.
-
Ozgur about 5 yearsGlad it helped Mr.Shounak Ray ;)
-
Kwnstantinos Nikoloutsos over 4 yearsWait can they see my code that easily? I see the power of obfuscators now!