aapt_rules.txt 未找到:libGDX IntelliJ Idea 项目

aapt_rules.txt not found: libGDX project on IntelliJ Idea

当我尝试构建一个项目时遇到了这个问题,我在我的 android/build.gradle 文件中添加了对混淆器的支持,如下所示:

// Proguard configuration
buildTypes {
    release {
        //minifyEnabled true will turn proguard ON
        minifyEnabled true
        //proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
    }
}

我没有 proguard-android.txt 文件,但我在同一个 android 模块目录中有一个 proguard-project.txt 文件,其中包含以下文本:

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.parentDir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

-verbose

-dontwarn android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild

-keep class com.badlogic.gdx.controllers.android.AndroidControllers

-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
   <init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
}

-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
   boolean contactFilter(long, long);
   void    beginContact(long);
   void    endContact(long);
   void    preSolve(long, long);
   void    postSolve(long, long);
   boolean reportFixture(long);
   float   reportRayFixture(long, float, float, float, float, float);
}

我得到的错误是这样的:

Warning:Exception while processing task java.io.FileNotFoundException: /home/.../Desktop/Idea/.../android/build/intermediates/proguard-rules/release/aapt_rules.txt (No such file or directory)

我看到其他人的问题是他们有一个空的 proguard 规则文件,但显然不是这种情况。

关于如何调试它有什么想法吗?

提前致谢!

我发现这个问题的解决方案是 在文件菜单中 "Invalidate Cache/Restart..." 之前 完全删除项目中的 android/build 目录。在没有删除 android/build 目录之前,我已经尝试了几次该菜单选项,但它没有任何区别。

尽管启用了复选框 "Clean project on rebuild",但重建项目也不起作用,因此有时似乎要在 IntelliJ Idea 中获得一个干净的项目,您必须自己完成。