每当我尝试运行我的应用时,我都会收到此错误:
错误:任务执行失败
:app:transformClassesWithInstantRunSlicerForDebug'.
java.io.IOException: Failed to delete
C:\Users\ashis\AndroidStudioProjects\FirstApp\app\build\intermediates\instant-run-support\debug\restart-changes.txt**
,这是输出:
信息:Gradle任务
[:应用程序:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :应用:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42340Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE :应用:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:mergeDebugShaders UP-TO-DATE :app:compileDebugShaders UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE :app:compileDebugJavaWithJavac UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources UP-TO-DATE :应用:buildInfoDebugLoader :app:transformClassesWithExtractJarsForDebug UP-TO-DATE :app:transformClassesWithInstantRunVerifierForDebug UP-TO-DATE :app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE :app:mergeDebugJniLibFolders UP-TO-DATE :app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE :app:processDebugJavaRes UP-TO-DATE :app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE :app:transformResourcesAndNative_libsWithJavaResourcesVerifierForDebug UP-TO-DATE :app:transformClassesWithInstantRunForDebug UP-TO-DATE :app:transformClasses_enhancedWithInstant + reloadDexForDebug UP-TO-DATE :应用:incrementalDebugTasks :应用:prePackageMarkerForDebug :app:fastDeployDebugExtractor UP-TO-DATE :app:generateDebugInstantRunAppInfo UP-TO-DATE :应用:coldswapKickerDebug :app:transformClassesWithInstantRunSlicerForDebug FAILED 错误:任务':app:transformClassesWithInstantRunSlicerForDebug'执行失败。 java.io.IOException:无法删除C:\ Users \ ashis \ AndroidStudioProjects \ FirstApp \ app \ build \ intermediates \ instant-run-support \ debug \ restart-changes.txt 信息:建筑失败 信息:总时间:1分钟6.761秒 信息:1错误 信息:0警告 信息:请参阅控制台中的完整输出
答案 0 :(得分:75)
:应用程序:transformClassesWithInstantRunSlicerForDebug”。 java.io.IOException:无法删除
- 尝试清理项目并重建项目。
来自@Kael:通过Build - >执行清理清洁项目或构建 - >重建项目。
答案 1 :(得分:18)
请按照以下步骤操作: 转到
1>File
2>Settings
3>Build,Execution,Deployment
4>Instant Run
5>Uncheck (Enable Instant Run to hot swap code)
所以这对我有所帮助。
答案 2 :(得分:8)
在我的情况下public interface IBasic
{
}
public class Basic : IBasic
{
}
public class AnotherBasic : Basic
{
}
public interface IWorker
{
void Run(IBasic basic);
}
public interface IWorker<in TBasic> : IWorker where TBasic : IBasic
{
void Run(TBasic basic);
}
public abstract class Worker<TBasic> : IWorker<TBasic> where TBasic : IBasic
{
void IWorker.Run(IBasic basic)
{
if (basic is TBasic)
Run((TBasic)basic);
}
public abstract void Run(TBasic basic);
}
public class FirstWorker : Worker<Basic>
{
public override void Run(Basic basic)
{
// ...
}
}
public class SecondWorker : Worker<AnotherBasic>
{
public override void Run(AnotherBasic basic)
{
// ...
}
}
public void Test()
{
List<IWorker> workers = new List<IWorker>
{
new FirstWorker(),
new SecondWorker()
};
}
没有用。相反,我必须从文件系统中手动删除Build Menu > Clean Project and Build Menu > Rebuild
文件夹(在OSX上使用Finder,在Win上使用Explorer)。
答案 3 :(得分:1)
尝试从Build Menu > Clean Project and Build Menu > Rebuild
清除项目并重建项目
尝试重新启动android studio或在不同用户上使用android studio
答案 4 :(得分:1)
我执行任务失败&#39;:app:generateDebugBuildConfig&#39;。错误,清理和重建项目无效。
C:\Users\...\AppData\Local\Android\sdk\tools
添加到我的PATH
环境变量。答案 5 :(得分:1)
我遇到了同样的问题..我通过删除项目根目录上的.gradle文件并重新构建了项目来解决了我的问题。
答案 6 :(得分:0)
将此https://services.gradle.org/distributions/gradle-4.4-all.zip更改为grable-wrapper中的https://services.gradle.org/distributions/gradle-4.1-all.zip。性质鉴别仪表。然后重新导入属性。并同步项目。