更新到com.android.tools.Build:gradle:4.2.1后生成错误



我在构建android项目时遇到以下错误:

AAPT: <project directory>appbuildintermediatesstable_resource_ids_filedebugstableIds.txt: error: failed to open: The data is invalid. (13).

它是在将项目的app目录中的build.gradle文件从com.android.tools.build:gradle:4.1.3更新为com.android.tools.build:gradle:4.2.1:之后开始发生的

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
...
dependencies {
...
classpath "com.android.tools.build:gradle:4.2.1"
...
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

目前,我正在通过将项目app目录中build.gradle文件中的com.android.tools.build:gradle:4.2.1降级为com.android.tools.build:gradle:4.1.3来避免这个问题:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
...
dependencies {
...
classpath "com.android.tools.build:gradle:4.1.3"     // <--- downgrade to 4.1.3 to avoid build error!!
...
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

我遇到了同样的问题,我用解决了这个问题

rm -rf node_modules
yarn install

最新更新