react-nativeのプロジェクトをビルドしたい3(Mac)(約18時間目〜)

7:40

休日だけど気になって眠れないので
やる。

% react-native run-android --verbose

AAPT: error: attribute android:enableOnBackInvokedCallback not found.

compileSdkVersion 29に変更

% react-native run-android --verbose

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-29).
Dependency: androidx.appcompat:appcompat:1.4.1.
AAR metadata file: /Users/tenna/.gradle/caches/transforms-3/c3244396153fe2aaf9e48d10c9e0cd0d/transformed/appcompat-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.

% yarn yarn-upgrade-all
% react-native run-android --verbose

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-29).
Dependency: androidx.appcompat:appcompat:1.4.1.
AAR metadata file: /Users/tenna/.gradle/caches/transforms-3/c3244396153fe2aaf9e48d10c9e0cd0d/transformed/appcompat-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.
->
supportLibVersionを
下げても同じエラーが出たので、compileSdkVersionを下げるのは諦める。

この
ノート
エンター押すたびに改行
される


implementation 'androidx.appcompat:appcompat:1.6.0-alpha03'を追加
->
defaultConfigに以下を追加
ndk {
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}

kokoni書いてあることも
やってみようとしたけどjcenter()を
追加するくらいしかやってない。jcenter()ってなに。
->
android % ./gradlew assembleDebug --stacktrace
->
ERROR:/Users/tenna/Desktop/name/android/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:66: AAPT: error: attribute android:enableOnBackInvokedCallback not found.
at com.android.builder.internal.aapt.v2.Aapt2Exception$Companion.create(Aapt2Exception.kt:45)
at com.android.builder.internal.aapt.v2.Aapt2Exception$Companion.create$default(Aapt2Exception.kt:33)
こんなエラーも
Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: View!, p1: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView
->
なんか
根本的に
間違ってる気がして
仕方ない

こんな
色々
起こる
???
1箇所が
間違ってて
そこから
全てのエラーでてるとか
アリエル

->
AndroidXが関係あるかも
#android .useAndroidX=true
#android .enableJetifier=true
コメントアウト

% npx react-native run-android

rror:
Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.9.0-alpha03] AndroidManifest.xml:30: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.

言われた通りやってみる。
tools:replace="android:appComponentFactory"

% npx react-native run-android

Error:
tools:replace specified at line:12 for attribute android:appComponentFactory, but no new value specified

AndroidX用らしい。android.useAndroidX=true android.enableJetifier=trueを追加しろと書いてる。


一回tools:replace="android:appComponentFactory"を消そうと思ったけど、AndroidXの方を推奨されてるからこっち使った方がいいのかな。苦労して戻してもエラー解消する保証ないし。

android:appComponentFactory="android.support.v4.app.CoreComponentFactory"を追加

% npx react-native run-android
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081… Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: View!, p1: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView
エラーこれだけになった!!!!!!!!!!!!

ん?もう一回% npx react-native run-androidやったらまた新しいエラー追加された。
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
Android resource linking failed
ERROR:/Users/tenna/Desktop/name/android/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:66: AAPT: error: attribute android:enableOnBackInvokedCallback not found.

android:enableOnBackInvokedCallback="true"追加

エラー消えた!あとこれだけ
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081… Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: View!, p1: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView

ModalContentLayoutが使われている様子がないので、街頭部分のコードを消しちゃう
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
}

ERROR:/Users/tenna/Desktop/name/android/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:66: AAPT: error: attribute android:enableOnBackInvokedCallback not found.
Execution failed for task ':react-native-navigation:compileReactNative57_5DebugKotlin'.
エラー二つni増えてるし。
enableOnBackInvokedCallbackがないとかいってるけどあるし。

android:enableOnBackInvokedCallback="true"の位置をnameの下にしてみた。
エラー消えた。

次は
Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: View!, p1: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView
。。。消したんだけどなあ。
onChildStartedNativeGestureこれを元に戻したら、エラーも変わった。

onChildStartedNativeGestureは消さずにoverrideだけ消した
->
ERROR:/Users/tenna/Desktop/name/android/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:66: AAPT: error: attribute android:enableOnBackInvokedCallback not found.
Execution failed for task ':react-native-navigation:compileReactNative57_5DebugKotlin'.
->
ええ?
何回見てもenableOnBackInvokedCallbackはちゃんとある。どこ見てるんだ?
なんか勝手にdebuggableの下に移動されてるのでまたnameの下に移動。
今度は効かない。

こんなエラーも
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: … /ModalContentLayout.kt: (12, 1): Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: View!, p1: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView
e: /Users/tenna/Desktop/name/node_modules/react-native-navigation/lib/android/app/src/reactNative57_5/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt: (52, 9): 'onChildStartedNativeGesture' hides member of supertype 'RootView' and needs 'override' modifier
override必須って言ってる?戻してやるよ!

