この文書の現在のバージョンと選択したバージョンの差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
|
reactnative:react-native-maps [2019/03/27 00:51] ips 作成 |
reactnative:react-native-maps [2019/03/30 09:49] (現在) ips |
||
|---|---|---|---|
| ライン 1: | ライン 1: | ||
| ====== react-native-maps ====== | ====== react-native-maps ====== | ||
| + | [[https://medium.com/quick-code/react-native-location-tracking-14ab2c9e2db8|React Native Location Tracking]] | ||
| + | |||
| + | ===== インストール ===== | ||
| + | |||
| + | |||
| + | <code> | ||
| + | npm install react-native-maps --save | ||
| + | react-native link | ||
| + | </code> | ||
| + | |||
| + | |||
| + | Google Maps Platform ドキュメント | ||
| + | https://developers.google.com/maps/documentation/ | ||
| + | |||
| + | |||
| + | Get API Key | ||
| + | https://developers.google.com/maps/documentation/android-sdk/signup | ||
| + | |||
| + | |||
| + | Step 1. Get an API key | ||
| + | |||
| + | Google Maps Platform の有効化 | ||
| + | [[google:google_maps_platform|詳細はここ]] | ||
| + | |||
| + | |||
| + | Step 2. Add the API key to your app | ||
| + | |||
| + | native_background_timer\android\app\src\main\AndroidManifest.xml にmeta-data追加 | ||
| + | <code> | ||
| + | ・・・ | ||
| + | </activity> | ||
| + | <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> | ||
| + | ↓追加 | ||
| + | <meta-data | ||
| + | android:name="com.google.android.geo.API_KEY" | ||
| + | android:value="[STEP 1 のAPIキー]"/> | ||
| + | </application> | ||
| + | </code> | ||
| + | |||
| + | ===== react-native run-androidの文字化け ===== | ||
| + | |||
| + | |||
| + | <html>chcp 932</html>をしないと<html>react-native run-android</html>が文字化けする。 | ||
| + | |||
| + | ===== エラー ===== | ||
| + | <code> | ||
| + | FAILURE: Build failed with an exception. | ||
| + | |||
| + | * What went wrong: | ||
| + | Could not resolve all files for configuration ':react-native-maps:debugCompileClasspath'. | ||
| + | > Could not resolve com.android.support:support-compat:26.1.0. | ||
| + | Required by: | ||
| + | project :react-native-maps | ||
| + | > Cannot find a version of 'com.android.support:support-compat' that satisfies the version constraints: | ||
| + | Dependency path 'native_background_timer:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.59.1' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-compat:28.0.0' | ||
| + | </code> | ||
| + | |||
| + | native_background_timer\node_modules\react-native-maps\lib\android\build.gradleに追加 ※ファイルの場所に注意 | ||
| + | ↓ | ||
| + | <code> | ||
| + | dependencies { | ||
| + | def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_VERSION) | ||
| + | // Variable lookup order : googlePlayServicesMapsVersion > googlePlayServicesVersion > DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION | ||
| + | def googlePlayServicesMapsVersion = safeExtGet('googlePlayServicesMapsVersion', safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION)) | ||
| + | def androidMapsUtilsVersion = safeExtGet('androidMapsUtilsVersion', DEFAULT_ANDROID_MAPS_UTILS_VERSION) | ||
| + | |||
| + | compileOnly "com.facebook.react:react-native:+" | ||
| + | implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion" | ||
| + | implementation "com.google.android.gms:play-services-maps:$googlePlayServicesMapsVersion" | ||
| + | implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion" | ||
| + | //↓追加しないとrunできない | ||
| + | implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" | ||
| + | } | ||
| + | </code> | ||
| + | |||
| + | ==== react-native run-androidをするとすぐおちる ==== | ||
| + | |||
| + | [[https://github.com/react-native-community/react-native-maps/issues/2766|Blank map on android device #2766]] | ||
| + | |||
| + | <code> | ||
| + | > adb logcat | findstr "Google Maps Android API" // windowsなのでgrepがない | ||
| + | ・・・ | ||
| + | 03-29 22:27:58.592 6007 6066 E AndroidRuntime: Process: com.native_background_timer, PID: 6007 | ||
| + | 03-29 22:27:58.592 6007 6066 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion; | ||
| + | ・・・ | ||
| + | </code> | ||
| + | |||
| + | ↓を参考にして native_background_timer\android\app\build.gradle に追加 | ||
| + | [[https://github.com/react-native-community/react-native-maps/issues/818|Failed resolution of com.google.android.gms.maps.GoogleMapOptions #818]] | ||
| + | |||
| + | <code> | ||
| + | android { | ||
| + | compileSdkVersion rootProject.ext.compileSdkVersion | ||
| + | |||
| + | ・・・ | ||
| + | } | ||
| + | |||
| + | defaultConfig { | ||
| + | applicationId "com.native_background_timer" | ||
| + | minSdkVersion rootProject.ext.minSdkVersion | ||
| + | targetSdkVersion rootProject.ext.targetSdkVersion | ||
| + | versionCode 2 | ||
| + | versionName "1.1" | ||
| + | multiDexEnabled true // ADD | ||
| + | } | ||
| + | |||
| + | dependencies { | ||
| + | implementation project(':react-native-maps') | ||
| + | implementation ("com.google.android.gms:play-services-maps:+") { // ADD | ||
| + | force = true; // ADD | ||
| + | } // ADD | ||
| + | implementation 'com.android.support:multidex:1.0.0' // ADD | ||
| + | implementation project(':react-native-background-timer') | ||
| + | implementation fileTree(dir: "libs", include: ["*.jar"]) | ||
| + | implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" | ||
| + | implementation "com.facebook.react:react-native:+" // From node_modules | ||
| + | |||
| + | } | ||
| + | </code> | ||
| + | |||
| + | {{:reactnative:pasted:20190330-094948.png}} | ||