react-nativeのプロジェクトをビルドしたい2(Mac)(丸一日かかってできませんでした)

9/30 18:02

Could not find com.android.tools.build:gradle:4.0.1.とか言われてるけど探しても無い。
react-native-linear-gradientも無い。
% yarn add react-native-linear-gradient

No matching configuration of project :realm was found. The consumer was configured to find an API of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.ProductFlavor:RNN.reactNativeVersion' with value 'reactNative57_5', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.3.0' but:

          - None of the consumable configurations have attributes.

堂々巡り。

% yarn add realm        
gradle:7.0.4に変更

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.

   > Could not resolve project :realm.

     Required by:

         project :app

      > No matching configuration of project :realm was found. The consumer was configured to find an API of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'RNN.reactNativeVersion' with value 'reactNative57_5' but:

          - None of the consumable configurations have attributes.

realmをコメントアウトした(しかも何故か2個あった)

* What went wrong:

Execution failed for task ':app:checkDebugAarMetadata'.

> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction

   > One or more issues found when checking AAR metadata values:

     

     The minCompileSdk (31) specified in a

     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

     is greater than this module's compileSdkVersion (android-28).

     Dependency: androidx.appcompat:appcompat:1.4.1.

     AAR metadata file: /Users/username/.gradle/caches/transforms-3/c3244396153fe2aaf9e48d10c9e0cd0d/transformed/appcompat-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.

     

     The minCompileSdk (31) specified in a

     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

     is greater than this module's compileSdkVersion (android-28).

     Dependency: androidx.appcompat:appcompat-resources:1.4.1.

     AAR metadata file: /Users/username/.gradle/caches/transforms-3/1a27c374063d8d0e11a12cbb4aa1ddbd/transformed/appcompat-resources-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.

     

     The minCompileSdk (30) specified in a

     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

     is greater than this module's compileSdkVersion (android-28).

     Dependency: androidx.work:work-runtime:2.6.0.

     AAR metadata file: /Users/username/.gradle/caches/transforms-3/d4dedee1b15a7e9a33c1a092468e3a07/transformed/work-runtime-2.6.0/META-INF/com/android/build/gradle/aar-metadata.properties.

     

     The minCompileSdk (31) specified in a

     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

     is greater than this module's compileSdkVersion (android-28).

     Dependency: androidx.emoji2:emoji2-views-helper:1.0.0.

     AAR metadata file: /Users/username/.gradle/caches/transforms-3/be8b26f6fe72563f0dc108fd43fabd71/transformed/emoji2-views-helper-1.0.0/META-INF/com/android/build/gradle/aar-metadata.properties.

     

     The minCompileSdk (31) specified in a

     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

     is greater than this module's compileSdkVersion (android-28).

     Dependency: androidx.emoji2:emoji2:1.0.0.

     AAR metadata file: /Users/username/.gradle/caches/transforms-3/eea55c90336e2ad8a5204c8a3270c918/transformed/emoji2-1.0.0/META-INF/com/android/build/gradle/aar-metadata.properties.

     

     The minCompileSdk (31) specified in a

     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

     is greater than this module's compileSdkVersion (android-28).

     Dependency: androidx.core:core:1.7.0.

     AAR metadata file: /Users/username/.gradle/caches/transforms-3/df6363d1e4e6f3fab9fc98129e184100/transformed/core-1.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.

     

     The minCompileSdk (31) specified in a

     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

     is greater than this module's compileSdkVersion (android-28).

     Dependency: androidx.lifecycle:lifecycle-process:2.4.0.

     AAR metadata file: /Users/username/.gradle/caches/transforms-3/116d173dfeccd1b08e9c2909251e25ab/transformed/lifecycle-process-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

     

     The minCompileSdk (31) specified in a

     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)

     is greater than this module's compileSdkVersion (android-28).

     Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.

     AAR metadata file: /Users/username/.gradle/caches/transforms-3/62e3858dc5aa4aa4fa8b176fb1486c1f/transformed/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

全てのcompileSdkVersionを31に。

> Task :app:processDebugMainManifest FAILED

[com.android.support:animated-vector-drawable:28.0.0] /Users/username/.gradle/caches/transforms-3/233cd41ab5d43779d1ddd64b4614d29a/transformed/animated-vector-drawable-28.0.0/AndroidManifest.xml Warning:

        Package name 'android.support.graphics.drawable' used in: com.android.support:animated-vector-drawable:28.0.0, com.android.support:support-vector-drawable:28.0.0.

