Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
405 views
in Technique[技术] by (71.8m points)

android - Expo build crashed when using "enableDangerousExperimentalLeanBuilds"

I'm pretty much new to react native currently i'm developing a small app to get a better idea on this using expo. But when i build the apk files it goes up to 53 mb which makes no sense because app has only limited functionalities. After i searched in google i found that by adding this "enableDangerousExperimentalLeanBuilds" : true to the app.json file will reduce the app size. But after i adding this to the app.json file app build got error. I don't know how to fix this. Also is there any way to reduce the app size.

This is tha app.json file

{
  "expo": {
    "name": "ceculator",
    "slug": "ceculator",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "com.ceculator",
      "enableDangerousExperimentalLeanBuilds" : true
    },
    "web": {
      "favicon": "./assets/favicon.png"
    }
  }
}

This is the error log

    Wed, 30 Dec 2020 12:15:12 GMT[stderr] /app/turtle/workingdir/android/sdk40/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:8: error: package expo.modules.splashscreen does not exist

Wed, 30 Dec 2020 12:15:12 GMT[stderr] import expo.modules.splashscreen.SplashScreenImageResizeMode;

Wed, 30 Dec 2020 12:15:12 GMT[stderr]                                 ^

Wed, 30 Dec 2020 12:15:12 GMT[stderr] /app/turtle/workingdir/android/sdk40/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:25: error: cannot find symbol

Wed, 30 Dec 2020 12:15:12 GMT[stderr]   public static SplashScreenImageResizeMode SPLASH_SCREEN_IMAGE_RESIZE_MODE = SplashScreenImageResizeMode.CONTAIN;

Wed, 30 Dec 2020 12:15:12 GMT[stderr]                 ^

Wed, 30 Dec 2020 12:15:12 GMT[stderr]   symbol:   class SplashScreenImageResizeMode

Wed, 30 Dec 2020 12:15:12 GMT[stderr]   location: class AppConstants

Wed, 30 Dec 2020 12:15:12 GMT[stderr] /app/turtle/workingdir/android/sdk40/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:25: error: cannot find symbol

Wed, 30 Dec 2020 12:15:12 GMT[stderr]   public static SplashScreenImageResizeMode SPLASH_SCREEN_IMAGE_RESIZE_MODE = SplashScreenImageResizeMode.CONTAIN;

Wed, 30 Dec 2020 12:15:12 GMT[stderr]                                                                               ^

Wed, 30 Dec 2020 12:15:12 GMT[stderr]   symbol:   variable SplashScreenImageResizeMode

Wed, 30 Dec 2020 12:15:12 GMT[stderr]   location: class AppConstants

Wed, 30 Dec 2020 12:15:12 GMT[stderr] /app/turtle/workingdir/android/sdk40/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:53: error: cannot access SplashScreenImageResizeMode

Wed, 30 Dec 2020 12:15:12 GMT[stderr]     constants.SPLASH_SCREEN_IMAGE_RESIZE_MODE = SPLASH_SCREEN_IMAGE_RESIZE_MODE;

Wed, 30 Dec 2020 12:15:12 GMT[stderr]                                               ^

Wed, 30 Dec 2020 12:15:12 GMT[stderr]   class file for expo.modules.splashscreen.SplashScreenImageResizeMode not found

Wed, 30 Dec 2020 12:15:13 GMT[stderr] 4 errors

Wed, 30 Dec 2020 12:15:13 GMT> Task :app:compileReleaseJavaWithJavac FAILED

Wed, 30 Dec 2020 12:15:13 GMT> Task :app:mergeReleaseNativeLibs

Wed, 30 Dec 2020 12:15:13 GMT> Task :app:mergeReleaseJavaResource

Wed, 30 Dec 2020 12:15:13 GMTDeprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

Wed, 30 Dec 2020 12:15:13 GMTUse '--warning-mode all' to show the individual deprecation warnings.

Wed, 30 Dec 2020 12:15:13 GMTSee https://docs.gradle.org/6.6.1/userguide/command_line_interface.html#sec:command_line_warnings

Wed, 30 Dec 2020 12:15:13 GMT20 actionable tasks: 20 executed

Wed, 30 Dec 2020 12:15:13 GMT[stderr] FAILURE: Build failed with an exception.

Wed, 30 Dec 2020 12:15:13 GMT[stderr] * What went wrong:

Wed, 30 Dec 2020 12:15:13 GMT[stderr] Execution failed for task ':app:compileReleaseJavaWithJavac'.

Wed, 30 Dec 2020 12:15:13 GMT[stderr] > Compilation failed; see the compiler error output for details.

Wed, 30 Dec 2020 12:15:13 GMT[stderr] * Try:

Wed, 30 Dec 2020 12:15:13 GMT[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Wed, 30 Dec 2020 12:15:13 GMT[stderr] * Get more help at https://help.gradle.org

Wed, 30 Dec 2020 12:15:13 GMT[stderr] BUILD FAILED in 2m 49s

Wed, 30 Dec 2020 12:15:26 GMTError: ./gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/app/turtle/node_modules/@expo/xdl/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
    at Object.onceWrapper (events.js:418:26)
    at ChildProcess.emit (events.js:311:20)
    at ChildProcess.EventEmitter.emit (domain.js:482:12)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
    ...
    at spawnAsync (/app/turtle/node_modules/@expo/xdl/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
    at spawnAsyncThrowError (/app/turtle/node_modules/@expo/xdl/build/detach/ExponentTools.js:201:45)
    at buildShellAppAsync (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidShellApp.js:975:11)
    at async Object.createAndroidShellAppAsync (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidShellApp.js:396:5)
    at async runShellAppBuilder (/app/turtle/build/builders/android.js:95:9)
    at async Object.buildAndroid [as android] (/app/turtle/build/builders/android.js:43:28)
    at async build (/app/turtle/build/jobManager.js:181:33)
    at async processJob (/app/turtle/build/jobManager.js:118:32)
    at async Object.doJob (/app/turtle/build/jobManager.js:49:5)
    at async main (/app/turtle/build/server.js:66:13)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As the property already says, it is an experimental and dangerous feature. So the chance that it does not work is high.

However, if I get you correctly, what you intentionally wanted to do is to reduce the size of the apk.

Remember that even though your react-native code might be small, there will always be the need for the "frame" of the app (the actual apk, all the expo stuff and so on) which will add to the size.

See this thread on the expo forum: https://forums.expo.io/t/apk-size-is-too-large/3462

In case you are using the bare workflow, it might be worth trying the managed workflow. Although there is a higher initial payload, the final apk might be smaller than the one you are producing with bare workflow when being unexperienced.

In addition, instead of the experimental feature, go check your assets' sizes. Remember that some of them (such as the app icon) will be generated in several resolutions during the build process and therefore causes multiple times of the space that it takes on your workspace


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...