Error: Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: View!, p1: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView
ファーーーーーーーーーーーーーーーーーー
ドユコトーーーーーーーーーーーーーーーーーーーーー
override必要てゆうたやん。
わあああああああああああああああああ

ネット検索しても何も引っかからない。
これ自前ファイル???
何もわからない。

10:04

土曜の朝に何をやっているんだ。

override元の名前変わってるとか?
ていうかreact-nativeでkotlin編集していいの?
jsから自動生成されたものじゃないの?
react-nativeのクラッシュコース見るべき?(見ろ)

AAPT: error: attribute android:enableOnBackInvokedCallback not found.
https://stackoverflow.com/questions/73535001/react-native-aapt-error-attribute-androidenableonbackinvokedcallback-not-foun

おんなじようなこと起こってる人見つけた。1ヶ月前に投稿されて誰も回答してない。多分昨日とりあえずエラー消すために適当なことしたのが今祟ってるんだ。とりあえず消した.shコマンドとか戻してみよう。

10/2(sun) 7:48 

またやる。一回クリーンしてみる。
% cd android
% ./gradlew clean

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

一回react-native-navigation消しちゃう。。?
% yarn remove react-native-navigation
->
No matching configuration of project :react-native-navigation 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.
->
だめだよね。。
% yarn add react-native-navigation
->
react-native-navigationのbuild.gradleのminSDKVersion変えてみた。

最低21って書いてある。
minSdkVersion 16 -> 21

AAPT: error: attribute android:enableOnBackInvokedCallback not found.
Execution failed for task
Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: View!, p1: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView

英語翻訳間違えてた。。onChildStartedNativeGestureが新しいreact-native-navigationでちょっと変更されてて、それに対応する必要があった。

Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView
ん?できてない?
上のURLではreact-native-navigationとreact-native0.68が一緒に使えないって書いてるけど今使ってるのは0.70.1。

まだreact-native0.70.1なんてない。。。
ダウングレード。
% yarn add react-native@0.69.6
->
エラー変わらん
% yarn add react-native@0.67
->
implementation "androidx.activity:activity:1.6.0-alpha05"をbuild.gradleに追加

The minCompileSdk (32) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-31).

compileSdkVersion = 31 -> 32
->
AAPT: error: attribute android:enableOnBackInvokedCallback not found.
->
enableOnBackInvokedCallback消してみても自動で追加されるし。
「android:enableOnBackInvokedCallbackがないよ」じゃなくて「android:enableOnBackInvokedCallbackってのがあるけどこれ何?」って言ってるのか?
自分で追加しといてなんだよおおおおお。
->
手詰まりなので、何もしてない状態のプロジェクトからまたトライ。
むやみに色々触らないようにしよう。

8:54

% yarn install
./fix-lib.sh: line 10: syntax error: unexpected end of file
前も見たやつ。

% npm install
onajiyouna大量のエラー

% ./gradlew assembleDebug
zsh: permission denied: ./gradlew

% chmod +x gradlew
% ./gradlew assembleDebug
env: sh\r: No such file or directory

% dos2unix ./gradlew
dos2unix: converting file ./gradlew to Unix format...
% ./gradlew assembleDebug
Cannot add task 'wrapper' as a task with that name already exists.
使用しているGradleのバージョンが5.X(5系)の場合、以下の「task wrapper」の記述は使えない。

gradleのバージョンを下げる。
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip

% export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
% ./gradlew assembleDebug
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

Go to android directory Create a file with following name:
local.properties
Open the file and paste your Android SDK path like below:
sdk.dir = /Users/USERNAME/Library/Android/sdk

% ./gradlew assembleDebug
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:12:5-54:19 to override.

AndroidXにしたら堂々巡りだ。。。ここは回避したい。

9:45

あれ、
https://stackoverflow.com/questions/56914269/how-to-fix-manifest-merger-failed-in-react-native-android

まえandroidXにしたときこれに変更してなかったかも?
implementation 'com.android.support:multidex:1.0.3' implementation "com.android.support:appcompat-v7:28.0.0"

implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.appcompat:appcompat:1.0.2"
やってみた。

classpath 'com.android.tools.build:gradle:3.3.1' ( 3.21 -> 3.3.1 )

Error
Minimum supported Gradle version is 4.10.1. Current version is 4.8.1. If using the gradle wrapper, try editing the distributionUrl in /Users/tenna/Downloads/name/android/gradle/wrapper/gradle-wrapper.properties to gradle-4.10.1-all.zip

gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-bin.zip

Error
Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

やってみた。

Error
Could not initialize class com.sun.xml.bind.v2.runtime.reflect.opt.Injector

