Correct way to publish detached app

#1

Hi Expo devs,

I work on an app and needed to detach my project since I need a background interval function (I use ocetnik/react-native-background-timer).
Im able to test my app within Android Studio with Genymotion correctly. But when I test my app on my phone within the Expo app the react-native-background-timer doesn’t work.
This is correct behaviour I guess since native modules outside Expo are not supported.
So, If I want to successfully test my app on my phone I need to build a standalone android app? But when I try ‘exp build:android’, expo complains ‘exp build’ is not supported for detached apps.
It’s a little bit confusing for me. What is the correct way to build my detached android app?

1 Like

#2

Ok, never mind.

I understand the flow now. I can just treat the detached app as a ‘normal’ Android app.
However, when you’re new with Expo (and even new with native app development) the whole detach feature makes Expo a little bit confusing in my opinion.
Probably when you already have experience with native app development going into detached mode is easier to understand…

1 Like

#3

Thanks for the feedback, that’s definitely true! Going to “Native Land” opens an enormous can of worms that hopefully beginners can avoid as long as possible thanks to Expo!

Any feedback on how we can help it be less confusing for new developers?

0 Likes

#4

Well I think it would be really helpful to have some kind of topic how to work on the app after choosing detach mode.

First questions which I had;

  1. How to deploy my app now? Am I still dependent on the expo app? Should I treat it like a react native app?
  2. Can I use everything from react native now ? What about react native updates?
  3. What happens with expo updates after detaching my app?
4 Likes

#5

I agree with you and expanding on #1 I think this would be a very useful to have more info for people who are new regarding continued development of a detached app in Xcode & Android Studio.

Hopefully in time the EXPO SDK will support the native module which I am sure will be greatly welcomed by the community.

0 Likes

#6

cc @ben for some useful feedback on improvements to the detach docs.

0 Likes

#7

Yeah I’m confused as well - I’m trying to build a standalone iOS app and am following the docs, but am getting exp build is not supported for detached projects. To be specific, my app is detached with Expo Kit and I am trying to get a version of an iOS app ready to use in TestFlight.

In my app directory, I have run exp start. In a separate terminal window, same directory, I ran exp build:ios and get the error. Do I need XDE running? Do I need to do anything with Xcode? I presume not but it’s not working so I’m not sure. The docs are a little vague on exactly what to do here. That error message is probably not appropriate considering exp build is supported for detached projects? Or am I misunderstanding the process completely? I would appreciate some advice.

@mtvanderplaat how did you work this out?
cc @dikaiosune

1 Like

#8

OK yeah I think I get it too. It’s already a standalone app if it’s detached, pretty much? There is no need to run exp build. If that’s the case, mentioning that specifically on the Publish page would be good.

0 Likes

#9

Yeah, it’s already a “standalone app” if you’ve detched. I believe this is covered on the expokit docs, but I agree we probably should mention it anywhere we talk about standalone builds and publishing (cc @ben). Can you link me to the “Publish page” you’re referring to? I think we have a few places we talk about publishing in the docs.

1 Like

#10

Thanks @dikaiosune - the “Deploying to the App Store and Play Store” section starts with “When you’re ready to distribute your app to end-users, you can create a standalone app binary (an ipa or apk file) and put it in the iOS App Store and the Google Play Store.”. I think simply adding something like “If you are developing with ExpoKit, you already have a standalone app running in Xcode or Android Studio” would be really helpful.

https://docs.expo.io/versions/latest/guides/publishing.html

0 Likes

#11

exp build is not supported for detached projects.

  1. after detached projects , can i use ’ react-native bundle XXXXX ’ then drop to xcode?
    like: https://segmentfault.com/a/1190000004189538

  2. after bundle, i cannot find

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"index.ios" withExtension:@"jsbundle"];

how can i do?

0 Likes

#12

