java 在android studio中获取之前的代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37502455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 02:34:08  来源:igfitidea点击:

Get previous code in android studio

javaandroid

提问by AxeManTOBO

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.

嘿,我遇到了这个问题,我首先创建了一个应用程序,将其放在 Playstore 上,然后我尝试将 google adsense 集成到其中。我不得不更改构建文件中的一些代码,这些代码现在已经完全破坏了我的项目,而且自从我关闭了 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?

我花了几个小时试图修复代码,但它不起作用。我需要看看我做错了什么。在以前的版本中,它运行良好。有什么办法可以看到之前apk中的代码吗?或者在android studio中重置更改或类似的东西?

回答by Ukubu

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.

Android Studio 具有代码历史记录功能,可让您查看相应文件的先前版本。只需右键单击 IDE 文件资源管理器中的文件,您就会看到此选项。

回答by Ozgur

Right click the file in android studio, Local History -> Show History. Maybe you can see old version of file.

在 android studio 中右键单击该文件,Local History -> Show History。也许您可以看到旧版本的文件。

If not, here is the certain solution: download old apk from Play store, use Dex2jarto decompile old .dex file and see codes with JD-GUI.

如果没有,这里是特定的解决方案:从 Play 商店下载旧的 apk,使用Dex2jar反编译旧的 .dex 文件并使用JD-GUI查看代码。

Or you can use Jadxtoo.

或者你也可以使用Jadx

回答by Micro

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.

您可以尝试在谷歌上搜索 .apk 反编译器并尝试反编译旧的 .apk。您可能会得到好坏参半的结果,但如果您不顾一切,这是一种选择。

But from now on, make sure to use git for source control in your apps. Android Studio makes it really easy to use git.

但是从现在开始,请确保在您的应用程序中使用 git 进行源代码控制。Android Studio 使使用 git 变得非常容易。