reiui9 / Moim

Project-Moim
1 stars 0 forks source link

naver / kakao login 적용 #5

Open eubnara opened 5 years ago

eubnara commented 5 years ago

naver

적용방법

https://github.com/react-native-seoul/react-native-naver-login#getting-started

## 프로젝트 홈에서
$ npm install react-native-naver-login --save
$ react-native link react-native-naver-login

참고: https://github.com/reiui9/Moim/commit/c3733c0231230b66947b4f52dea3e457d471cf85

react-native-naver-login API 정리

import { NaverLogin, getProfile } from 'react-native-naver-login';

NaverLogin <Object>

NaverLogin.login(initials, callback)
- initials <Object>
  - kConsumerKey <String>: OAUTH_CLIENT_ID 에 대응
  - kConsumerSecret <String>: OAUTH_CLIENT_SECRET 에 대응
  - kServiceAppName <String>: OAUTH_CLIENT_NAME 에 대응
- callback <Function>
  - err <String>
  - accessToken <String>
NaverLogin.logout()

getProfile

getProfile(accessToken)
- accessToken <String>
trouble shooting ``` $ react-native run-android JS server already running. Building and installing the app on the device (cd android && ./gradlew installDebug)... NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /home/eub/Android/Sdk/ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning. NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /home/eub/Android/Sdk/ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning. FAILURE: Build failed with an exception. * Where: Build file '/home/eub/github/react-native-naver-login/NaverLoginExample/node_modules/react-native-naver-login/android/build.gradle' line: 39 * What went wrong: A problem occurred evaluating project ':react-native-naver-login'. > Could not find method implementation() for arguments [com.naver.nid:naveridlogin-android-sdk:4.2.5] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 0.638 secs 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: https://facebook.github.io/react-native/docs/getting-started.html ``` ndk 설치해야 하는 듯? #### appcompat v7 관련 에러 react-native 0.57.8 버전에서 com.android.support:appcompat-v7:27.1.1 을 필요로 한다. 그런데 다운로드를 못받는 느낌. 확인해보니 특정 버전 이상부터 받는 주소가 변경된 것으로 보인다. https://stackoverflow.com/questions/45357000/failed-to-resolve-com-android-supportappcompat-v726-0-0 를 참고하여, build.gradle repositories 부분을 변경한다. #### manifest 충돌 이슈 ``` /tmp/react-native-naver-login/NaverLoginExample/android/app/src/main/AndroidManifest.xml:34:9-68 Error: Attribute activity#com.nhn.android.naverlogin.ui.OAuthLoginActivity@theme value=(@android:style/Theme.Translucent.NoTitleBar) from AndroidManifest.xml:34:9-68 is also present at [com.naver.nid:naveridlogin-android-sdk:4.2.5] AndroidManifest.xml:19:13-64 value=(@style/Theme.AppCompat.Light.Dialog). Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:31:7-34:71 to override. See http://g.co/androidstudio/manifest-merger for more information about the manifest merger. :app:processDebugManifest FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugManifest'. > Manifest merger failed : Attribute activity#com.nhn.android.naverlogin.ui.OAuthLoginActivity@theme value=(@android:style/Theme.Translucent.NoTitleBar) from AndroidManifest.xml:34:9-68 is also present at [com.naver.nid:naveridlogin-android-sdk:4.2.5] AndroidManifest.xml:19:13-64 value=(@style/Theme.AppCompat.Light.Dialog). Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:31:7-34:71 to override. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 7.674 secs 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: https://facebook.github.io/react-native/docs/getting-started.html ``` android:theme="@android:style/Theme.Translucent.NoTitleBar" 라인 제거 #### react-native-naver-login 모듈 못찾는 문제 아래에 설명된 내용 적용 후 성공 ``` error: bundling failed: Error: Unable to resolve module `react-native-naver-login` from `/tmp/react-native-naver-login/NaverLoginExample/src/components/pages/First/index.js`: Module `react-native-naver-login` does not exist in the Haste module map This might be related to https://github.com/facebook/react-native/issues/4968 To resolve try the following: 1. Clear watchman watches: `watchman watch-del-all`. 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`. 3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`. at ModuleResolver.resolveDependency (/tmp/react-native-naver-login/NaverLoginExample/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:139:15) at ResolutionRequest.resolveDependency (/tmp/react-native-naver-login/NaverLoginExample/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:49:18) at DependencyGraph.resolveDependency (/tmp/react-native-naver-login/NaverLoginExample/node_modules/metro/src/node-haste/DependencyGraph.js:218:16) at Object.resolve (/tmp/react-native-naver-login/NaverLoginExample/node_modules/metro/src/lib/transformHelpers.js:141:30) at dependencies.map.result (/tmp/react-native-naver-login/NaverLoginExample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:373:31) at Array.map () at resolveDependencies (/tmp/react-native-naver-login/NaverLoginExample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:369:18) at /tmp/react-native-naver-login/NaverLoginExample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:188:33 at Generator.next () at step (/tmp/react-native-naver-login/NaverLoginExample/node_modules/metro/src/DeltaBundler/traverseDependencies.js:298:30) BUNDLE [android, dev] ./index.android.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed. ``` #### rngesture handler module error ``` undefined is not an object (evaluating '_RNGestureHandlerModule.default.Direction') Directions.js:3:38 loadModuleImplementation require.js:320:6 guardedLoadModule require.js:214:36 metroRequire require.js:136:24 GestureHandler.js:2 loadModuleImplementation require.js:320:6 guardedLoadModule require.js:214:36 metroRequire require.js:136:24 Swipeable.js:10 loadModuleImplementation require.js:320:6 guardedLoadModule require.js:214:36 metroRequire require.js:136:24 index.js:1 loadModuleImplementation require.js:320:6 guardedLoadModule require.js:214:36 metroRequire require.js:136:24 StackViewLayout.js:19 loadModuleImplementation require.js:320:6 guardedLoadModule require.js:214:36 metroRequire require.js:136:24 StackView.js:4 loadModuleImplementation require.js:320:6 guardedLoadModule require.js:214:36 metroRequire require.js:136:24 createStackNavigator.js:3 loadModuleImplementation require.js:320:6 guardedLoadModule require.js:207:45 metroRequire require.js:136:24 createStackNavigator index.js:9:18 createStackNavigator react-navigation.js:107:45 render app.js:27:27 proxiedMethod createPrototypeProxy.js:44:35 finishClassComponent ReactNativeRenderer-dev.js:11610:21 updateClassComponent ReactNativeRenderer-dev.js:11538:4 beginWork ReactNativeRenderer-dev.js:12741:8 performUnitOfWork ReactNativeRenderer-dev.js:16075:21 workLoop ReactNativeRenderer-dev.js:16115:41 renderRoot ReactNativeRenderer-dev.js:16219:15 performWorkOnRoot ReactNativeRenderer-dev.js:17198:17 performWork ReactNativeRenderer-dev.js:17099:24 performSyncWork ReactNativeRenderer-dev.js:17060:14 requestWork ReactNativeRenderer-dev.js:16925:19 scheduleWork ReactNativeRenderer-dev.js:16724:16 scheduleRootUpdate ReactNativeRenderer-dev.js:17413:15 updateContainerAtExpirationTime ReactNativeRenderer-dev.js:17447:28 updateContainer ReactNativeRenderer-dev.js:17537:4 render ReactNativeRenderer-dev.js:18191:20 renderApplication renderApplication.js:59:34 run AppRegistry.js:101:10 runApplication AppRegistry.js:195:26 __callFunction MessageQueue.js:349:47 MessageQueue.js:106:26 __guard MessageQueue.js:297:10 callFunctionReturnFlushedQueue MessageQueue.js:105:17 callFunctionReturnFlushedQueue [native code] ``` https://reactnavigation.org/docs/en/3.x/getting-started.html 에 따라서 react-native-gesture-handler, react-native-reanimated 잘 설치하기 #### implementation / compile ``` $ react-native run-android JS server already running. Building and installing the app on the device (cd android && ./gradlew installDebug)... Starting a Gradle Daemon (subsequent builds will be faster) > Configure project :app NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /home/eub/Android/Sdk/ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning. > Configure project :react-native-gesture-handler NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /home/eub/Android/Sdk/ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning. Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error. FAILURE: Build failed with an exception. * Where: Build file '/tmp/react-native-naver-login/NaverLoginExample/node_modules/react-native-gesture-handler/android/build.gradle' line: 27 * What went wrong: A problem occurred evaluating project ':react-native-gesture-handler'. > Could not find method implementation() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. * 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 7s 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: https://facebook.github.io/react-native/docs/getting-started.html ``` https://stackoverflow.com/questions/45615474/gradle-error-could-not-find-method-implementation-for-arguments-com-android
eubnara commented 5 years ago
$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (25.0.0) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.0'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getPackageApplication(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.

> Configure project :react-native-naver-login
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '27.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-reanimated
WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

FAILURE: Build failed with an exception.

* Where:
Build file '/tmp/react-native-naver-login/NaverLoginExample/node_modules/react-native-reanimated/android/build.gradle' line: 35

* What went wrong:
A problem occurred evaluating project ':react-native-reanimated'.
> Cannot get property 'supportLibVersion' on extra properties extension as it does not exist

* 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 4s
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:
https://facebook.github.io/react-native/docs/getting-started.html