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 follow
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?
It's due to updated configuration changes in the gradle.
So just try File -> File > Invalidate Caches / Restart
Or Delete the old APKs in your system
This issue is resolved by deleting APKs generated by previous build existing in release and debug folders.
Invalidating cache and rebuild would not help if you have not deleted previously generated APKs
I got this error message while generating signed APK.
Entry name res/interpolator/btn_checkbox_checked_mtrl_animation_interpolator_0.xml collided
Solved it by deleting existing APK. Pretty strange solution though.
Delete "ProjectFolder/build" folder of your project. Make sure you Have Closed Android Studio , otherwise you would unable to delete it.
Before reading solution below, please read my update from 01.04.2020, the problem is deeper and it is in your code.
I've got the same problem after this 3.6 update.
*The fast solution is:*
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.
UPD 01.04.2020: (Not 1st April joke:) )
Since month I worked with Android Studio developers and today I was told to use jdk instead of using jre, because one of deep errors in logs said It.
After setting jdk (File->Project Structure->SDK Location->JDK Location) instead of jre, I've got some another errors which were not showed in "build output" so I run Analyze -> Inspect Code and got EIGHTEEN errors such as refering to wrong view id in layouts, errors with orientation (hi to tools:ignore="MissingDefaultResource"
) and errors in manifest also with orientation: I read that this is some new update in 3.6.1 - about landscape or portrait screenOrientation
, fixed fast by Studio with this:
<activity
tools:ignore="LockedOrientationActivity" />
When all of errors were fixed with Analyze -> Inspect Code, I have succesfully generated signed APK using jdk and then using jre (just for test).
So in summary, this bug caused because of deep errors which you can find out only with Inspect Code
tool.
I think AS will not think that this a bug, I think they will said that this is a new feature for improving your code. Also I think you should try to inspect your code even without setting jdk instead of jre.
Additional recommendation from AS support:
BTW when exporting a release
build, we also run lintVital
which does some extra checks and have some errors marked as fatal
. This check is expensive so it does not happen in debug
builds