アプリで Google マップを使用しています。マップを含むフラグメント内で MapView と SupportMapFragment を使用しようとしました。発生した問題により、マップの初期化中に (私がテストしたすべてのデバイスで) 'Build APK' プロセスの後に Google マップがクラッシュしますが、Android Studio (Run を使用) から実行すると、期待どおりに動作します。これはスタック トレースです (すべての実行で得られるのは AssertionError だけです)。
10-19 12:17:27.244 2256-2638/com.google.android.gms E/BaseAppContext: グローバル GMSCore RequestQueue を停止しようとしました。これは意図しない可能性が高いため、無視します。10-19 12:17:28.640 1921-1921/com.google.android.gms.persistent E/BluetoothAdapter: Bluetooth バインダーが null です 10-19 12:17:29.537 1921-1921/com.google.android.gms.persistent E/BluetoothAdapter: Bluetooth バインダーが null 10-19 12:17:29.542 2256-2677/com.google.android.gms E/MDM: [142] rpv.a: Google API クライアントに接続できませんでした: ConnectionResult{statusCode =API_UNAVAILABLE, resolution=null, message=null} 10-19 12:17:30.112 1921-1921/com.google.android.gms.persistent E/ChimeraRcvrProxy: Chimera レシーバー impl クラス com.google.android が見つかりません。 gms.auth.setup.devicesignals.LockScreenChimeraReceiver、ブロードキャスト 10-19 12:17:31.602 2393-2501/com.app E/Surface をドロップ: getSlotFromBufferLocked: 不明なバッファ: 0xaa112310 10-19 12:17:36.351 2776-2782/? E/art: デバッガーへの返信の送信に失敗しました: 壊れたパイプ 10-19 12:17:37.267 1269-1617/? E/SurfaceFlinger: ro.sf.lcd_density をビルド プロパティとして定義する必要があります 10-19 12:17:46.449 1269-1269/? E/EGL_emulation: tid 1269: eglCreateSyncKHR(1370): エラー 0x3004 (EGL_BAD_ATTRIBUTE) 10-19 12:17:47.050 2393-2501/com.app E/Surface: getSlotFromBufferLocked: 不明なバッファ: 0xaa112700 [ 10-19 12:17: 47.094 2393: 2842 D/] HostConnection::get() 新しいホスト接続が確立されました 0xb4050b90、tid 2842 10-19 12:17:47.222 1899-2797/com.android.inputmethod.latin E/Surface: getSlotFromBufferLocked:
ここで述べたように、ビルド gradle で API キーを宣言しています: Google Maps Signed APK Android
マップを初期化する方法のコード サンプル:
public class MainMapFragment extends BaseFragment implements{...
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(Consts.TAGS.FRAG_MAIN_MAP,"BEGIN onCreate()");
super.onCreate(savedInstanceState);
FragmentManager fm = getChildFragmentManager();
_mapFragment = (SupportMapFragment) fm.findFragmentByTag(Consts.TAGS.UTIL_MAP);
if (_mapFragment == null) {
Log.d(Consts.TAGS.FRAG_MAIN_MAP,"mapFragment is null. creating new map...");
_mapFragment = SupportMapFragment.newInstance();
fm.beginTransaction().replace(R.id.map_container, _mapFragment).commit();
_mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
Log.d(Consts.TAGS.FRAG_MAIN_MAP,"BEGIN onMapReady()");
_map = googleMap;
//_map.setInfoWindowAdapter(this);
_map.setInfoWindowAdapter(new CDInfoWindowAdapter(getActivity(),_markersPos));
_map.setOnInfoWindowClickListener(this);
_map.setPadding(120, 120, 170, 200);
MapsInitializer.initialize(getActivity());
initilizeMap();
}
}
これはフラグメントのレイアウトです:
<RelativeLayout tools:context=".MainMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map_container"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<!--<fragment-->
<!--android:id="@+id/map"-->
<!--android:name="com.google.android.gms.maps.SupportMapFragment"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--/>-->
<!--<com.google.android.gms.maps.MapView-->
<!--xmlns:android="http://schemas.android.com/apk/res/android"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:id="@+id/map_view"-->
<!--/>
-->
</RelativeLayout>
コードが実行モードでは機能するが、「Build APK」モードでは機能しない場合、何が問題になる可能性がありますか?