我的问题不是新问题。但我仍然无法解决问题。我将项目从Eclipse导入Android Studio。最初,我使用谷歌播放服务4.3.23,项目导入Android Studio后,它改为4+。并且MapFragment回复null引用。我试图关注this但仍有问题。
非常感谢任何帮助。这是我的logcat。
10-08 18:01:43.897 30197-30197/sg.searchhouse.mobile.activity I/projectPO﹕ Grange Infinite
10-08 18:01:43.907 30197-30197/sg.searchhouse.mobile.activity E/ViewRootImpl﹕ sendUserActionEvent() mView == null
10-08 18:01:43.907 30197-30197/sg.searchhouse.mobile.activity V/ActivityThread﹕ updateVisibility : ActivityRecord{26a796c6 token=android.os.BinderProxy@2bdc65d {sg.searchhouse.mobile.activity/sg.searchhouse.mobile.activity.NPMProjectSelectionActivity}} show : false
10-08 18:01:44.068 30197-30197/sg.searchhouse.mobile.activity I/u﹕ Making Creator dynamically
10-08 18:01:44.068 30197-30197/sg.searchhouse.mobile.activity D/ResourcesManager﹕ creating new AssetManager and set to /data/app/com.google.android.gms-2/base.apk
10-08 18:01:44.078 30197-30197/sg.searchhouse.mobile.activity W/ResourcesManager﹕ Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
10-08 18:01:44.078 30197-30197/sg.searchhouse.mobile.activity W/ResourcesManager﹕ Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
10-08 18:01:44.128 30197-30218/sg.searchhouse.mobile.activity W/art﹕ Suspending all threads took: 16.143ms
10-08 18:01:44.238 30197-30197/sg.searchhouse.mobile.activity D/ChimeraCfgMgr﹕ Loading module com.google.android.gms.maps from APK /data/data/com.google.android.gms/app_chimera/chimera-module-root/module-588df5a5ceb113dbbd16a6b4eefe2d0baa24f6a7/MapsModule.apk
10-08 18:01:44.238 30197-30197/sg.searchhouse.mobile.activity D/ChimeraModuleLdr﹕ Loading module APK /data/data/com.google.android.gms/app_chimera/chimera-module-root/module-588df5a5ceb113dbbd16a6b4eefe2d0baa24f6a7/MapsModule.apk
10-08 18:01:44.258 30197-30197/sg.searchhouse.mobile.activity D/ChimeraFileApk﹕ Primary ABI of requesting process is armeabi-v7a
10-08 18:01:44.258 30197-30197/sg.searchhouse.mobile.activity I/art﹕ DexFile_isDexOptNeeded failed to open oat file '/data/dalvik-cache/arm/data@data@com.google.android.gms@app_chimera@chimera-module-root@module-588df5a5ceb113dbbd16a6b4eefe2d0baa24f6a7@MapsModule.apk@classes.dex' for file location '/data/data/com.google.android.gms/app_chimera/chimera-module-root/module-588df5a5ceb113dbbd16a6b4eefe2d0baa24f6a7/MapsModule.apk': Failed to open oat filename for reading: No such file or directory
10-08 18:01:44.258 30197-30197/sg.searchhouse.mobile.activity D/ChimeraFileApk﹕ Classloading successful. Optimized code found.
10-08 18:01:44.388 30197-30197/sg.searchhouse.mobile.activity I/Google Maps Android API﹕ Google Play services client version: 4452000
10-08 18:01:44.408 30197-30197/sg.searchhouse.mobile.activity I/Google Maps Android API﹕ Google Play services package version: 8115238
10-08 18:01:44.748 30197-30197/sg.searchhouse.mobile.activity D/AbsListView﹕ Get MotionRecognitionManager
10-08 18:01:45.299 30197-30197/sg.searchhouse.mobile.activity D/AbsListView﹕ Get MotionRecognitionManager
10-08 18:01:45.339 30197-30197/sg.searchhouse.mobile.activity I/project data﹕ Grange Infinite
10-08 18:01:45.359 30197-30197/sg.searchhouse.mobile.activity I/System.out﹕ setUpGoogleMap null
10-08 18:01:45.359 30197-30197/sg.searchhouse.mobile.activity D/AndroidRuntime﹕ Shutting down VM
10-08 18:01:45.359 30197-30274/sg.searchhouse.mobile.activity D/State ::﹕ Start getting bitmap drawable
10-08 18:01:45.359 30197-30275/sg.searchhouse.mobile.activity D/State ::﹕ Start getting bitmap drawable
10-08 18:01:45.359 30197-30197/sg.searchhouse.mobile.activity W/System.err﹕ java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.MapFragment.getMap()' on a null object reference
Java代码
private GoogleMap map;
if (map == null) {
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapFragment)).getMap();
// Check if we were successful in obtaining the map.
if (map != null) {
zoomToMap();
}
}
XML代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativelayout_maps"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
>
<TextView
android:id="@+id/textView_mapBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="@drawable/bluebtn"
android:gravity="center"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="@string/back"
android:layout_margin="15dp"
android:textColor="@color/black"
/>
<fragment
android:id="@+id/mapFragment"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/textView_mapBack" />
</RelativeLayout>
答案 0 :(得分:0)
这个问题:
<?php
$footer_col = 12 / $data["footer_widgets_columns"];
for($i=1; $i <= $data["footer_widgets_columns"]; $i++)
{
if($i != 4){
?>
<article class="col-md-<?php echo $footer_col ?>">
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget '.$i)):
endif;
?>
</article>
<?php
}
else{
?>
<article class="col-md-<?php echo $footer_col ?>" last>
<?php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Widget '.$i)):
endif;
?>
</article>
<?php
}
}
?>
可以使用java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.MapFragment.getMap()' on a null object reference
代替SupportMapFragment
修复
MapFragment
答案 1 :(得分:0)
你需要使用它:
SupportMapFragment fragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.googleMap);
fragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap; // here you set your Google map
// here you do the rest of your calculations with your map
}
});