Android studio java.io.FileNotFoundException 中的错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37153803/
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
Error in Android studio java.io.FileNotFoundException
提问by Andreas Notanto
I got error when I want to debbuging usb at my phone I cant display my code on android studio in my phone and the error looks like this: please help me I am using android studio 2.0 and my phone is ASUS Fone-Pad 8.0.
当我想在手机上调试 USB 时出现错误 我无法在手机中的 android studio 上显示我的代码,错误如下所示:请帮助我 我使用的是 android studio 2.0,我的手机是 ASUS Fone-Pad 8.0。
Error:java.io.FileNotFoundException: C:\Users\Andrezs\AndroidStudioProjects\HappySunday.gradle\2.10\taskArtifacts\cache.properties (The system cannot find the file specified)
错误:java.io.FileNotFoundException:C:\Users\Andrezs\AndroidStudioProjects\HappySunday.gradle\2.10\taskArtifacts\cache.properties(系统找不到指定的文件)
C:\Users\Andrezs\AndroidStudioProjects\HappySunday.gradle\2.10\taskArtifacts\cache.properties (The system cannot find the file specified)
C:\Users\Andrezs\AndroidStudioProjects\HappySunday.gradle\2.10\taskArtifacts\cache.properties(系统找不到指定的文件)
回答by Mayur Sakhiya
You should read the Android Studio 2.0 changes doc. because adding some new functionality in Android Studio and its effect on some another functions. So, Read the Documentation and issues pages and You can solve this problem.
您应该阅读 Android Studio 2.0 更改文档。因为在 Android Studio 中添加了一些新功能及其对其他一些功能的影响。所以,阅读文档和问题页面,你可以解决这个问题。
As my opinion , this type of error found When your app run in Instant Run feature of Android Studio. so, new build not generated every time and app content not found in your android device.
我认为,当您的应用程序在 Android Studio 的 Instant Run 功能中运行时,会发现此类错误。因此,每次都不会生成新版本,并且在您的 android 设备中找不到应用程序内容。
Solutionis define in this linkor following instruction :
解决方案在此链接或以下说明中定义:
<div><p style="margin:0px 0px 12px;font-family:Roboto,sans-serif;font-size:14px;line-height:24px"><font color="#000000">By default, Android Studio automatically restarts the current activity after performing a hot swap, while the app keeps running. To disable this setting:</font></p><ol style="margin:0px 0px 15px 20px;padding:0px;font-family:Roboto,sans-serif;font-size:14px;line-height:24px"><li style="margin:0px 0px 12px"><font color="#000000">Open the <strong>Settings</strong> or <strong>Preferences</strong> dialog.</font></li><li style="margin:0px 0px 12px"><font color="#000000">Navigate to <strong>Build, Execution, Deployment</strong> > <strong>Instant Run.</strong></font></li><li style="margin:0px 0px 12px"><font color="#000000">Uncheck the box next to <strong>Restart activity on code changes</strong>.</font></li></ol><p style="margin:0px 0px 12px;font-family:Roboto,sans-serif;font-size:14px;line-height:24px"><font color="#000000">If automatic activity restart is disabled, you can manually restart the current activity from the menu bar by selecting <strong>Run</strong> > <strong>Restart Activity</strong>.</font></p><h4 style="font-size:18px;line-height:24px;margin:12px 0px;font-family:Roboto,sans-serif"><a name="TOC-Using-Rerun"></a><font color="#000000">Using Rerun</font></h4><p style="margin:0px 0px 12px;font-family:Roboto,sans-serif;font-size:14px;line-height:24px"><font color="#000000">When pushing certain code changes, such as changes to an app's <code style="font-size:13px;font-stretch:normal;line-height:18px;font-family:Consolas,Liberation Mono,Menlo,Courier,monospace;padding:3px 5px;background-color:rgb(247,247,247)"><a href="http://adarshf-linux.kir.corp.google.com:9000/reference/android/app/Application.html#onCreate()" style="text-decoration:none">onCreate()</a></code> method, you will need to restart your running app for the changes to take effect. You can click <strong>Rerun </strong></font><img border="0" src="http://tools.android.com/_/rsrc/1458888270801/tech-docs/instant-run/as-restart.png"><strong style="color:rgb(0,0,0);background-color:transparent"> </strong><span style="color:rgb(0,0,0);background-color:transparent">to stop the app, perform an </span><em style="color:rgb(0,0,0);background-color:transparent">incremental build</em><span style="color:rgb(0,0,0);background-color:transparent">, and restart the app.</span></p><p style="margin:0px 0px 12px;font-family:Roboto,sans-serif;font-size:14px;line-height:24px"><font color="#000000">If you need to deploy a <em>clean build</em>, select <strong>Run</strong> > <strong>Clean and Rerun 'app'</strong> </font><img border="0" src="http://tools.android.com/_/rsrc/1458888258422/tech-docs/instant-run/as-cleanrerun.png"><font color="#000000"> from the main menu, or hold down the <strong>Shift</strong> key while clicking <strong>Rerun</strong> </font><img border="0" src="http://tools.android.com/_/rsrc/1458888270801/tech-docs/instant-run/as-restart.png"><font color="#000000">. This action stops the running app, performs a full clean build, and deploys the new APK to your target device.</font></p></div>
If above solution not worked than go to project> appfolder > buildfolder and delete build folder than after run again.
如果上述解决方案不起作用,请转到项目>应用程序文件夹>构建文件夹并删除构建文件夹,然后再次运行。
回答by naveed148
Quit Android Studio, delete build folder, open your project again. Should fix the problem.
退出 Android Studio,删除 build 文件夹,再次打开您的项目。应该解决问题。
回答by Syed Danish Haider
go to the project and delete .idea,.gradle & build folder from project and then import the project
转到项目并从项目中删除 .idea,.gradle & build 文件夹,然后导入项目