[Resolved] Android build fails with "TypeError: Cannot read property 'package' of undefined"


#1

Hi,

This morning, I’m trying to build for Android through exp and I’m getting this error: “TypeError: Cannot read property ‘package’ of undefined”.

My build ID is 597078bd-5a31-4485-9cc8-7db40eee9da7. I’ve tried this twice and got the same error. I do have android.package defined, so I’m not sure what “package” field it has a problem with.

Build log:

▼configuring builder
release channel: test
▼generating keystore
[stderr] Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
[stderr] 	for: CN=, OU=, O=, L=, ST=, C=US
[stderr] [Storing /tmp/new-keystore-3683b9aa-5741-4a9b-be65-033caccbe46c.keystore]
▼running gulp task
[13:30:36] Using gulpfile /src/exponent/tools-public/gulpfile.js
[13:30:36] Starting 'android-shell-app'...
▼reading manifest
Using manifest: {"bundledAssets":["asset_7e45bc5571abde2f2d2c5b65b617c884.jpg","asset_ed602a0088332e6415a7f8c45d6b8ea5.png","asset_9f3e65e4d2c5a8ace193f6ed92af9d4f.png","asset_bbd747809118266dd0701fde41e67639.png","asset_c8aeee83f4cbb5e873bccdafef37083c.png","asset_4888702d613cc0008d2866c124c2b8f7.png","asset_c4fa3ca9c0b7884df7b8d97f552c5944.png","asset_5f7bfb5046f57be1c24d771fd7d1a44c.png","asset_d45adbdf03748e0b4db9916598d2608e.png","asset_e19df598768a83f0e7028cf1621b21cd.png","asset_a8ce35df971252a846b310bdd6898aa1.png","asset_d476b0ac8dad2b98be11015f0cf417ee.png","asset_b2c42d52505c3b1aaa98910a599107d6.png","asset_a18785eb43894ca9846884d94d6885fe.png","asset_7c5ac3a13106d3b46f163e1a97eefdd3.png","asset_136786757f0754d422bcb4d825c62291.png","asset_fe7a0c32789467cd3ae7bc3e9560de69.png","asset_c834230e54d04b59e4799e7a86cfe2f4.png","asset_ecbc5b18554f29e5acdd7ae4b110ae99.png","asset_f2ccf4a38cbd46c6a746c4161803bb07.png","asset_8c4d8003a219a0bd8e9a29b843f679b9.png","asset_36bcb5e154538f71ab24312a3b3ff9ee.png"],"description":"An empty new project","icon":"./current-brand/platforms/ios/Nudge/Images.xcassets/AppIcon.appiconset/icon-1024.png","iconUrl":"https://d1wp6m56sqw74a.cloudfront.net/~assets/43ae899215814db507ceffa0bded05b2","ios":{"supportsTablet":false},"locales":{},"name":"Nudge","orientation":"portrait","packagerOpts":{"assetExts":["ttf","mp4"]},"primaryColor":"#FFA200","privacy":"unlisted","sdkVersion":"26.0.0","slug":"nudge-firstparty-9b512a","splash":{"backgroundColor":"#FFA200","image":"./current-brand/res/ios/splash/Default@2x~universal~anyany.png","imageUrl":"https://d1wp6m56sqw74a.cloudfront.net/~assets/c0f0dca0b7dab48bee7bc52ea2f89dd7","resizeMode":"cover"},"version":"1.0.0","id":"@nudge/nudge-firstparty-9b512a","revisionId":"1.0.0-r.ej0xWllQdy","publishedTime":"2018-04-21T02:41:00.229Z","bundleUrl":"https://d1wp6m56sqw74a.cloudfront.net/%40nudge%2Fnudge-firstparty-9b512a%2F1.0.0%2F546e09d0e4a9aff96cbb76b5a007cddc-26.0.0-android.js","releaseChannel":"test"}
▼generating dynamic macros
/src/exponent/tools-public /src/exponent/android/app
[13:30:42] 
Using gulpfile /src/exponent/tools-public/gulpfile.js
[13:30:42] 
Starting 'generate-dynamic-macros'...
Downloading DEV published kernel manifest...
[stderr] Unable to download manifest from undefined: Can't read JSON file: /src/exponent/dev-home-config.json
[stderr] └─ Cause: Error: ENOENT: no such file or directory, open '/src/exponent/dev-home-config.json'
Using published dev version of Expo Home
[13:30:42] 
Finished 'generate-dynamic-macros' after 45 ms
/src/exponent/android/app
▼copying initial shell app files
Warning: Could not copy android.iml to shell app directory.
▼running gulp task
[stderr] [13:30:45] 'android-shell-app' errored after 9.49 s
[stderr] [13:30:45] TypeError: Cannot read property 'package' of undefined
[stderr]     at /xdl/src/detach/AndroidShellApp.js:402:38
[stderr]     at Generator.next (<anonymous>)
[stderr]     at step (/src/exponent/tools-public/node_modules/xdl/build/detach/AndroidShellApp.js:627:191)
[stderr]     at /src/exponent/tools-public/node_modules/xdl/build/detach/AndroidShellApp.js:627:437
[stderr]     at new Promise (<anonymous>)
[stderr]     at /src/exponent/tools-public/node_modules/xdl/build/detach/AndroidShellApp.js:627:99
[stderr]     at runShellAppModificationsAsync (/src/exponent/tools-public/node_modules/xdl/build/detach/AndroidShellApp.js:474:18)
[stderr]     at Object.<anonymous> (/xdl/src/detach/AndroidShellApp.js:352:9)
[stderr]     at Generator.next (<anonymous>)
[stderr]     at step (/src/exponent/tools-public/node_modules/xdl/build/detach/AndroidShellApp.js:627:191)

#2

Error resolved! Based on this other issue (Error building for Android) and some thinking, I think this is the sequence of events that can cause the error:

  1. Create a basic app.json that’s only good for publishing (no ios/ android sections).
  2. Publish.
  3. Update your app.json to include ios/ android sections. (but don’t publish)
  4. Build with the --no-publish flag.

I think the disconnect for me was that I assumed I didn’t need to publish again because my JS was already up-to-date. However, publishing is for updating your JS and your app.json. Even if your app.json updates are only relevant to a standalone build, they still need to be uploaded as part of the publish process.


#3

Thanks for all the details! This behavior is indeed intentional but we could have definitely provided a better error when you tried running exp build with --no-publish.


closed #4

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