Shopify / flash-list

A better list for React Native
https://shopify.github.io/flash-list/
MIT License
5.42k stars 280 forks source link

Canvas type missmatch in Android SDK 34 #864

Open peter-stocks opened 1 year ago

peter-stocks commented 1 year ago

Current behavior

Android build fails with the following error when using Android compileSdkVersion = 34

The issue seems similar to this one - https://github.com/software-mansion/react-native-screens/pull/1795

`

Task :shopify_flash-list:compileReleaseKotlin FAILED e: /Users/peter.igov/projects/stocks/stocksapp/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt: (29, 5): 'dispatchDraw' overrides nothing e: /Users/peter.igov/projects/stocks/stocksapp/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt: (32, 28): Type mismatch: inferred type is Canvas? but Canvas was expected `

To Reproduce

Change compileSdkVersion to 34 and gradle version to 8.0.1

Platform:

Environment

"react-native": "0.71.8" "@shopify/flash-list": "1.4.3"

siyahulhaq commented 1 year ago

i am also facing issue

siyahulhaq commented 1 year ago

fixed issue by paching

diff --git a/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt b/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt
index 6b78bd9..4571798 100644
--- a/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt
+++ b/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt
@@ -26,7 +26,7 @@ class AutoLayoutView(context: Context) : ReactViewGroup(context) {

     /** Overriding draw instead of onLayout. RecyclerListView uses absolute positions for each and every item which means that changes in child layouts may not trigger onLayout on this container. The same layout
      * can still cause views to overlap. Therefore, it makes sense to override draw to do correction. */
-    override fun dispatchDraw(canvas: Canvas?) {
+    override fun dispatchDraw(canvas: Canvas) {
         fixLayout()
         fixFooter()
         super.dispatchDraw(canvas)
RKowalczykOnPoint commented 1 year ago

Is there any way to make it work with expo eas build? "react-native": "0.72.3", "@shopify/flash-list": "1.4.3"

davidcort commented 1 year ago

Is there any way to make it work with expo eas build? "react-native": "0.72.3", "@shopify/flash-list": "1.4.3"

Hi, you could try change the kotlinVersion to: kotlinVersion = '1.8.10'

That works for me in Expo SDK 49 :)

"react-native": "0.72.3", "@shopify/flash-list": "1.4.3"

nicolascavallin commented 1 year ago

diff --git a/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt b/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt index 6b78bd9..4571798 100644 --- a/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt +++ b/node_modules/@shopify/flash-list/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt @@ -26,7 +26,7 @@ class AutoLayoutView(context: Context) : ReactViewGroup(context) {

 /** Overriding draw instead of onLayout. RecyclerListView uses absolute positions for each and every item which means that changes in child layouts may not trigger onLayout on this container. The same layout
  * can still cause views to overlap. Therefore, it makes sense to override draw to do correction. */
  • override fun dispatchDraw(canvas: Canvas?) {
  • override fun dispatchDraw(canvas: Canvas) { fixLayout() fixFooter() super.dispatchDraw(canvas)

Working, thanks @siyahulhaq