ExpoKit / Detached Android changes when upgrading to SDK 24 from 23

Hi all,

I am running a detached app and attempting to upgrade from SDK 23 to 24. Everything upgraded perfectly for iOS with the instructions in the blog post, however, I am having issues with Android.

Following these instructions:

-Additionally, for Android you will need to create a new project with exp init, run exp detach on it and copy the changes over because there were some changes to how ExpoKit runs on Android.

When I run exp detach I am getting this error:

[exp] Error: Can't determine exponent directory
    at exponentDirectory (/xdl/src/detach/AndroidShellApp.js:27:11)
    at Object.<anonymous> (/xdl/src/detach/AndroidShellApp.js:235:20)
    at Generator.next (<anonymous>)

I also tried copying changes from “temp-android-directory”, but kept getting stuck at:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:exponentPrebuildStep'.

Has anyone been able to successfully upgrade an android detached app to 24? Would love to get some insights on how you did it.

Let me know if you need me to provide more information on my end to help solve this.

Cheers,
Shawn

Hello,

I have the same issue with upgrading from Expo SDK 23 to 24. When I run exp detach on a new blank project created from Expo XDE, I get the following:

[exp] Making sure project is set up correctly...
[exp] Your project looks good!
Validating project manifest...
Skipping iOS because you are not running macOS.
Moving Android project files...
Downloading Android code...
[exp] Can't determine exponent directory
[exp] Set EXPO_DEBUG=true in your env to view the stack trace.

Any help will be appreciated.

getting this as well.

I resolved the issue by setting the EXP_UNIVERSE_DIR environment variable to .expo before running the detach command, as suggested by @mauroporrasp in the related github issue.

2 Likes

Thanks @lihop! That allowed me to detached as well. I’m curious, how did you end up copying the changes over? At first, I tried to make a new project, but it seemed like so much had changed so then I just deleted my android / ios folders and tried to detach the same project again.

The app is building, however, now I am running into some weird issues where my native models (react-native-background-geolocation) seem to be inaccessible; they are getting imported as undefined.

Curious to see if anyone is having similar issues.

Cheers,
Shawn

Hi @voshawn. I haven’t gotten that far yet :grin: but I am also using react-native-background-geolocation (RNBG).

I copied the new files over the top of my projects ones and am now trying to merge back in my modifications most of which were to the apps build.gradle file which has changed around a lot.

How did you install RNBG? I ended up following the manual installation instructions and ran into this issue due to a conflict between the google-play-services version required by RNBG and the one that ships with expo. Got it sorted by following the instructions in that thread though.

Yes, I ran into that same exact problem. I didn’t see that specific thread, but I solved in a very similar manner. See my post here if you’re curious.

I think with this detached version, all of the expo dependencies are in the build.gradle so I think we could simplify the code a bit.

I’m going to take another stab at this today and let you know if I make any progress. Good to hear we are both using RNBG though!

Just an update:

I tried two methods of detaching and they both seemed to build. But in both cases I have an issue related to linking native modules in android.

The first way was just deleting my ios/android folders and then re-detaching.
The second way was making a new exp project and then copying files over.

In both cases, when I tried to link my native modules back into the project on Android, I keep getting:
TypeError: undefined is not an object (evaluating RNBackgroundGeolocation.addEventListener')

I have also tried to install this module on a fresh exp project and am getting the same error.

@lihop If you (or anyone else) are getting the same error please let me know!

Cheers,
Shawn

We’re aware of the issue and are tracking the fix here.

1 Like

Amazing, thanks @ben! Just to clarify, do you think the detaching error is related to not being able to link native modules? If not, I can create a separate issue with details on the linking error.

It looks like the issues are likely separate. I’d recommend using the latest version of exp with the fix for “Can’t determine exponent directory” to isolate potential issues. Getting an issue about an undefined native module sounds like React Native isn’t exposing the module to JS correctly. I’d try debugging React Native (both in Xcode with breakpoints and in JS with console.log and the remote debugger) to get a better idea of what’s going on.