あたまがゆるふわのエンジニアブログ

あたまがゆるふわなエンジニアの日常をエントリーしまーす

ExpoでEjectしたら全然run-androidできない件について

こんにちは! FGOでキャスターアルトリアを引けてウキウキのワタシです!どうも!

さて、今回は表題の通り、Expoで作成したプロジェクトをEjectしたらさっぱり動かなかったのでその情報共有です。

ちな、以下の環境で開発しています

ignite doctor

System
  platform           win32
  arch               x64
  cpu                12 cores     Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  directory          omt          D:\yurufuwa\omt

JavaScript
  node               12.18.2      C:\Program Files\nodejs\node.EXE
  npm                6.14.5       C:\Program Files\nodejs\npm.CMD
  yarn               1.22.4       C:\Users\mihun\AppData\Roaming\npm\yarn.CMD

Ignite
  ignite-cli           3.5.2              C:\Users\mihun\AppData\Local\Yarn\bin\ignite.CMD

  ignite src           build              C:\Users\mihun\AppData\Local\Yarn\Data\global\node_modules\ignite-cli\build
  navigation           react-navigation

  generators

                       component          ignite-bowser

                       model              ignite-bowser

                       navigator          ignite-bowser

                       screen             ignite-bowser

  createdWith          3.5.2

  boilerplate          ignite-bowser

  boilerplateVersion   5.2.1


Android
  java               -            C:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.252-2\bin\java.EXE
  android home       -            C:\Users\mihun\AppData\Local\Android\Sdk

やろうとしたこと

ネイティブライブラリを使いたかったので、ExpoをEjectしてBareWorkflowで開発したかった

ぶちあたったこと

ぜんぜん、びるど、できない

手順

  1. igniteでプロジェクト作成
 > ignite new unko

