java.lang.IllegalArgumentException:参数'directory'不是android中的目录

时间:2019-01-03 07:37:45

标签: java android

我重建我的项目,并从发生错误的地方得到这个错误,我找不到。在下面找到日志,

Caused by: java.lang.IllegalArgumentException: Parameter 'directory' is not a directory
    at org.apache.commons.io.FileUtils.validateListFilesParameters(FileUtils.java:545)
    at org.apache.commons.io.FileUtils.listFiles(FileUtils.java:521)
    at android.databinding.tool.store.ResourceBundle.loadClassInfoFromFolder(ResourceBundle.java:157)
    at android.databinding.tool.store.LayoutInfoInput$deps$2.invoke(LayoutInfoInput.kt:63)
    at android.databinding.tool.store.LayoutInfoInput$deps$2.invoke(LayoutInfoInput.kt:30)
    at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:154)
    at android.databinding.tool.store.LayoutInfoInput.getDeps(LayoutInfoInput.kt)
    at android.databinding.tool.store.LayoutInfoInput$existingBindingClasses$2.invoke(LayoutInfoInput.kt:86)
    at android.databinding.tool.store.LayoutInfoInput$existingBindingClasses$2.invoke(LayoutInfoInput.kt:30)
    at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:154)
    at android.databinding.tool.store.LayoutInfoInput.getExistingBindingClasses(LayoutInfoInput.kt)
    at android.databinding.tool.BaseDataBinder.<init>(BaseDataBinder.kt:40)
    at com.android.build.gradle.internal.tasks.databinding.DataBindingGenBaseClassesTask$CodeGenerator.run(DataBindingGenBaseClassesTask.kt:203)
    at com.android.build.gradle.internal.tasks.databinding.DataBindingGenBaseClassesTask.writeBaseClasses(DataBindingGenBaseClassesTask.kt:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
    ... 33 more

我们将不胜感激!

2 个答案:

答案 0 :(得分:5)

我遇到了同样的问题。我所做的就是:

  1. 删除 .gradle 目录
  2. 使缓存无效并重新启动Android Studio。

答案 1 :(得分:-1)

您的“文件”类型应引用文件夹,而不是文件。 Android源代码执行此操作:

if (!directory.isDirectory()) {
    throw new IllegalArgumentException("Parameter 'directory' is not a directory: " + directory);
}

因此您传递的File变量不指向Folder,而是其他。