Saya baru-baru ini memutakhirkan versi SDK expo saya dari 35 menjadi 41 dan juga memutakhirkan expo-cli dari 3.18.5 ke 4.4.3. Namun, ketika saya mencoba membuat APK/AAB mandiri, saya mendapatkan kesalahan berikut:
× Build failed. Standalone build failed!
Untuk memahami apa yang sebenarnya menyebabkan masalah ini, saya memeriksa log Gradle dari build Gradle di pameran, dan inilah yang dapat saya temukan.

Installing unimodules:
 unimodules-core@7.1.0 from /app/turtle/workingdir/android/sdk41/packages/@unimodules/core
 unimodules-react-native-adapter@6.2.2 from /app/turtle/workingdir/android/sdk41/packages/@unimodules/react-native-adapter
 expo-application@3.1.2 from /app/turtle/workingdir/android/sdk41/packages/expo-application
 expo-barcode-scanner@10.1.2 from /app/turtle/workingdir/android/sdk41/packages/expo-barcode-scanner
 expo-camera@11.0.2 from /app/turtle/workingdir/android/sdk41/packages/expo-camera
 expo-constants@10.1.3 from /app/turtle/workingdir/android/sdk41/packages/expo-constants
 expo-error-recovery@2.1.0 from /app/turtle/workingdir/android/sdk41/packages/expo-error-recovery
 expo-file-system@11.0.2 from /app/turtle/workingdir/android/sdk41/packages/expo-file-system
 expo-font@9.1.0 from /app/turtle/workingdir/android/sdk41/packages/expo-font
 expo-image-loader@2.1.1 from /app/turtle/workingdir/android/sdk41/packages/expo-image-loader
 expo-keep-awake@9.1.2 from /app/turtle/workingdir/android/sdk41/packages/expo-keep-awake
 expo-notifications@0.11.6 from /app/turtle/workingdir/android/sdk41/packages/expo-notifications
 unimodules-app-loader@2.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-app-loader
 expo-permissions@12.0.1 from /app/turtle/workingdir/android/sdk41/packages/expo-permissions
 unimodules-barcode-scanner-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-barcode-scanner-interface
 unimodules-camera-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-camera-interface
 unimodules-constants-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-constants-interface
 unimodules-face-detector-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-face-detector-interface
 unimodules-file-system-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-file-system-interface
 unimodules-font-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-font-interface
 unimodules-image-loader-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-image-loader-interface
 unimodules-permissions-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-permissions-interface
 unimodules-sensors-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-sensors-interface
 unimodules-task-manager-interface@6.1.0 from /app/turtle/workingdir/android/sdk41/packages/unimodules-task-manager-interface
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Task :app:preBuild UP-TO-DATE
> Task :app:extractProguardFiles
> Task :app:preReleaseBuild
> Task :app:compileReleaseRenderscript NO-SOURCE
> Task :app:generateReleaseResValues
> Task :app:generateReleaseResources
> Task :app:processReleaseGoogleServices
Parsing json file: /app/turtle/workingdir/android/sdk41/android-shell-app/app/google-services.json
> Task :app:createReleaseCompatibleScreenManifests
> Task :app:extractDeepLinksRelease
> Task :app:mergeReleaseResources
> Task :app:processReleaseMainManifest
[com.facebook.soloader:soloader:0.8.2] /root/.gradle/caches/transforms-3/cfd0b9e5b303f54f13e669e38ab029ae/transformed/jetified-soloader-0.8.2/AndroidManifest.xml Warning:
    Package name 'com.facebook.soloader' used in: com.facebook.soloader:soloader:0.8.2, com.facebook.soloader:annotation:0.8.2.
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:35:1-94 Warning:
    Element uses-permission#android.permission.SYSTEM_ALERT_WINDOW at AndroidManifest.xml:35:1-94 duplicated with element declared at AndroidManifest.xml:16:3-76
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:23:1-101 Warning:
    uses-permission#android.permission.ACCESS_BACKGROUND_LOCATION was tagged at AndroidManifest.xml:23 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:24:1-87 Warning:
    uses-permission#android.permission.RECORD_AUDIO was tagged at AndroidManifest.xml:24 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:26:1-89 Warning:
    uses-permission#android.permission.WRITE_CONTACTS was tagged at AndroidManifest.xml:26 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:32:1-88 Warning:
    uses-permission#android.permission.USE_BIOMETRIC was tagged at AndroidManifest.xml:32 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:33:1-82 Warning:
    uses-permission#android.permission.VIBRATE was tagged at AndroidManifest.xml:33 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:34:1-91 Warning:
    uses-permission#android.permission.READ_PHONE_STATE was tagged at AndroidManifest.xml:34 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:35:1-94 Warning:
    uses-permission#android.permission.SYSTEM_ALERT_WINDOW was tagged at AndroidManifest.xml:35 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:37:1-83 Warning:
    uses-permission#android.permission.READ_SMS was tagged at AndroidManifest.xml:37 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:38:1-99 Warning:
    uses-permission#android.permission.REQUEST_INSTALL_PACKAGES was tagged at AndroidManifest.xml:38 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:41:1-104 Warning:
    uses-permission#com.android.launcher.permission.INSTALL_SHORTCUT was tagged at AndroidManifest.xml:41 to remove other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:208:5-213:39 Warning:
    activity#com.facebook.FacebookActivity@android:theme was tagged at AndroidManifest.xml:208 to replace other declarations but no other declaration present