-----------------------------------------------
  (                  )   (
  )\ )   (        ( /(   )\ )    *   )
 (()/(   )\ )     )\()) (()/(  ` )  /(   (
  /(_)) (()/(    ((_)\   /(_))  ( )(_))  )\
 (_))    /(_))_   _((_) (_))   (_(_())  ((_)
 |_ _|  (_)) __| | \| | |_ _|  |_   _|  | __|
  | |     | (_ | | .` |  | |     | |    | _|
 |___|     \___| |_|\_| |___|    |_|    |___|
-----------------------------------------------

An unfair headstart for your React Native apps.
https://infinite.red/ignite

-----------------------------------------------

� igniting app unko
√ Which boilerplate would you like to use? · ignite-bowser
√ using the Infinite Red Bowser boilerplate
√ Would you like to use Expo on this project?


        Why Expo? Expo (https://expo.io) is the fastest way to get started.
        However, Expo support is experimental at this time. If unsure, select No and we'll install the traditional route.
        Additionally, using Expo means you won't be able to add any custom native modules.

       (y/N) · true

  We'll initiate your app using Expo. Please note that you won't be able
  to use native modules unless you "eject".

  More info here: https://docs.expo.io/versions/latest/expokit/eject/
√ Installed dependencies
√ Linted and formatted
√ ignited unko in 99.081s

    Ignite CLI ignited unko in 99.081s

    To get started:

      cd unko
      yarn start
      npx ignite-cli --help
      npx ignite-cli doctor

    Need additional help? Join our Slack community at http://community.infinite.red.

    Now get cooking! �

    (Running yarn install one last time to make sure everything is installed -- please be patient!)

√ yarn complete
  1. イジェクトする
> cd unko
> expo eject
┌─────────────────────────────────────────────────────────────────────────┐
│                                                                         │
│   There is a new version of expo-cli available (3.23.3).                │
│   You are currently using expo-cli 3.21.13                              │
│   Install expo-cli globally using the package manager of your choice;   │
│   for example: `npm install -g expo-cli` to get the latest version      │
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘
Warning! Your git working tree is dirty.
It's recommended to commit all your changes before proceeding, so you can revert the changes made by this command if necessary.

? Would you like to proceed? Yes

Now we need to know your iOS bundle identifier (​https://expo.fyi/bundle-identifier​). You can change this in the future if you need to.
? What would you like your bundle identifier to be? com.unko

Now we need to know your Android package (​https://expo.fyi/android-package​). You can change this in the future if you need to.
? What would you like your package to be named? 

√ App configuration (app.json) updated.
√ Created native project directories (./ios and ./android) and updated .gitignore.
√ Added Metro bundler configuration.
√ Updated package.json and added index.js entry point for iOS and Android.
√ Installed JavaScript dependencies.

⚠️  iOS configuration applied with warnings that should be fixed:
- supportsTablet: You will need to configure this in the "General" tab for your project target in Xcode.
- entitlements: iOS entitlements could not be applied. Please ensure that contact notes, Apple Sign In, and associated domains entitlements are properly configured if you use them in your app.
- icon: This is the image that your app uses on your home screen, you will need to configure it manually.
- splash: This is the image that your app uses on the loading screen, we recommend installing and using expo-splash-screen. Details. (​https://github.com/expo/expo/blob/master/packages/expo-splash-screen/README.md​)

⚠️  Android configuration applied with warnings that should be fixed:
- splash: This is the image that your app uses on the loading screen, we recommend installing and using expo-splash-screen. Details. (​https://github.com/expo/expo/blob/master/packages/expo-splash-screen/README.md​)
- icon: This is the image that your app uses on your home screen, you will need to configure it manually.

√ Skipped installing CocoaPods because operating system is not on macOS.

➡️  Next steps
- � Review the logs above and look for any warnings (⚠️ ) that might need follow-up.
- � You may want to run npx @react-native-community/cli doctor to help install any tools that your app may need to run your native projects.
- � When CocoaPods is installed, initialize the project workspace: cd ios && pod install
- � Download your Android keystore (if you're not sure if you need to, just run the command and see): expo fetch:android:keystore

☑️  When you are ready to run your project
To compile and run your project in development, execute one of the following commands:
- yarn ios
- yarn android
- yarn web
  1. Andoridビルドしようとする
> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1328 file(s) to forward-jetify. Using 12 workers...
info Starting JS server...
info Installing the app...

> Configure project :app

Installing unimodules:
 unimodules-core@5.3.0 from D:\yurufuwa\unko\node_modules\@unimodules\core
 unimodules-react-native-adapter@5.4.0 from D:\yurufuwa\unko\node_modules\@unimodules\react-native-adapter
 expo-constants@9.1.1 from D:\yurufuwa\unko\node_modules\expo-constants
 expo-error-recovery@1.2.1 from D:\yurufuwa\unko\node_modules\expo-error-recovery
 expo-file-system@9.0.1 from D:\yurufuwa\unko\node_modules\expo-file-system
 expo-font@8.2.2 from D:\yurufuwa\unko\node_modules\expo-font
 expo-image-loader@1.1.1 from D:\yurufuwa\unko\node_modules\expo-image-loader
 expo-keep-awake@8.2.1 from D:\yurufuwa\unko\node_modules\expo-keep-awake
 expo-linear-gradient@8.2.1 from D:\yurufuwa\unko\node_modules\expo-linear-gradient
 expo-localization@8.2.1 from D:\yurufuwa\unko\node_modules\expo-localization
 expo-location@8.2.1 from D:\yurufuwa\unko\node_modules\expo-location
 expo-permissions@9.0.1 from D:\yurufuwa\unko\node_modules\expo-permissions
 expo-splash-screen@0.5.0 from D:\yurufuwa\unko\node_modules\expo-splash-screen
 expo-sqlite@8.2.1 from D:\yurufuwa\unko\node_modules\expo-sqlite
 expo-updates@0.2.14 from D:\yurufuwa\unko\node_modules\expo-updates
 unimodules-app-loader@1.2.0 from D:\yurufuwa\unko\node_modules\unimodules-app-loader
 unimodules-barcode-scanner-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-barcode-scanner-interface
 unimodules-camera-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-camera-interface
 unimodules-constants-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-constants-interface
 unimodules-face-detector-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-face-detector-interface
 unimodules-file-system-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-file-system-interface
 unimodules-font-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-font-interface
 unimodules-image-loader-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-image-loader-interface
 unimodules-permissions-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-permissions-interface
 unimodules-sensors-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-sensors-interface
 unimodules-task-manager-interface@5.2.1 from D:\yurufuwa\unko\node_modules\unimodules-task-manager-interface
cache fileHashes.bin (D:\yurufuwa\unko\android\.gradle\6.0.1\fileHashes\fileHashes.bin) is corrupt. Discarding.
cache outputFiles.bin (D:\yurufuwa\unko\android\.gradle\buildOutputCleanup\outputFiles.bin) is corrupt. Discarding.
cache executionHistory.bin (D:\yurufuwa\unko\android\.gradle\6.0.1\executionHistory\executionHistory.bin) is corrupt. Discarding.
cache resourceHashesCache.bin (D:\yurufuwa\unko\android\.gradle\6.0.1\fileHashes\resourceHashesCache.bin) is corrupt. Discarding.
cache jarAnalysis.bin (D:\yurufuwa\unko\android\.gradle\6.0.1\javaCompile\jarAnalysis.bin) is corrupt. Discarding.
cache classAnalysis.bin (D:\yurufuwa\unko\android\.gradle\6.0.1\javaCompile\classAnalysis.bin) is corrupt. Discarding.
cache taskHistory.bin (D:\yurufuwa\unko\android\.gradle\6.0.1\javaCompile\taskHistory.bin) is corrupt. Discarding.

> Task :unimodules-core:compileDebugJavaWithJavac

> Task :expo-constants:compileDebugJavaWithJavac

> Task :expo-file-system:processDebugManifest
D:\yurufuwa\unko\node_modules\expo-file-system\android\src\main\AndroidManifest.xml:10:9-21:20 Warning:
        provider#expo.modules.filesystem.FileSystemFileProvider@android:authorities was tagged at AndroidManifest.xml:10 to replace other declarations but no other declaration present

> Task :expo-file-system:compileDebugJavaWithJavac

> Task :expo-localization:compileDebugJavaWithJavac
> Task :expo-image-loader:compileDebugKotlin
w: D:\yurufuwa\unko\node_modules\expo-image-loader\android\src\main\java\expo\modules\imageloader\ImageLoaderModule.kt: (11, 42): 'SimpleTarget<Z : Any!>' is deprecated. Deprecated in Java
w: D:\yurufuwa\unko\node_modules\expo-image-loader\android\src\main\java\expo\modules\imageloader\ImageLoaderModule.kt: (83, 22): 'SimpleTarget<Z : Any!>' is deprecated. Deprecated in Java

> Task :expo-location:compileDebugJavaWithJavac

> Task :expo-sqlite:compileDebugJavaWithJavac

> Task :expo-updates:compileDebugJavaWithJavac
Gradle may disable incremental compilation as the following annotation processors are not incremental: room-compiler-2.1.0.jar (androidx.room:room-compiler:2.1.0).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run annotation processing in a separate task and make compilation incremental.

> Task :react-native-gesture-handler:compileDebugJavaWithJavac

> Task :react-native-keychain:compileDebugJavaWithJavac FAILED
w: Detected multiple Kotlin daemon sessions at build\kotlin\sessions

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.0.1/userguide/command_line_interface.html#sec:command_line_warnings
239 actionable tasks: 239 executed
����:���̓t�@�C���̑���̂����A���`�F�b�N�܂��͈��S�ł͂Ȃ����̂�����܂��B
����:�ڍׂ́A-Xlint:unchecked�I�v�V�������w�肵�čăR���p�C�����Ă��������B
����:D:\yurufuwa\unko\node_modules\expo-constants\android\src\main\java\expo\modules\constants\ConstantsService.java�͔����API���g�p�܂��̓I�[�o�[���C�h���Ă��܂��B
����:�ڍׂ́A-Xlint:deprecation�I�v�V�������w�肵�čăR���p�C�����Ă��������B
����:D:\yurufuwa\unko\node_modules\expo-file-system\android\src\main\java\expo\modules\filesystem\FileSystemModule.java�̑���́A���`�F�b�N�܂��͈��S�ł͂���܂���B
����:�ڍׂ́A-Xlint:unchecked�I�v�V�������w�肵�čăR���p�C�����Ă��������B
����:D:\yurufuwa\unko\node_modules\expo-localization\android\src\main\java\expo\modules\localization\LocalizationModule.java�͔����API���g�p�܂��̓I�[�o�[���C�h���Ă��܂��B
����:�ڍׂ́A-Xlint:deprecation�I�v�V�������w�肵�čăR���p�C�����Ă��������B
����:D:\yurufuwa\unko\node_modules\expo-location\android\src\main\java\expo\modules\location\taskConsumers\GeofencingTaskConsumer.java�̑���́A���`�F�b�N�܂��͈��S�ł͂���܂���B
����:�ڍׂ́A-Xlint:unchecked�I�v�V�������w�肵�čăR���p�C�����Ă��������B
����:D:\yurufuwa\unko\node_modules\expo-sqlite\android\src\main\java\expo\modules\sqlite\SQLiteModule.java�̑���́A���`�F�b�N�܂��͈��S�ł͂���܂���B
����:�ڍׂ́A-Xlint:unchecked�I�v�V�������w�肵�čăR���p�C�����Ă��������B
����:D:\yurufuwa\unko\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerButtonViewManager.java�͔����API���g�p�܂��̓I�[�o�[���C�h���Ă��܂��B
����:�ڍׂ́A-Xlint:deprecation�I�v�V�������w�肵�čăR���p�C�����Ă��������B
����:���̓t�@�C���̑���̂����A���`�F�b�N�܂��͈��S�ł͂Ȃ����̂�����܂��B
����:�ڍׂ́A-Xlint:unchecked�I�v�V�������w�肵�čăR���p�C�����Ă��������B
D:\yurufuwa\unko\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\DeviceAvailability.java:30: �G���[: �V���{�����������܂���
    return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE);
                                                                      ^
  �V���{��:   �ϐ� FEATURE_FACE
  �ꏊ: �N���X PackageManager
D:\yurufuwa\unko\node_modules\react-native-keychain\android\src\main\java\com\oblador\keychain\DeviceAvailability.java:34: �G���[: �V���{�����������܂���
        return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_IRIS);
                                                                          ^
  �V���{��:   �ϐ� FEATURE_IRIS
  �ꏊ: �N���X PackageManager
�G���[2��

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-keychain:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 29s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
����:���̓t�@�C���̑���̂����A���`�F�b�N�܂��͈��S�ł͂Ȃ����̂�����܂��B

ふぁっきゅ!!!!! :-p

文字化けしてるし、エラーも全然いみわからんたすけてぐーぐる。。。

えーなになに?bundle.gradleの設定が終わってるから修正してクレメンスぅ?

https://github.com/oblador/react-native-keychain/issues/193

依存関係ライブラリのせいかぁー。しゃーない。。 bundle.gradleを変更。。。からの

  1. またAndroidびるどをじっこう
> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1526 file(s) to forward-jetify. Using 12 workers...
info Starting JS server...
info Installing the app...

> Configure project :app

Installing unimodules:
 unimodules-core@5.3.0 from D:\yurufuwa\test\unko3\node_modules\@unimodules\core
 unimodules-react-native-adapter@5.4.0 from D:\yurufuwa\test\unko3\node_modules\@unimodules\react-native-adapter
 expo-constants@9.1.1 from D:\yurufuwa\test\unko3\node_modules\expo-constants
 expo-error-recovery@1.2.1 from D:\yurufuwa\test\unko3\node_modules\expo-error-recovery
 expo-file-system@9.0.1 from D:\yurufuwa\test\unko3\node_modules\expo-file-system
 expo-font@8.2.2 from D:\yurufuwa\test\unko3\node_modules\expo-font
 expo-image-loader@1.1.1 from D:\yurufuwa\test\unko3\node_modules\expo-image-loader
 expo-keep-awake@8.2.1 from D:\yurufuwa\test\unko3\node_modules\expo-keep-awake
 expo-linear-gradient@8.2.1 from D:\yurufuwa\test\unko3\node_modules\expo-linear-gradient
 expo-location@8.2.1 from D:\yurufuwa\test\unko3\node_modules\expo-location
 expo-permissions@9.0.1 from D:\yurufuwa\test\unko3\node_modules\expo-permissions
 expo-splash-screen@0.5.0 from D:\yurufuwa\test\unko3\node_modules\expo\node_modules\expo-splash-screen
 expo-sqlite@8.2.1 from D:\yurufuwa\test\unko3\node_modules\expo-sqlite
 expo-updates@0.2.14 from D:\yurufuwa\test\unko3\node_modules\expo-updates
 expo-web-browser@8.3.1 from D:\yurufuwa\test\unko3\node_modules\expo-web-browser
 unimodules-app-loader@1.2.0 from D:\yurufuwa\test\unko3\node_modules\unimodules-app-loader
 unimodules-barcode-scanner-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-barcode-scanner-interface
 unimodules-camera-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-camera-interface
 unimodules-constants-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-constants-interface
 unimodules-face-detector-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-face-detector-interface
 unimodules-file-system-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-file-system-interface
 unimodules-font-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-font-interface
 unimodules-image-loader-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-image-loader-interface
 unimodules-permissions-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-permissions-interface
 unimodules-sensors-interface@5.2.1 from D:\yurufuwa\test\unko3\node_modules\unimodules-sensors-interface
Found some duplicated unimodule packages. Installed the ones with the highest version number.
Make sure following dependencies of your project are resolving to one specific version:
 expo-splash-screen

> Task :app:compileDebugJavaWithJavac FAILED

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.0.1/userguide/command_line_interface.html#sec:command_line_warnings
423 actionable tasks: 2 executed, 421 up-to-date
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:30: �G���[: �V���{�����������܂���
import jp.com.test;
             ^
  �V���{��:   �N���X test
  �ꏊ: �p�b�P�[�W jp.com
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:40: �G���[: �V���{�����������܂���
      return BuildConfig.DEBUG;
             ^
  �V���{��: �ϐ� BuildConfig
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:57: �G���[: �V���{�����������܂���
      if (BuildConfig.DEBUG) {
          ^
  �V���{��: �ϐ� BuildConfig
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:57: �G���[: �^�̊J�n���s���ł�
      if (BuildConfig.DEBUG) {
         ^
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:66: �G���[: �V���{�����������܂���
      if (BuildConfig.DEBUG) {
          ^
  �V���{��: �ϐ� BuildConfig
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:66: �G���[: �^�̊J�n���s���ł�
      if (BuildConfig.DEBUG) {
         ^
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:84: �G���[: �V���{�����������܂���
    if (!BuildConfig.DEBUG) {
         ^
  �V���{��:   �ϐ� BuildConfig
  �ꏊ: �N���X MainApplication
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:100: �G���[: �V���{�����������܂���
    if (BuildConfig.DEBUG) {
        ^
  �V���{��:   �ϐ� BuildConfig
  �ꏊ: �N���X MainApplication
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:100: �G���[: �^�̊J�n���s���ł�
    if (BuildConfig.DEBUG) {
       ^
��g�p�܂��̓I�[�o�[���C�h���Ă��܂��B
����:�ڍׂ́A-Xlint:deprecation�I�v�V�������w�肵�čăR���p�C�����Ă��������B
�G���[9��

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\yurufuwa\test\unko3\android\app\src\main\java\com\unko3\MainApplication.java:30: �G���[: �V���{�����������܂���

あ”っ!?な”ん”ででぎな”い”!!!?!?(藤原竜也

けつろんからいうとですね。 EjectのIdentifier設定するときに、わけわからんIdentifier設定してたのがだめでした。。
しっかり、com.unkoみたいな感じで設定しましょう。

上記のエラーはBuildConfig.DEBUGの値が読み取れないエラーで、
つまるところ名前空間の不一致による読み込みエラーでした。

私はこれで4時間無駄にしました^q^