ImagePicker, Expo SDK 44 and EAS Build trhows error on Gradlew build: Unresolved reference: ifNull

Hello everyone, i’m facing this error when Building with EAS and Expo SDK 44, it looks like the ImagePicker module is the cause:

> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (25, 36): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (131, 39): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (133, 7): 'return' is not allowed here
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (138, 71): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (140, 7): 'return' is not allowed here
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (193, 7): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (195, 7): 'return' is not allowed here
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (200, 39): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (202, 7): 'return' is not allowed here
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (325, 8): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (327, 9): 'return' is not allowed here
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (376, 8): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (378, 9): 'return' is not allowed here
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (381, 46): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (383, 7): 'return' is not allowed here
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerOptions.kt: (4, 36): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerOptions.kt: (40, 9): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerOptions.kt: (42, 9): 'return' is not allowed here
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerUtils.kt: (11, 36): Unresolved reference: ifNull
> [stderr] e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerUtils.kt: (32, 39): Unresolved reference: ifNull
> [stderr] FAILURE: Build failed with an exception.
> [stderr] * What went wrong:
> [stderr] Execution failed for task ':expo-image-picker:compileDebugKotlin'.

In your post, please share:

  • Whether you are bare or managed workflow: managed
  • Your eas-cli version: eas-cli/0.41.1 win32-x64 node-v16.13.1
  • What you have tried so far:

I’ve added the plugin in app.json as documentation explains, also i have sentry-expo added.
And installed package:

expo install expo-image-picker
{
  "expo": {
    "plugins": [
      [
        "expo-image-picker",
        {
          "photosPermission": "The app accesses your photos to let you share them with your friends."
        }
      ],
      "sentry-expo"
    ]
  }
}

Using app configurations: (from EAS Build Website)

includes

 "plugins": [
    "expo-image-picker",
    "sentry-expo"
  ],

image

But error persists.

I have the same error have you found a solution?

can you share a reproducible example app on github? i am unable to reproduce this.

Yes I can give you access to the private repository on github but need your github username

i’d prefer to see a minimal reproducible example, you can see how to create one here: How to create a Minimal, Reproducible Example - Help Center - Stack Overflow

1 Like

I was able to reproduce error. Have to say that when I created new App and added only library expo-image-picker it worked fine and build passed well but, when I copied package.json file from my main project I got exactly the same error: Execution failed for task ':expo-image-picker:compileReleaseKotlin'.

[stderr] `e: /root/workingdir/build/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/ImagePickerModule.kt: (25, 36): Unresolved reference: ifNull

Please have a look: GitHub - andrey-grach/ErrorReproduced

1 Like

It must be a module/package conflict, we still no fixed it, we rolled back to a previous SDK version.

I downgraded to "expo-image-picker": "~11.0.3" after that problem has gone but appeared the same one with expo-linear-gradient: Execution failed for task ':expo-linear-gradient:compileReleaseKotlin'. I also downgraded that library from ~11.0.0 to 10.0.3 and problem disappeared and after that I get another one with expo-media-library so I downgraded that package from 14.0.1 to 13.0.3 and now I have this problem: Execution failed for task ':expo:compileReleaseKotlin'

And actually this is my first attempt to build via EAS, so I don’t know if I roll back to previous SDK it will help or not, but thanks for reply.

Not solved yet. I still having the issue. Not able to build by eas. Also I am not getting any error while compilation. -

can you please share a minimal reproducible example? How to create a Minimal, Reproducible Example - Help Center - Stack Overflow

You already have a minimal reproduction repo. :thinking:

i do not. i have a repository with about 80 direct dependencies, that is pretty far from minimal :stuck_out_tongue: ErrorReproduced/package.json at master · andrey-grach/ErrorReproduced · GitHub

You sounds lazy. Just remove them to test. We Don’t know which package is the problem since the error only says things about ‘image-picker’. I know you have work, we have work, you and we want a better Expo, (or not?).

That’s a no custom logic repo, it’s enough for me, since a real world project is not only expo packages.

Hi there! Calling somebody trying to help out “lazy” is not acceptable. As I’m sure you appreciate as a software developer, table stakes for getting help with a possible bug are that someone provide a minimal reproducible example. This is the case on StackOverflow as much as it is here (How do I ask a good question? - Help Center - Stack Overflow). Feel free to fix the issue on your own if you are unable to provide what we need to help you out.

That’s what a lazy says (joke).

Seriously, I just skip. But Thanks to try.

Hi! If it was not what you have been waiting for you could at least tell me that. It would be better than just silence. As I mentioned above problem appeared when I added all the packages from the old project, what should I do now? Should I try to remove packages one by one until build would work and then tell you what package it was? I really want to solve this problem but I don’t know what is the next step?

could you try finding the minimum set of packages that reproduces the issue? we’re happy to investigate further if we have that :slight_smile:

@notbrent

Here you go:

{
  "name": "ifNull-crash",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "^44.0.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "expo-images-picker": "^2.2.4"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}

Note: That’s not expo-image-picker

EDIT: The crash is different depending on whether you have just expo-images-picker installed, or in addition you have expo-linear-gradient or expo-image-picker.

1 Like

thanks! i don’t know what expo-images-picker is :joy: it is not something that we maintain. it looks like it depends on old versions of expo-image-manipulator and expo-media-library. so @laneboyandrew you should remove expo-images-picker from your package.json and just leave expo-image-picker.

@wodin - i’ve tried installing expo-linear-gradient and expo-image-picker in a new project and it builds successfully, can you elaborate on that last point?

edit: i created an issue on expo-images-picker repo with a suggestion Expo module dependencies should be devDependencies · Issue #50 · natysoz/expo-images-picker · GitHub