/app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/AndroidManifest.xml:17:9-26:20 Warning:
    provider#expo.modules.filesystem.FileSystemFileProvider@android:authorities was tagged at AndroidManifest.xml:17 to replace other declarations but no other declaration present
> Task :app:processReleaseManifest
> Task :app:processApplicationManifestReleaseForBundle
> Task :app:mergeReleaseShaders
> Task :app:compileReleaseShaders NO-SOURCE
> Task :app:generateReleaseAssets UP-TO-DATE
> Task :app:mergeReleaseAssets
> Task :app:compileReleaseAidl
 NO-SOURCE
> Task :app:generateReleaseBuildConfig
> Task :app:checkReleaseDuplicateClasses
> Task :app:javaPreCompileRelease
> Task :app:checkReleaseAarMetadata
> Task :app:processReleaseJavaRes NO-SOURCE
> Task :app:bundleReleaseResources
> Task :app:mergeReleaseJniLibFolders
> Task :app:collectReleaseDependencies
> Task :app:configureReleaseDependencies
> Task :app:parseReleaseIntegrityConfig
> Task :app:validateSigningRelease
> Task :app:processReleaseManifestForPackage
> Task :app:mergeReleaseNativeLibs
> Task :app:processReleaseResources
> Task :app:mergeReleaseJavaResource
> Task :app:compileReleaseJavaWithJavac
[stderr] /app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:8: error: package expo.modules.splashscreen does not exist
[stderr] import expo.modules.splashscreen.SplashScreenImageResizeMode;
[stderr]                                 ^
[stderr] /app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:25: error: cannot find symbol
[stderr]   public static SplashScreenImageResizeMode SPLASH_SCREEN_IMAGE_RESIZE_MODE = SplashScreenImageResizeMode.CONTAIN;
[stderr]                 ^
[stderr]   symbol:   class SplashScreenImageResizeMode
[stderr]   location: class AppConstants
[stderr] /app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:25: error: cannot find symbol
[stderr]   public static SplashScreenImageResizeMode SPLASH_SCREEN_IMAGE_RESIZE_MODE = SplashScreenImageResizeMode.CONTAIN;
[stderr]                                                                               ^
[stderr]   symbol:   variable SplashScreenImageResizeMode
[stderr]   location: class AppConstants
[stderr] /app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:53: error: cannot access SplashScreenImageResizeMode
[stderr]     constants.SPLASH_SCREEN_IMAGE_RESIZE_MODE = SPLASH_SCREEN_IMAGE_RESIZE_MODE;
[stderr]                                               ^
[stderr]   class file for expo.modules.splashscreen.SplashScreenImageResizeMode not found
[stderr] 4 errors
> Task :app:compileReleaseJavaWithJavac FAILED
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:compileReleaseJavaWithJavac'.
[stderr] > Compilation failed; see the compiler error output for details.
[stderr] * Try:
[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.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 35s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings
26 actionable tasks: 26 executed
Error: ./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:976: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)

