Gradle assemble of an Android project failed, can't find R.txt

前端 未结 4 1990
余生分开走
余生分开走 2021-01-04 17:43

Sorry for my poor English. I\'m trying to migrate my project to Gradle with Android Studio, but currently the build fails during processDebugResources.

相关标签:
4条回答
  • 2021-01-04 18:24

    This worked for me, maybe this helps someone

    build.gradle:

    classpath 'com.android.tools.build:gradle:2.3.2'
    

    gradle/wrapper/gradle-wrapper.properties:

    distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
    

    Sync Now.

    0 讨论(0)
  • 2021-01-04 18:30

    I had the same problem, beginning when I fumbled around adding a second sub-subfolder to my assets directory. Removing the folder (basically undoing what I did to cause the problem) didn't help, which indicated it may be a problem with caches. The accepted answer may work, if by changing the manifest file you trigger Android Studio to invalidate its caches (apparently this is more than clean and rebuild, as I tried that several times).

    Simple thing to try: go to File->Invalidate Caches and Restart.

    0 讨论(0)
  • 2021-01-04 18:40

    So the way I fixed this was:

    inside my androidTest folder, I had a java folder with my test files. But gradle requires you to have some resources inside test so that it generates the R.txt file. So what I did was created a res folder inside androidTest and added a values/strings.xml folder with one string resource.

    This allowed my tests to build and run!

    0 讨论(0)
  • 2021-01-04 18:44

    Solved. The reason is that the AndroidManifest.xml file had something wrong, but gradle(or lint?) didn't figure it out. Thus the R.txt file couldn't be generated. As soon as I amended the AndroidManifest.xml file, the problem was gone. Sorry again for my poor English.

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