我对Google地图还算陌生,所以不确定从哪里开始解决这个问题。仅当我点击“应用更改”按钮时才会发生,而当我“运行应用程序”时则不会发生。另外,我的values文件夹中没有dimen xml:
06-23 09:15:30.772 2268-2268/com.driptosinha.eataway.eataway E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.locate.store.eataway, PID: 2268
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locate.store/com.locate.store.MainActivity}: android.content.res.Resources$NotFoundException: Resource "com.locate.store:dimen/card_icon_multiline_padding_bottom" (7f060059) is not a Drawable (color or path): TypedValue{t=0x5/d=0xc30c21 a=3 r=0x7f060059}
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5382)
at android.app.ActivityThread.access$1200(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1800)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.content.res.Resources$NotFoundException: Resource "com.driptosinha.eataway.eataway:dimen/card_icon_multiline_padding_bottom" (7f060059) is not a Drawable (color or path): TypedValue{t=0x5/d=0xc30c21 a=3 r=0x7f060059}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:4178)
at android.content.res.Resources.loadDrawable(Resources.java:4085)
at android.content.res.Resources.getDrawable(Resources.java:2005)
at android.content.res.Resources.getDrawable(Resources.java:1987)
at android.content.res.Resources.getDrawable(Resources.java:1961)
at com.google.maps.api.android.lib6.impl.aw.e(:com.google.android.gms.dynamite_mapsdynamite@17785047@17.7.85 (040308-253824076):35)
at com.google.maps.api.android.lib6.impl.fw.<init>(:com.google.android.gms.dynamite_mapsdynamite@17785047@17.7.85 (040308-253824076):12)
at com.google.maps.api.android.lib6.impl.bg.a(:com.google.android.gms.dynamite_mapsdynamite@17785047@17.7.85 (040308-253824076):32)
at com.google.maps.api.android.lib6.impl.dd.a(:com.google.android.gms.dynamite_mapsdynamite@17785047@17.7.85 (040308-253824076):2)
at com.google.maps.api.android.lib6.impl.de.a(:com.google.android.gms.dynamite_mapsdynamite@17785047@17.7.85 (040308-253824076):11)
at com.google.android.gms.maps.internal.t.a(:com.google.android.gms.dynamite_mapsdynamite@17785047@17.7.85 (040308-253824076):29)
at hp.onTransact(:com.google.android.gms.dynamite_mapsdynamite@17785047@17.7.85 (040308-253824076):4)
at android.os.Binder.transact(Binder.java:387)
at com.google.android.gms.internal.maps.zza.zzb(Unknown Source)
at com.google.android.gms.maps.internal.zzk.onCreate(Unknown Source)
at com.google.android.gms.maps.MapView$zza.onCreate(Unknown Source)
at com.google.android.gms.dynamic.zac.zaa(Unknown Source)
at com.google.android.gms.dynamic.zaa.onDelegateCreated(Unknown Source)
at com.google.android.gms.maps.MapView$zzb.createDelegate(Unknown Source)
at com.google.android.gms.dynamic.DeferredLifecycleHelper.zaa(Unknown Source)
at com.google.android.gms.dynamic.DeferredLifecycleHelper.onCreate(Unknown Source)
at com.google.android.gms.maps.MapView.onCreate(Unknown Source)
at com.driptosinha.eataway.eataway.ui.MapviewFragment.initGoogleMap(MapviewFragment.java:404)
at com.driptosinha.eataway.eataway.ui.MapviewFragment.onCreateView(MapviewFragment.java:191)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreat
这是将错误归因于以下方法:
private void initGoogleMap(Bundle savedInstanceState) {
// *** IMPORTANT ***
// MapView requires that the Bundle you pass contain _ONLY_ MapView SDK
// objects or sub-Bundles.
Bundle mapViewBundle = null;
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
mapView.onCreate(mapViewBundle);
mapView.getMapAsync(this);
if (geoApiContext == null) {
geoApiContext = new GeoApiContext.Builder().apiKey(getString(R.string.google_api_key)).build();
}
}
和调用它的onCreateView方法如下:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
pickupView = inflater.inflate(R.layout.fragment_mapview, container, false);
((MainActivity) getActivity()).setActionBarTitle("Find your restaurant");
mapView = pickupView.findViewById(R.id.list_map);
ImageView resetButton = pickupView.findViewById(R.id.button_reset_map);
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(mapviewContext);
bundle = getArguments();
resetButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addMarkers();
}
});
getUser();
initGoogleMap(savedInstanceState);
return pickupView;
}