Jika kita perhatikan log di atas, dapat dilihat bahwa masalahnya sebagian besar berkaitan dengan layar Splash.

[stderr] /app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:8: error: package expo.modules.splashscreen does not exist
[stderr] import expo.modules.splashscreen.SplashScreenImageResizeMode;
[stderr]                                 ^
[stderr] /app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:25: error: cannot find symbol
[stderr]   public static SplashScreenImageResizeMode SPLASH_SCREEN_IMAGE_RESIZE_MODE = SplashScreenImageResizeMode.CONTAIN;
[stderr]                 ^
[stderr]   symbol:   class SplashScreenImageResizeMode
[stderr]   location: class AppConstants
[stderr] /app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:25: error: cannot find symbol
[stderr]   public static SplashScreenImageResizeMode SPLASH_SCREEN_IMAGE_RESIZE_MODE = SplashScreenImageResizeMode.CONTAIN;
[stderr]                                                                               ^
[stderr]   symbol:   variable SplashScreenImageResizeMode
[stderr]   location: class AppConstants
[stderr] /app/turtle/workingdir/android/sdk41/android-shell-app/app/src/main/java/host/exp/exponent/generated/AppConstants.java:53: error: cannot access SplashScreenImageResizeMode
[stderr]     constants.SPLASH_SCREEN_IMAGE_RESIZE_MODE = SPLASH_SCREEN_IMAGE_RESIZE_MODE;
[stderr]                                               ^
[stderr]   class file for expo.modules.splashscreen.SplashScreenImageResizeMode not found
[stderr] 4 errors
> Task :app:compileReleaseJavaWithJavac FAILED
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:compileReleaseJavaWithJavac'.
[stderr] > Compilation failed; see the compiler error output for details.
[stderr] * Try:
[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.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 35s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.

Ini app.json saya

{
  "expo": {
    "name": "APP_NAME",
    "slug": "APP_SLUG",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "version": "1.0.1",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "BUNDLE_IDENTIFIER"
    },
    "android": {
      "package": "APP_PACKAGE",
      "softwareKeyboardLayoutMode": "pan",
      "versionCode": 1,
      "permissions": [
        "CAMERA"
      ],
      "enableDangerousExperimentalLeanBuilds": true
    }
  }
}

Pembangunan berhasil dengan versi SDK yang lebih lama, tetapi beberapa paket tidak kompatibel dengan SDK yang lebih lama, oleh karena itu saya harus memutakhirkannya ke yang terbaru. Aplikasi berjalan dengan baik di aplikasi seluler expo go, tetapi tidak dapat membuat aplikasi mandiri.
Bagaimana cara mengatasi masalah ini? Atau, apakah mungkin untuk menurunkan versi dari SDK 41 ke 40 atau 39? Setiap saran atau rekomendasi dihargai.

1
Prajwal Kulkarni 8 Mei 2021, 14:33

1 menjawab

Jawaban Terbaik

Ada dua alasan utama untuk penyebab ini.

  1. Menyetel enableDangerousExperimentalLeanBuils ke true.
  2. Paket expo-splash-screen tidak ada.

Kesalahannya adalah karena (Gradle build) mencari paket expo-modules-splashscreen, yang seharusnya dipindahkan dari modul utama expo di SDK 41, karenanya perlu diinstal secara terpisah. Untuk memperbaikinya, ada dua solusi:

  1. Hapus properti enableDangerousExperimentalLeanBuilds. (Tidak diuji)
  2. Instal expo-splash-screen menggunakan npm install expo-splash-screen.(Diuji dan berfungsi)
0
Prajwal Kulkarni 8 Mei 2021, 18:04