How many times do we encounter such problems when we build Android app packages on a daily basis
|  1 2 3 4 5 6  | [ ] e: /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.3/android/src/main/kotlin/com/example/gogogo/xxxManager.kt: (19, 8): Redeclaration: xxxManager [ ] e: /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.3/android/src/main/kotlin/com/example/gogogo/xxxManager.kt: (79, 12): Redeclaration: gogogoResult [ ] e: /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.3/android/src/main/kotlin/com/example/gogogo/xxxManager.kt: (82, 12): Redeclaration: gogogoListResult [ ] e: /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/android/src/main/kotlin/com/example/gogogo/xxxManager.kt: (21, 8): Redeclaration: xxxManager [ ] e: /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/android/src/main/kotlin/com/example/gogogo/xxxManager.kt: (94, 12): Redeclaration: gogogoResult [ ] e: /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/android/src/main/kotlin/com/example/gogogo/xxxManager.kt: (97, 12): Redeclaration: gogogoListResult
 | 
 
 the cause of the problem
-  Because of the Kotlin incremental compilation bug. When you turn off incremental compilation, the problem does not appear.
 Common Solutions
-  flutter clean
-  But this method may be heavier, because it will clean up some redundant cache and affect the build speed
 more lightweight solution
-  This method only deletes the corresponding pub cache and does not delete other content.
|  1 2  | #!/bin/bash find ~/.pub-cache/hosted -name "$1-*" -type d -maxdepth 2 | xargs rm -rfv
 | 
 
 Save the above command as a script.
 For example, the name of the pub in question is gogogo, we just need to clear its version cache.
|  1 2 3 4 5 6 7  | removePubCache.sh gogogo /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/LICENSE /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/test/gogogo_test.dart /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/test /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/CHANGELOG.md /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/example/test/widget_test.dart /Users/xxxxxxxxx/.pub-cache/hosted/unpub.xxxxx.com/gogogo-1.0.4/example/test
 | 
 
 Then execute flutter pub get --verbose (required). 

 This article is reprinted from https://droidyue.com/blog/2022/10/04/fix-flutter-redeclaration-xxx-kotlin-error/
 This site is for inclusion only, and the copyright belongs to the original author.