他の方が作られたreact nativeプロジェクトを引き継いだ際に起こったエラーなどへの対応まとめ

■npx react-native run-android
を行うと、

* What went wrong:
Could not determine java version from '11.0.5'.
というエラーが…。

android/gradle/wrapper/gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
に変えて再度実行でokだった。

 

 

■* What went wrong:
A problem occurred configuring project ':app'.
> java.lang.NullPointerException (no error message)

android/gradle.properties
に、jdkのパスを追加。

ただ、こちらでは、
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
とかの、本来指定すべきようなパスではだめで、android studioのproject structureから確認できる、JDKのパスを入れないとだめだった。
(org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home のようなパスを指定した)

 

 

 

■> Task :react-native-line-sdk:compileDebugJavaWithJavac FAILED
node_modules/react-native-line-sdk/android/src/main/java/com/xmartlabs/lineloginmanager/LineLogin.java:76: エラー: getLoginIntentに適切なメソッドが見つかりません(Context,String)
Intent intent = LineLoginApi.getLoginIntent(context, channelId);
^
メソッド LineLoginApi.getLoginIntent(Context,String,LineAuthenticationParams)は使用できません
(実引数リストと仮引数リストの長さが異なります)
メソッド LineLoginApi.getLoginIntent(Context,LineAuthenticationConfig,LineAuthenticationParams)は使用できません
(実引数リストと仮引数リストの長さが異なります)
/Users/kuniakisuzuki/Desktop/work/github/admissions_app/node_modules/react-native-line-sdk/android/src/main/java/com/xmartlabs/lineloginmanager/LineLogin.java:135: エラー: シンボルを見つけられません
result.putString("accessToken", accessToken.getAccessToken());
^
シンボル: メソッド getAccessToken()
場所: タイプLineAccessTokenの変数 accessToken
エラー2個

 

これは、./node_module/react-native-line-sdk の更新が必要。

1.3以降、まだリリースされていないが、line公式sdk側の更新に伴い、

修正されている項目がありそれを適用しないとビルドエラーが出る。

なので現在のgitの最新を持ってくるように書き換え。

(フォークされているものかもしれないが、

https://github.com/nonth/react-native-line だとこの問題に対して更新されていたので、

このurlを直接package.jsonのlineの所に置き換えて書いて、

npm updateをして取ってきた)

 

 

■> Task :react-native-orientation:processDebugAndroidTestResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-orientation:processDebugAndroidTestResources'.

 

https://github.com/yamill/react-native-orientation/issues/318

を手動で適用(git上でコミットもまだされていないので…)

※/build.gradleのバージョンを書き換えた

※同様のエラーがreact-native-svgでも出たので、同様の対応をした。

 

 

■* What went wrong:
Execution failed for task ':app:transformClassesWithDesugarForDevelopmentDebug'.

android.enableD8.desugaring = true
を/android/gradle.propertiesに入れた

 


■* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDevelopmentDebug'.

https://stackoverflow.com/questions/47079113/android-studio-3-0-execution-failed-for-task-unable-to-merge-dex
を見て、multiDexEnabled true を入れた(multiDexEnabled = true のようにイコールはなくてok)

 

 

■* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:developmentDebugCompileClasspath'.
> Could not resolve project :react-native-orientation.

android 64bit対応をしないとリリースできないので、0.59.1以降にしようとしてビルドしたら起きた。react-native-orientationだと更新がなくビルドが通らないので、

その後更新されている、react-native-orientation-lockerに変えた。(npm linkとunlinkを忘れずに)

 

 

■* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:developmentDebugCompileClasspath'.
> More than one variant of project :react-native-svg matches the consumer attributes:
- Configuration ':react-native-svg:debugApiElements' variant android-aidl:

npm add react-native-svg でライブラリのアップデートが必要。

https://www.npmjs.com/package/react-native-svg

にもあるが、react-nativeに合うバージョンがある。

自分は普通に上記コマンドで最新版(10.0.0)に上げてしまって大丈夫だった。

(※npm list --depth=0

で現在入れているライブラリのバージョンが確認できる)

 

※また、上記のようにライブラリの名前指定で出るエラーは、概ね、同様にライブラリをアップデートすることで解消した。