% cd ../
% npx react-native run-android

Error
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:

% adb devices
-> aru
% export ANDROID_HOME=/Users/tenna/Library/Android/sdk
% react-native run-android
-> fail
bash_profileにもANDROID_HOME=/Users/tenna/Library/Android/sdk追加した。
-> fail
% chmod 755 android/gradlew
% react-native run-android
-> fail
% npx @react-native-community/cli doctor
-> doctor not found
多分sdk見つけられないんだろう。

gradleのバージョン変更しろというてる。。。
変更。
-> fail
ちょっと待ってエラーに「read the error above for details.」って言ってるじゃん。エミュレーターのせいじゃないじゃん。

これだった。
Error
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 62

JavaとGradleのバージョンが合ってないらしい。
Gradleのバージョンを7.3.3にしちゃう。

Error
Cannot add task 'wrapper' as a task with that name already exists.
堂々巡りの予感しかしない。wrapperを変更。

Error
Failed to notify project evaluation listener.
'org.gradle.api.file.DirectoryProperty org.gradle.api.file.ProjectLayout.directoryProperty(org.gradle.api.provider.Provider)'

Android Studio使ってる例しか出てこない。遅いから使いたくない。
classpath 'com.android.tools.build:gradle:4.1.0'

Error
Some problems were found with the configuration of task ':realm:send' (type 'SendAnalyticsTask').
- Type 'SendAnalyticsTask' property 'applicationId' is missing an input or output annotation.

Error
Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @1fcebd41

11:10

Error
エラー: シンボルを見つけられません
@Nullable ReadableArray readPermissions){…

compileSdkVersion = 31
-> fail

react-native-fbsdkってやつアーカイブされてる。。
% yarn remove react-native-fbsdk
% yarn add react-native-fbsdk-next
add this to build.gradle
implementation 'com.facebook.android:facebook-android-sdk:latest.release'

Error
No matching configuration of project :react-native-fbsdk-next was found. The consumer was configured to find an API of a component, 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.

一回クリーン。
BUILD SUCCESSFUL in 2s
Looks like you installed react-native globally, maybe you meant react-native-cli?
To fix the issue, run:
npm uninstall -g react-native
npm install -g react-native-cli
やってみたけど同じ結果だったのでとりあえず無視。

% react-native run-android
毎回新しいターミナルが起動されるんだけど、そこにも違うエラーが表示されてる。
Error: error:0308010C:digital envelope routines::unsupported

Node.jsをダウングレード。エラー消えないから無視。

Error
…/node_modules/react-native-picker/android/src/main/java/com/beefe/picker/PickerViewModule.java:533: エラー: シンボルを見つけられません
@Nullable WritableMap…

"react-native-picker": "^4.3.7",
Githubにはreact-native-picke/pickerしかなくて最新は2.4.6。react-native-pickerを外してreact-native-picker/pickerを追加

Error
…/node_modules/react-native-video/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java:72: エラー: シンボルを見つけられません
shutterView.setBackgroundColor(ContextCompat.getC…

% yarn add react-native-video@5.2.1

Error
MainApplication.java:9: エラー: パッケージcom.reactnativecommunity.webviewは存在しません
import com.reactnativecommunity.webview.RNCWebViewPackage;

MainActivity.java:48: エラー: メソッドはスーパータイプのメソッドをオーバーライドまたは実装しません
@Override

無理。
% yarn yarn-upgrade-all
% npx react-native run-android
-> fail
import com.facebook.react.BuildConfig;wo MainActivity.javaに追加
-> fail
% react-native upgrade
Error
Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().

% export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Error
Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

% npm install -g react-native-git-upgrade
% npm install -g @react-native-community/cli
% react-native-git-upgrade
git-upgrade ERR! Restore initial sources
使えない。。

% npx react-native run-android

Error
given for org.gradle.java.home Gradle property is invalid (Java home supplied is invalid)

org.gradle.java.home=...を消す。

Error
Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

13:30

/usr/libexec/java_home -V | grep jdkしてもjdkへのパスは出てこない。

インストールした。Pathも通した。

Error
Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().

% export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Error
Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

% yarn add react-native@0.68
% npx react-native run-android

ERROR: requires JDK11 or higher.
Incompatible major version detected: '8'

AndroidStudio->file->ProjectStructure->click Gradle Settings->choose idk 11 ->sync; できてる

ERROR: requires JDK11 or higher.
Incompatible major version detected: '8'

一回VCcode閉じる。

% export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
ERROR: requires JDK11 or higher.
Incompatible major version detected: '8'

compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 }
を追加

ERROR: requires JDK11 or higher.
Incompatible major version detected: '8'

この記事が気に入ったらサポートをしてみませんか?