升級後,想說試試官方的 Samples
Android Studio 3.1.3 編譯 AppUsageStatistics Sample
https://github.com/googlesamples/android-AppUsageStatistics/#readme
結果 error 滿天飛
這些錯誤訊息都沒有幫助,甚至有誤導之嫌…..
找了三天,原來是 build.gradle 裡面
dependencies {
compile ‘com.android.support:support-v4:27.0.2’
compile ‘com.android.support:support-v13:27.0.2’
compile ‘com.android.support:cardview-v7:27.0.2’
compile ‘com.android.support:appcompat-v7:27.0.2’
compile ‘com.android.support:recyclerview-v7:+’
compile ‘com.android.support:appcompat-v7:21.+’
}
改成…..
dependencies {
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:support-v13:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.0.2'
}
版本號碼不要用 "+",就沒 error
compile 改成 implementation 可以去除警告訊息
感謝這篇最後有個高手提示
https://stackoverflow.com/questions/50266035/no-resource-identifier-found-for-attribute-appcomponentfactory-in-package-and
要不然,依照錯誤訊息找到的文章大部分都要你關閉 AAPT2,雖然真的減少一兩個報錯,可是卻使問題更難找了,
而且,關閉這個新的資源編譯器,對未來開發很不利阿!!