[androidx.versionedparcelable:versionedparcelable:1.1.1] /Users/username/.gradle/caches/transforms-3/dc0f11691095d4bbc8003ad8f5bb847f/transformed/versionedparcelable-1.1.1/AndroidManifest.xml Warning:

        Package name 'androidx.versionedparcelable' used in: androidx.versionedparcelable:versionedparcelable:1.1.1, com.android.support:versionedparcelable:28.0.0.


See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

animated-vector-drawable:はどこにもない

build.gradleに追加してみたけど同じエラー
赤字だけどそもそもエラーではない?何も書いてない。

こっち?

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

% npx react-native info
warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Fetching system and libraries information...
System:
    OS: macOS 12.5
    CPU: (8) arm64 Apple M1
    Memory: 122.36 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 17.0.0 - ~/.nvm/versions/node/v17.0.0/bin/node
    Yarn: 3.2.3 - ~/.yarn/bin/yarn
    npm: 8.0.0 - ~/.nodebrew/current/bin/npm
    Watchman: 2022.09.26.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8609683
    Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
  Languages:
    Java: 18.0.2 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^18.2.0 => 18.2.0
    react-native: ^0.70.1 => 0.70.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
Android SDK: Not Foundになってる

command line toolにはチェック入ってる
Android12.0もインストールした

% react-native doctor
warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
⠋ Running diagnostics...(node:24382) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
⠼ Running diagnostics...warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
CommonNode.js
✓ yarn
✓ Watchman - Used for watching changes in the filesystem when in development mode
AndroidJDKAndroid Studio - Required for building and installing your app on AndroidAndroid SDK - Required for building and installing your app on Android
   - Versions found: N/A
   - Version supported: 28.0.2ANDROID_HOME

またここに飛ばされた。なんか見逃してる?
https://reactnative.dev/docs/environment-setup

こっちをやってみる。
https://stackoverflow.com/a/28296325/4252781

✓ ANDROID_HOMEninatta!!!!

あとは
✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A

Commandline Tool29.0.2もチェックされてる。

- Version supported: 28.0.2って書いてあった。SDK Managerで12.0.2をチェックしてApply

- Versions found: N/A

…...e?? arukedo…..

Android Studioでandroidファイルを開いてみる。
めちゃ時間かかる。

19:07

まだかかる

19:17

Terminalとかを一回全部閉じてみた。再度開くと。。。

✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A
   - Version supported: 28.0.2
✖ ANDROID_HOME

ANDROID_HOMEも元に戻ってるぅぅぅぅぅぅぅxうぅう

add <YOUR_ANDROID_SDK_PATH>\cmdline-tools\latest\bin to PATH environment variables
-> YOUR_ANDROID_SDK_PATHがAndroid sdkの「Android  sdk Location」っていうところにあるやつだとしたら、Pathはこうなる。

/Users/username/Library/Android/sdk\cmdline-tools\latest\bin

スラッシュ逆。どっちが正しいんだっけ。正しいとかある?
PATH=$PATH:\Users\username\Library\Android\sdk\cmdline-tools\latest\bin
これでやってみた。

✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A
   - Version supported: 28.0.2
✖ ANDROID_HOME

export PATH=$PATH:/Users/username/Library/Android/sdk/cmdline-tools/latest/bin
こっちだった。
できたあああああああああああああああああ😭😭

✓ Android SDK - Required for building and installing your app on Android
✓ ANDROID_HOME

% adb devices      
% npx react-native run-android
warn
Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.

info JS server already running.

/bin/sh: /Applications/ADT/sdk/platform-tools/adb: No such file or directory

info Launching emulator...

error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.

warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.

info Installing the app...


> Configure project :react-native-reanimated

Native libs debug enabled: false

Android gradle plugin: 7.0.4

Gradle: 7.5.1

building Reanimated2

WARNING:The specified Android SDK Build Tools version (28.0.2) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 7.0.4.

Android SDK Build Tools 30.0.2 will be used.

To suppress this warning, remove "buildToolsVersion '28.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

WARNING:The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 7.0.4.

Android SDK Build Tools 30.0.2 will be used.

To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

WARNING:The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 7.0.4.

Android SDK Build Tools 30.0.2 will be used.

To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.


> Task :app:processDebugMainManifest FAILED

