[solved] android how to develop and edit expoview after eject

I would like to know how I could use expo-view source instead of the precompiled .aar-File.
To avoid missunderstands:

  • I know how to eject (successfully)
  • I know how to create native modules (successfully)

But I don’t know how to edit for example host.exp.exponent.experience.DetachActivity. Its in the precompiled aar-Library host.exp.exponent:expoview.

So could please one the expo-team explain how to work with expoview-sources instead of aar-lib?

Hi @anil_from_the_alps - thanks for the question! In order to edit the compiled expoview code, the best way is to clone this repo: GitHub - expo/expo: An open-source platform for making universal native apps with React. Expo runs on Android, iOS, and the web. . If you follow the setup instructions for Android Studio & the NDK, then you should be able to edit and modify the expoview source files and then generate a new aar yourself.

Let us know if you have questions about this. We’re working on improving this workflow right now, so your feedback would be appreciated!

Hi @esamelson,

according to the steps mentioned on expo/README.md at master · expo/expo · GitHub
I successfully compiled the expo-client to run in the android-simulator. I did nothing for IOS.

Now I try to continue, but I have some problems. The section “Standalone Apps” tells me

You’ll need to add the appropriate fields to your app.json before the standalone app scripts can run

…ok so after successfully compiling expo-client, then I modified app.json in directory `home``

  • removed
    isKernel: true,
  • removed
    kernel: { iosManifestPath: "../ios/Exponent/Supporting/kernel-manifest.json", androidManifestPath: "../android/app/src/main/assets/kernel-manifest.json" }

… then expo start

… then in Expo DevTool publish

… then I get many errors in the commandline


[15:06:39] Building iOS bundle
[15:06:39] 500 - "{\"type\":\"TransformError\",\"lineNumber\":0,\"errors\":[{\"description\":\"/Users/anil/my/code/expoClone/master3Okt/home/.expo/AppEntry.js: Plugin/Preset files are not allowed to export objects, only functions. In /Users/anil/my/code/expoClone/master3Okt/node_modules/babel-preset-expo/index.js\",\"lineNumber\":0}],\"name\":\"SyntaxError\",\"message\":\"/Users/anil/my/code/expoClone/master3Okt/home/.expo/AppEntry.js: Plugin/Preset files are not allowed to export objects, only functions. In /Users/anil/my/code/expoClone/master3Okt/node_modules/babel-preset-expo/index.js\",\"stack\":\"Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/anil/my/code/expoClone/master3Okt/node_modules/babel-preset-expo/index.js\\n    at createDescriptor (/Users/anil/my/code/expoClone/master3Okt/home/node_modules/@babel/core/lib/config/config-descriptors.js:178:11)\\n    at items.map (/Users/anil/my/code/expoClone/master3Okt/home/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)\\n    at Array.map (<anonymous>)\\n    at createDescriptors (/Users/anil/my/code/expoClone/master3Okt/home/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)\\n    at createPresetDescriptors (/Users/anil/my/code/expoClone/master3Okt/home/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)\\n    at presets (/Users/anil/my/code/expoClone/master3Okt/home/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)\\n    at mergeChainOpts (/Users/anil/my/code/expoClone/master3Okt/home/node_modules/@babel/core/lib/config/config-chain.js:315:26)\\n    at /Users/anil/my/code/expoClone/master3Okt/home/node_modules/@babel/core/lib/config/config-chain.js:278:7\\n    at mergeExtendsChain (/Users/anil/my/code/expoClone/master3Okt/home/node_modules/@babel/core/lib/config/config-chain.js:294:21)\"}"
[15:06:39] /Users/anil/my/code/expoClone/master3Okt/home/.expo/AppEntry.js: Plugin/Preset files are not allowed to export objects, only functions. In /Users/anil/my/code/expoClone/master3Okt/node_modules/babel-preset-expo/index.js

… should I build before for IOS?
…am I missing something… or is this the complete wrong aproach?

Hi @anil_from_the_alps - thanks for the question. The code in the home directory is for the JS experience that you see when you run Expo client. You shouldn’t need to run or modify this; rather, the “standalone apps” section is referring to your own app.

If you’ve already detached your app, you should already have everything you need in its app.json, so you can just go ahead and publish that as usual from Dev Tools. Then you can pass the URL into the gulp android-shell-app script as described in the README. The gulp android-shell-app will build your standalone app locally, just like what happens on our servers when you run expo build:android – but it will use the code in the android directory, along with any modifications you’ve made to that.

Hope that helps! Let me know if that still doesn’t make sense.

1 Like

hi @esamelson,

thanks a lot - I am nearly at my goal. Now I have a better understanding.

  • I created outside of the cloned-expo directory a small micro app
  • then I published
  • then I went back to the cloned-expo directory to tools-public
  • then I created an unsigned apk by gulp android-shell-app...
  • I also can open the directory android-shell-app in android studio
    —> success :grinning:

One question is open:
When I open android-shell-app in android-studio, how can I do active development with my micro-project? I already edited DetachBuildConstants.java#DEVELOPMENT_URL to my active running expo-development server, but when I click then in android-studio on run-debug, the apk does not use local-development-server. I would like to achieve now the same behaviour as I am used to do it with ‘ejected projects’.

Hi @anil_from_the_alps - glad you got it working! :smiley: You’re very close – in the case of gulp android-shell-app you’ll need to edit the INITIAL_URL constant in AppConstants.java instead. Just don’t forget to put it back to your published project URL when you’re done.

Hi @esamelson,

thanks for your support.
These informations led me to a complete new approach for our team. First I wanted to create my custom expoview.aar. But now we made something different. We built now our own expoclient for internal development. In the past one developer only used expoclient and the other one made the native stuff. But whenever the expoclient-only developer wanted to test our custom native modules he had to use android-studio with “detached stuff”. But now the “native guy” (me :laughing:) creates an expoclient for the team. And all team-members can test the native modules without using android-studio. Our development flow has been massively improved.

Best Regards and thanks from Austria
:tada::tada::tada:
Anil

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.