I am trying to deploy on testflight a detached expo project but when the app tries to use any native library it crash and says: “undefined is not an object (evaluating “native function’s name” (code 1)”

Do anyone knows how to do this?. I want to use expo but if i cant fix this ill have to go with react-native alone

1 Like

#13

Hello! Please share your project or more information about the problem. We cannot debug the most common error in JavaScript (undefined is not a *) without seeing the code. I’m brentvatne on Github if you would like to share the code there.

0 Likes

#14

I have the exact same problem. I cannot see anything about it in documentation…
I am on windows 10
How it happens is…

  1. I have expo app.
  2. dettach the app to ExpoKit
  3. install libraries which I can do react-native link …
    It says linking successful.
  4. I import the library in the react component file.
  5. When I execute a function from the library in the app running in XDE or exp start, it complains that 'undefined is not an object"…
  6. So, I wonder if I have to run the app in android studio, but the app does not seem to work in android studio - when I open the android folder, it says ‘BUILD FAILD’ with error
    Error:Execution failed for task ‘:app:processDev19DebugGoogleServices’.

Failed to delete: C:\Users\HP Pavilion\Documents\noby-coding\react-native-pdf\android\app\build\generated\res\google-services\dev19\debug

When I open a simulator via AVD manager, it opens a simulator device but does nothing.

Here is the repo I created to reproduce the issue.

If you run this app, you may see what I am not doing right?

Thank you!

0 Likes

#15

Hey @nfabacus - you’re right, you will need to run the app in Android Studio (or from the command line) rather than using XDE & the Expo client.

I tried cloning your repo and running the app, and it immediately warned me that

[exp] Error: Problem validating fields in app.json. See https://docs.expo.io/versions/v25.0.0/guides/configuration.html.
[exp] • Field: android.package - 'android.package' should be a reverse DNS notation unique name for your app. For example, host.exp.exponent, where exp.host is our domain and Expo is our app..

I was never able to get much farther because trying to build the Android app created more issues stemming from this one.

Here is what I would suggest:

  1. un-detach your app, or go back to a time before you detached. (to un-detach, delete the android directory and the isDetached and detach keys in app.json)
  2. set android.package in your app.json - see rules here for allowed characters
  3. run exp detach again
  4. you will need to react-native link your native modules again
  5. serve the JS package by running exp start
  6. run the android app, either from Android Studio, or by running ./gradlew installDevDebug inside of the android directory. Note that if you use Android Studio, make sure to use the dev build variant instead of dev19 (you can set this in the lower left hand corner of the UI).

Let us know if that doesn’t fix things.

0 Likes

#16

HI, esameison

OK, I tried again as you suggested.
Here is the repo.

When I tried ./gradlew installDevDebug inside of the android directory, first time it failed. second time it built the app, and it installed the app in the simulator device. However,
I see the message below in the terminal.

Parallel execution with configuration on demand is an incubating feature.
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Android\sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

NDK is missing a "platforms" directory.g dependencies ':app:_devRemoteKernelDebugApk' > :react-native-html-to-pdf
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Android\sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Also, when I call the linked library’s function in the running app, it crashes…
exp also complains that I need to do npm install again, which I have done many times.

Your help is appreciated, as I have no idea how to solve this issue.

Thank you

0 Likes

MailComposer Attachments not working (android)
#17

Just as a follow up, I think there is an issue of linking non-expo library after detach. Even after my app is running, it crashes as soon as I try to use the non-expo library as it cannot see the library (undefined).

The non-expo library I am trying to use is

This library works fine with a pure react native project, but not with a detached Expo project (ExpoKit).
You will see if you create a brand new project with expo/crna, and detach it. and add the library and link it. It will not work. I don’t think this issue is only for the library mentioned above, but also for other non-expo libraries.
To prove me wrong, can anyone try to detach and link actually work?

0 Likes

#18

@nfabacus, I am able to detach my expo project and then followed the https://facebook.github.io/react-native/docs/signed-apk-android.html. But I am seeing EXPO user interface when I installed the APK in phone. Please let me know if you have any idea ?

0 Likes

#19

Hi, @dhana Sorry I am not sure what you mean.
I can also detach my expo app, and run it. I can also install non-expo libraries, and ‘link’ them. But, as soon as I run my app and try to use non-expo libraries, my app crashes. I am not sure why and have not been able to get any answers in the forum that work for me.

In the end, I rebuilt my app with react-native cli without Expo, using non-expo libraries. It works fine. I will not use Expo anymore unless I know from the beginning that it has all the libraries I need.
I have found too complicated and lack of expertise on the internet in making my expoKit app work with non-expo libraries after detaching.

1 Like