[com.android.support:animated-vector-drawable:28.0.0] /Users/username/.gradle/caches/transforms-3/233cd41ab5d43779d1ddd64b4614d29a/transformed/animated-vector-drawable-28.0.0/AndroidManifest.xml Warning:

        Package name 'android.support.graphics.drawable' used in: com.android.support:animated-vector-drawable:28.0.0, com.android.support:support-vector-drawable:28.0.0.

[androidx.versionedparcelable:versionedparcelable:1.1.1] /Users/username/.gradle/caches/transforms-3/dc0f11691095d4bbc8003ad8f5bb847f/transformed/versionedparcelable-1.1.1/AndroidManifest.xml Warning:

        Package name 'androidx.versionedparcelable' used in: androidx.versionedparcelable:versionedparcelable:1.1.1, com.android.support:versionedparcelable:28.0.0.


See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.



Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.


You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.


See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings

102 actionable tasks: 2 executed, 100 up-to-date

/Users/username/Desktop/name/android/app/src/main/AndroidManifest.xml:24:18-86 Error:

Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.7.0] AndroidManifest.xml:24:18-86

is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).

Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:12:5-54:19 to override.


FAILURE: Build failed with an exception.


* What went wrong:

Execution failed for task ':app:processDebugMainManifest'.

> Manifest merger failed with multiple errors, see logs


* 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 2s


error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

…/android/app/src/main/AndroidManifest.xml:24:18-86 Error:

Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.7.0] AndroidManifest.xml:24:18-86

is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).

Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:12:5-54:19 to override.


FAILURE: Build failed with an exception.


* What went wrong:

Execution failed for task ':app:processDebugMainManifest'.

> Manifest merger failed with multiple errors, see logs


* 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 2s


    at makeError (…/node_modules/execa/index.js:174:9)

    at …/node_modules/execa/index.js:278:16

    at processTicksAndRejections (node:internal/process/task_queues:96:5)

    at async runOnAllDevices (…/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)

    at async Command.handleAction (…./node_modules/@react-native-community/cli/build/index.js:142:9)

info Run CLI with --verbose flag for more details.

😭

何も変わってないやん・・

error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
これ。

Android Emulatorをアップデートした。
Emulatorも起動した。
Android実機もMacに繋がってる。

error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.

ええ

To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
これも。buildToolsVersion '23.0.1'自体無い。どうなってる。

ここをみるべき?
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed with multiple errors, see logs

logにはWaningしかないけど
Package name 'android.support.graphics.drawable' used in: com.android.support:animated-vector-drawable:28.0.0, com.android.support:support-vector-drawable:28.0.0.

android.useAndroidX=true android.enableJetifier=true
をbuild.propertiesに追加。
意味なし。
com.android.support:animated-vector-drawable:28.0.0を見つけた。

implementation('com.android.support:support-vector-drawable:28.0.0') {
            exclude group: 'android.support.graphics.drawable'
            exclude module: 'support-vector-drawable'
        }

これ追加した。

> Task :app:processDebugMainManifest FAILED
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

エラー内容消えた!!

20:59

Manifest Mergerを見るためにAndroidStudioを開く

こんなエラーが出てた。
Error: tools:replace specified at line:12 for attribute android:appComponentFactory, but no new value specified name.app main manifest (this file), line 11

Android Studio > Refactor > Migrate to AndroidX

色々私が変えたせいでエラーでてるかもしれないので、元の状態のプロジェクトで再度試す
% yarn install
振り出しに戻る。

やっぱり元の状態のやつは消して。。
Error:
tools:replace specified at line:12 for attribute android:appComponentFactory, but no new value specified
これ。

tools:replace="android:appComponentFactory"を消す。(Android Manifest)

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
.../android/app/src/main/AndroidManifest.xml Error:
android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

android:exported="false"を追加(Android Manifest)

Android resource linking failed
ERROR:.../android/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:60: AAPT: error: attribute android:enableOnBackInvokedCallback not found.

android:enableOnBackInvokedCallback="true"を追加

ERROR:.../android/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:60: AAPT: error: attribute android:enableOnBackInvokedCallback not found.

issyo.
minSdkVersion = 21 -> 29に変更

22:04

まだ仕事のSlackが動いている。。みんな仕事してるなあ☺️

逆にandroid:enableOnBackInvokedCallbackを消してみる。
react-native run-androidしたら勝手に追加されてるぅ。

22:16

もう寝る。

ネットに撒き散らした質問に誰かがコメントしてくれるのを待とう。


いいなと思ったら応援しよう!