在尝试将Google Map实施到我的片段时,我一直收到以下错误。我已经搜索了很多解决方案,但似乎找不到任何对我有用的东西。
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gvapp.diplomprojekt.at.gv_appandroid">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppThemeNeuigkeiten">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppThemeNeuigkeiten.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Ernaehrung.Rezepte.Details.RezepteDetailActivity"
android:label="@string/title_activity_rezepte_detail_ansicht"
android:parentActivityName=".MainActivity"
android:theme="@style/AppThemeErnaehrung">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="gvapp.diplomprojekt.at.gv_appandroid.MainActivity" />
</activity>
<activity
android:name=".Gesundheit.Details.AerzteDetailActivity"
android:label="@string/title_activity_aerzte_detail"
android:parentActivityName=".MainActivity"
android:theme="@style/AppThemeGesundheit">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="gvapp.diplomprojekt.at.gv_appandroid.MainActivity" />
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD4s85XcK5hio9lyxy3mJGQH9Lnu6Oayng"/>
</application>
</manifest>
我的地图片段。
package gvapp.diplomprojekt.at.gv_appandroid.Gesundheit.Karte;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import gvapp.diplomprojekt.at.gv_appandroid.R;
/**
* A simple {@link Fragment} subclass.
*/
public class AerzteFinderFragment extends Fragment implements OnMapReadyCallback {
GoogleMap mMap;
public AerzteFinderFragment() {
// Required empty public constructor
}
MapFragment mapFragment;
@Override
public void onStart() {
/*mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);*/
super.onStart();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_map, container, false);
return v;
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
布局:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
错误日志:
01-25 15:46:34.394 7566-7566/gvapp.diplomprojekt.at.gv_appandroid I/art: Not late-enabling -Xcheck:jni (already on)
01-25 15:46:34.425 7566-7566/gvapp.diplomprojekt.at.gv_appandroid W/System: ClassLoader referenced unknown path: /data/app/gvapp.diplomprojekt.at.gv_appandroid-2/lib/x86
01-25 15:46:34.445 7566-7566/gvapp.diplomprojekt.at.gv_appandroid I/GMPM: App measurement is starting up, version: 8487
01-25 15:46:34.445 7566-7566/gvapp.diplomprojekt.at.gv_appandroid I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
01-25 15:46:34.449 7566-7566/gvapp.diplomprojekt.at.gv_appandroid E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services. Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
01-25 15:46:34.449 7566-7566/gvapp.diplomprojekt.at.gv_appandroid E/GMPM: Scheduler not set. Not logging error/warn.
01-25 15:46:34.471 7566-7581/gvapp.diplomprojekt.at.gv_appandroid E/GMPM: Uploading is not possible. App measurement disabled
01-25 15:46:34.597 7566-7585/gvapp.diplomprojekt.at.gv_appandroid D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
01-25 15:46:34.657 7566-7585/gvapp.diplomprojekt.at.gv_appandroid I/OpenGLRenderer: Initialized EGL, version 1.4
01-25 15:46:34.699 7566-7585/gvapp.diplomprojekt.at.gv_appandroid W/EGL_emulation: eglSurfaceAttrib not implemented
01-25 15:46:34.699 7566-7585/gvapp.diplomprojekt.at.gv_appandroid W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xad7099c0, error=EGL_SUCCESS
01-25 15:46:35.327 7566-7566/gvapp.diplomprojekt.at.gv_appandroid W/InputMethodManager: Ignoring onBind: cur seq=103, given seq=102
01-25 15:46:44.594 7566-7581/gvapp.diplomprojekt.at.gv_appandroid I/GMPM: Tag Manager is not found and thus will not be used
01-25 15:47:10.724 7566-7566/gvapp.diplomprojekt.at.gv_appandroid I/zzad: Making Creator dynamically
01-25 15:47:10.736 7566-7566/gvapp.diplomprojekt.at.gv_appandroid W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86
01-25 15:47:10.756 7566-7566/gvapp.diplomprojekt.at.gv_appandroid D/ChimeraCfgMgr: Reading stored module config
01-25 15:47:10.759 7566-7566/gvapp.diplomprojekt.at.gv_appandroid D/ChimeraCfgMgr: Loading module com.google.android.gms.maps from APK /data/user/0/com.google.android.gms/app_chimera/chimera-module-root/module-a3e4fba11e705727c59ff3116ef21fa4834b9f56/MapsModule.apk
01-25 15:47:10.759 7566-7566/gvapp.diplomprojekt.at.gv_appandroid D/ChimeraModuleLdr: Loading module APK /data/user/0/com.google.android.gms/app_chimera/chimera-module-root/module-a3e4fba11e705727c59ff3116ef21fa4834b9f56/MapsModule.apk
01-25 15:47:10.761 7566-7566/gvapp.diplomprojekt.at.gv_appandroid D/ChimeraFileApk: Primary ABI of requesting process is x86
01-25 15:47:10.762 7566-7566/gvapp.diplomprojekt.at.gv_appandroid D/ChimeraFileApk: Classloading successful. Optimized code found.
01-25 15:47:10.762 7566-7566/gvapp.diplomprojekt.at.gv_appandroid W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/chimera-module-root/module-a3e4fba11e705727c59ff3116ef21fa4834b9f56/native-libs/x86
01-25 15:47:10.778 7566-7566/gvapp.diplomprojekt.at.gv_appandroid I/Google Maps Android API: Google Play services client version: 8487000
01-25 15:47:10.780 7566-7566/gvapp.diplomprojekt.at.gv_appandroid I/Google Maps Android API: Google Play services package version: 8489470
01-25 15:47:10.863 7566-7566/gvapp.diplomprojekt.at.gv_appandroid W/ContextImpl: Failed to ensure /sdcard/Android/data/gvapp.diplomprojekt.at.gv_appandroid/cache: java.lang.SecurityException: Invalid mkdirs path: /storage/self/primary/Android/data/gvapp.diplomprojekt.at.gv_appandroid/cache
01-25 15:47:10.871 7566-7566/gvapp.diplomprojekt.at.gv_appandroid D/AndroidRuntime: Shutting down VM
01-25 15:47:10.872 7566-7566/gvapp.diplomprojekt.at.gv_appandroid E/AndroidRuntime: FATAL EXCEPTION: main
Process: gvapp.diplomprojekt.at.gv_appandroid, PID: 7566
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class fragment
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at gvapp.diplomprojekt.at.gv_appandroid.Gesundheit.Karte.AerzteFinderFragment.onCreateView(AerzteFinderFragment.java:45)
at android.app.Fragment.performCreateView(Fragment.java:2220)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
at android.app.BackStackRecord.run(BackStackRecord.java:793)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at gvapp.diplomprojekt.at.gv_appandroid.Gesundheit.Karte.AerzteFinderFragment.onCreateView(AerzteFinderFragment.java:45)
at android.app.Fragment.performCreateView(Fragment.java:2220)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
at android.app.BackStackRecord.run(BackStackRecord.java:793)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.io.File.mkdir()' on a null object reference
at com.google.maps.api.android.lib6.gmm6.m.ad.a(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.c.h.a(Unknown Source)
at com.google.maps.api.android.lib6.gmm6.c.ao.a(Unknown Source)
at com.google.maps.api.android.lib6.e.bd.a(Unknown Source)
at com.google.maps.api.android.lib6.e.ev.a(Unknown Source)
at com.google.maps.api.android.lib6.e.z.a(Unknown Source)
at com.google.maps.api.android.lib6.e.y.a(Unknown Source)
at com.google.android.gms.maps.internal.u.onTransact(SourceFile:107)
at android.os.Binder.transact(Binder.java:387)
at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onCreateView(Unknown Source)
at com.google.android.gms.maps.MapFragment$zza.onCreateView(Unknown Source)
at com.google.android.gms.dynamic.zza$4.zzb(Unknown Source)
at com.google.android.gms.dynamic.zza.zza(Unknown Source)
at com.google.android.gms.dynamic.zza.onCreateView(Unknown Source)
at com.google.android.gms.maps.MapFragment.onCreateView(Unknown Source)
at android.app.Fragment.performCreateView(Fragment.java:2220)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:949)
at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2224)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:186)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:754)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at gvapp.diplomprojekt.at.gv_appandroid.Gesundheit.Karte.AerzteFinderFragment.onCreateView(AerzteFinderFragment.java:45)
at android.app.Fragment.performCreateView(Fragment.java:2220)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
at android.app.BackStackRecord.run(BackStackRecord.java:793)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-25 15:52:10.919 7566-7566/? I/Process: Sending signal. PID: 7566 SIG: 9
非常感谢任何帮助。
此致