Failed to transform file '45907c80e09917e1b776adf038505958' to match attributes {artifactType=jar} using transform AarTransform

前端 未结 4 539
粉色の甜心
粉色の甜心 2020-12-10 05:04

I am using Android 3.0 canary 4 and making an app. Everything was working fine until yesterday, but today when i opened the project, it gave me an error

 F:\         


        
相关标签:
4条回答
  • 2020-12-10 05:31

    It turns out that this is a weird bug in the Gradle itself. I posted it on google forum and one of their coders gave me a solution and also put it up as an issue with the gradle team.

    For the solution, you can clear your project cache (C:\Users\<username>\.gradle\caches\transforms-1 ) and rebuild your project again and it will work fine. The gradle needs some artifacts to build which are stored in the cache memory. So if the gradle fails to build, the cache can be cleared which will prompt fresh downloading. You can be offline as long as all the artifacts you need have been downloaded in Gradle's cache (so don't delete the cache folder when offline!)

    0 讨论(0)
  • 2020-12-10 05:36

    Received similar error:

    Failed to transform file 'uat-release.jar' to match attributes {artifactType=android-classes} Transform output file D:\R\project\uat-release.jar does not exist.

    In my case, Actual file was aar and bymistake I put .jar in build.gradle(of uat-release module)

      configurations.maybeCreate("default")
      artifacts.add("default", file('uat-release.jar'))
    

    Solved it by correcting file type:

      configurations.maybeCreate("default")
      artifacts.add("default", file('uat-release.aar'))
    
    0 讨论(0)
  • 2020-12-10 05:37

    Faced the same issue. The simple way to solve this is to switch between your build variants. This refreshes the cached copies and resolves the issue.

    0 讨论(0)
  • 2020-12-10 05:38

    The error seems to be caused by corrupt Jetified files.

    Delete ONLY the corrupted .jars from the error message from the Gradle caches folder:

    rm ~/.gradle/caches/modules-2/files-2.1/path-to/some-release.aar
    

    The "path-to" will be probably be the package name e.g., com.example.somerelease

    Usually I get the path of the file to delete from the error message itself and cut and paste it into the terminal in order to execute the rm command.

    Deleting the entire folder is not an optimal solution as all the dependencies will need to be Jetified again. If you're already having corruption issues, you're likely to encounter the issue again as there is more work for Jetify when it has to reprocess the entire folder

    0 讨论(0)
提交回复
热议问题