问题
I have updated my android studio from 3.5.x to 3.6 today and getting error while generating signed apk for build variant showing the following message - Entry name 'res/layout/test_toolbar.xml' collided I don't have any layout named like this one in the whole project at all. I have custom build variant named "stage" and whenever I am trying to build an signed apk, it always fails. I count find any solution yet. Please help me with this issue. Thanks
回答1:
I've got the same problem after this 3.6 update.
The solution is:
- delete projectFolder\build
- delete projectFolder\debug*
- delete projectFolder\release*
- delete projectFolder\app\build
- delete projectFolder\app\build\debug*
- delete projectFolder\app\build\release*
So you need to delete all of build, debug and release directories.
Note that you may be not able to delete whole debug and release directories, but you can delete all of it contents.
UPD:
I think they have fixed this bug today:
UPD 03.03.2020: Unfortunatelly, bug doesn't fixed.
回答2:
I deleted the previous build outputs for build variant, including APK file. That's what helped me
回答3:
While generating the apk, check for the destination folder, from which delete output.json and app-debug.apk from debug folder. Try building the same after this. AFAIK, it is a bug for android studio, hope they might fix this soon :)
回答4:
It happen when you used auto viewBinding, Binding using Kotlin or viewBinding feature of 3.6.
In case, you are adding files whose element share same id's, ViewBinding confuse and create such error.
Let me help you by example Adapter class which have two layout file separating by view Type :
import kotlinx.android.synthetic.main.frag_subscription_recommend.view.*
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
LayoutInflater.from(parent.context).inflate(
if (viewType == 1) {
R.layout.frag_subscription_recommend
} else
R.layout.frag_subscription_common,
parent,
false
)
)
}
onBinding(){
holder.itemView.id_button_submit.setOnClickListener {}
}
// which in case confusing which resource or layout full fill the requirement bcoz both have same ids of button. in case you have to use :
onBinding(){
holder.itemView.findViewById<Button>(R.id.id_button_submit).setOnClickListener {}
}
which enable the old implementation.
Let me know if this working on your side?
来源:https://stackoverflow.com/questions/60406047/getting-error-says-entry-name-res-layout-test-toolbar-xml-collided-while-c