19
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AndroidStudio3.1.2でAAPT2エラーが出た時の対処法

Last updated at Posted at 2018-06-18

恐怖のエラーAAPT2

ふとした瞬間に起こるAAPT2エラーに、幾度となく悩まされてきました。
どうにか終止符を打ちたいので残しておきます。

エラーログ

Warning:The [パッケージ名] property is deprecated and it has no effect on the build process.
/home/********/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/*************************/res/values/values.xml 
Error:(246, 5) error: resource android:attr/fontVariationSettings not found. 
/project/bkup/14_march_2018/***/***/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml
Error:(246, 5) error: resource android:attr/ttcIndex not found.
Error:(269) resource android:attr/ttcIndex not found.
Error:(269) resource android:attr/fontVariationSettings not found. Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception:
AAPT2 error: check logs for details Error:failed linking references.
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception:
AAPT2 error: check logs for details Error:com.android.tools.aapt2.Aapt2Exception:
AAPT2 error: check logs for details Error:Execution failed for task ':*****:processDebugAndroidTestResources'.

解決策①:enableAapt2

gradle.properties

android.enableAapt2=false

自分は解決しませんでした。

解決策②:force 'com.android.support:support-v4:27.0.2'

build.gradle

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.0.2'
    }
}

自分は解決しませんでした。

解決策③:build tools

build.gradle

classpath 'com.android.tools.build:gradle:3.2.0-alpha13'

自分はこれで解決できました。

考察

AAPT2エラー自体、.xmlファイルの記述ミスで発生するみたいなんですけど、今まではAAPT2エラーが出るばかりで何処がミスしてるのか書いてないんですよね。
それが最新のbuild toolsでミス箇所まで出るようになったみたいです。

参考:
android studio 3.0.1 で AAPT2 error が出た時の対応
https://qiita.com/kako351/items/7775157358aaf00da6f9

LobiのAndroidアプリ開発を Android Studio 3.0 に移行しました!
https://techblog.kayac.com/ready-for-andorid-studio-3

AAPT2 working abnormally in android studio 3.1 both for True and False flag
https://stackoverflow.com/questions/49534951/aapt2-working-abnormally-in-android-studio-3-1-both-for-true-and-false-flag

19
14
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?