Discussion Forums  >  Maps, Device Location, Tracking

Replies: 23    Views: 6369

RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
03/19/15 12:43 PM (9 years ago)

[SOLVED] - AndroidStudio package issue with Google Maps

Google Maps issue in Android Studio project from buzztouch.com: I am having this crash when I try to load my Google Maps using the new AndroidStudio version of BT.com package. What I've done so far: 1) I was able to successfully use Google Maps with the old Eclipse package, and using Marks instructions 2) made sure I put my new SHAkey;package_name into my list of Android Applications at <a href="https://console.developers.google.com/project" target="_blank" rel="nofollow">https://console.developers.google.com/project</a> 3) Updated my AndroidManifest. xml file <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value= 4) used DiffMerge to compare the BT_screen_map.java files (Eclipse version vs the AndroidStudio version), but this was past my understanding Error from my LogCat: 03-19 15:26:10.899 7488-7488/com.ScsAndroidBuzz031915 W/ZZ﹕ WB_screen_menuImage:onPause JSON itemId: "74F89A8245650D01A2168FE" itemType: "WB_screen_menuImage" itemNickname: "LandMenu" 03-19 15:26:10.899 7488-7488/com.ScsAndroidBuzz031915 W/ZZ﹕ WB_screen_menuImage:onStop JSON itemId: "74F89A8245650D01A2168FE" itemType: "WB_screen_menuImage" itemNickname: "LandMenu" 03-19 15:26:10.899 7488-7488/com.ScsAndroidBuzz031915 W/ZZ﹕ BT_screen_map:onAttach JSON itemId: "8B0AE4503A72BA74C39573B" itemType: "BT_screen_map" itemNickname: "SC_WMA_MAP" 03-19 15:26:10.899 7488-7488/com.ScsAndroidBuzz031915 W/ZZ﹕ BT_screen_map:onCreate JSON itemId: "8B0AE4503A72BA74C39573B" itemType: "BT_screen_map" itemNickname: "SC_WMA_MAP" 03-19 15:26:10.899 7488-7488/com.ScsAndroidBuzz031915 W/ZZ﹕ BT_screen_map:onCreateView JSON itemId: "8B0AE4503A72BA74C39573B" itemType: "BT_screen_map" itemNickname: "SC_WMA_MAP" 03-19 15:26:10.900 7488-7488/com.ScsAndroidBuzz031915 W/ZZ﹕ BT_screen_map:onCreate. Found Google Maps v2 API Key: XXXXXXXXXXXXXXXXXXXXXXXX 03-19 15:26:10.919 7488-7488/com.ScsAndroidBuzz031915 I/x﹕ Making Creator dynamically 03-19 15:26:10.926 7488-7488/com.ScsAndroidBuzz031915 W/ResourcesManager﹕ Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources. 03-19 15:26:10.926 7488-7488/com.ScsAndroidBuzz031915 W/ResourcesManager﹕ Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources. 03-19 15:26:10.946 7488-7488/com.ScsAndroidBuzz031915 I/Google Maps Android API﹕ Google Play services client version: 6587000 03-19 15:26:10.955 7488-7488/com.ScsAndroidBuzz031915 I/Google Maps Android API﹕ Google Play services package version: 7097436 03-19 15:26:11.476 533-1318/? I/art﹕ Explicit concurrent mark sweep GC freed 74700(3MB) AllocSpace objects, 10(4MB) LOS objects, 31% free, 35MB/51MB, paused 1.892ms total 103.393ms 03-19 15:26:11.727 7488-7488/com.ScsAndroidBuzz031915 D/AndroidRuntime﹕ Shutting down VM --------- beginning of crash 03-19 15:26:11.728 7488-7488/com.ScsAndroidBuzz031915 E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.ScsAndroidBuzz031915, PID: 7488 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 at com.ScsAndroidBuzz031915.BT_screen_map.onCreateView(BT_screen_map.java:181) at android.app.Fragment.performCreateView(Fragment.java:2053) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:894) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) at android.app.BackStackRecord.run(BackStackRecord.java:833) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452) at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 03-19 15:26:11.729 533-828/? W/ActivityManager﹕ Force finishing activity com.ScsAndroidBuzz031915/.BT_activity_host 03-19 15:26:11.804 533-659/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/19/15 01:05 PM (9 years ago)
What's on line 181? also edit the post because api key is showing.or just make a new one
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
03/19/15 01:15 PM (9 years ago)
line 181 from BT_screen_map.java: mapView = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapView)).getMap();
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/19/15 04:58 PM (9 years ago)
Edit ----- Testing , will post back
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/19/15 07:46 PM (9 years ago)
I tested and the location map works with no problems. how did you generate the sha1 key? This is how I generate mine: http://stackoverflow.com/questions/27609442/how-to-get-the-sha1-fingerprint-certificate-in-android-studio-for-debug-mode keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android you can leave out the alias.Thats for the mac.For windows: keytool -list -v -keystore c:\users\your_user_name\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
03/19/15 08:00 PM (9 years ago)
That is same syntax I'm using, and I'm not seeing the familiar LOGCAT error if I have the wrong SHA1 key in there...it even tells you what to put in to fix it. Are you getting it to work with the new AndroidStudio Android package? I did it twice, and both had the same JAVA error. Then I did one on my self-hosted, with the Eclipse-based Android package,and the map worked. Pulling my hair out on this....any help appreciated.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/19/15 08:09 PM (9 years ago)
Also you have to make an apk ,then install that on the device to test maps.Try making an apk and not worry about the error. See if the error still persists after you've installed the apk. Yes Im using the new android studio buzztouch project. Not the old eclipse package
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
03/19/15 08:27 PM (9 years ago)
Yeah, done that about 10 times across 3 projects today...burned out, try again tomorrow. Thanks CMCOFFEE for trying, really appreciate it.
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
03/20/15 07:40 AM (9 years ago)
Figured it out, had to do this In Android Studio, File, Project Structure, Under properties, set my Compile SDK to API 14 (was set to 21). Then under Flavors, set Target SDK to API 14 as well. Clean, Build and Run - Google maps works fine!
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/20/15 07:55 AM (9 years ago)
Nice glad you got it working
 
snowman7040
Lost but trying
Profile
Posts: 83
Reg: Jul 03, 2013
lawton
5,430
like
11/15/15 08:08 PM (9 years ago)
ok I have done everything you guys have done put it on a phone and it just crash when I go to use my location maps any help would be great
 
snowman7040
Lost but trying
Profile
Posts: 83
Reg: Jul 03, 2013
lawton
5,430
like
11/15/15 08:56 PM (9 years ago)
logcat info 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: FATAL EXCEPTION: main 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: Process: com.tramp4life, PID: 15403 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: 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 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at com.tramp4life.BT_screen_map.onCreateView(BT_screen_map.java:181) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.app.Fragment.performCreateView(Fragment.java:2149) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:912) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.app.BackStackRecord.run(BackStackRecord.java:833) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1580) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.app.FragmentManagerImpl$1.run(FragmentManager.java:451) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.os.Looper.loop(Looper.java:155) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5696) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028) 11-15 22:09:13.831 15403-15403/com.tramp4life E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
 
ehwright
Aspiring developer
Profile
Posts: 57
Reg: Feb 21, 2012
Perth
2,370
like
11/24/15 01:30 AM (9 years ago)
Hi I'm getting this error when running my app on a Samsung Galaxy s4, but not when running the same app on an HTC mini. Changing the target versions to 14 is not an option for me. Has anyone got any other suggestions?
 
ehwright
Aspiring developer
Profile
Posts: 57
Reg: Feb 21, 2012
Perth
2,370
like
11/24/15 06:10 PM (9 years ago)
Found a fix to my problem, it looks like a workaround for the moment. Here is the code that I changed: It's where the map is created, on the newer version of android the app is crashing using the old code, when I changed the call to getchildfragmentmanager instead of getfragmentmanager, the older version of the app crashed. So I needed to check whether the fragment was null after creating. //get reference to the map in the screen_map.xml file... // getfragmentmanager returning null on android 5.0.1 but not returning null on getchildfragmentmanager // getfragmentmanager ok on 4.2.2 but getchildfragmentmanager returns null. com.google.android.gms.maps.MapFragment myfrag = (MapFragment) getFragmentManager().findFragmentById(R.id.mapView); if (myfrag != null){ mapView = myfrag.getMap(); }else { myfrag = (MapFragment) getChildFragmentManager().findFragmentById(R.id.mapView); if(myfrag != null) mapView = myfrag.getMap(); }
 
snowman7040
Lost but trying
Profile
Posts: 83
Reg: Jul 03, 2013
lawton
5,430
like
11/25/15 03:05 PM (9 years ago)
That's in the manifest right
 
snowman7040
Lost but trying
Profile
Posts: 83
Reg: Jul 03, 2013
lawton
5,430
like
11/25/15 04:19 PM (9 years ago)
That's in the manifest right
 
ehwright
Aspiring developer
Profile
Posts: 57
Reg: Feb 21, 2012
Perth
2,370
like
11/25/15 04:38 PM (9 years ago)
It's in the maps plugin file. Where the map is created
 
snowman7040
Lost but trying
Profile
Posts: 83
Reg: Jul 03, 2013
lawton
5,430
like
11/25/15 08:31 PM (9 years ago)
getting an error from this do i need to add something Error:(188, 30) error: cannot find symbol variable getChildFragmentManager
 
ehwright
Aspiring developer
Profile
Posts: 57
Reg: Feb 21, 2012
Perth
2,370
like
11/25/15 10:09 PM (9 years ago)
getChildFragmentManager was introduced in api level 17 so I updated my app's minSdkVersion to this.
 
snowman7040
Lost but trying
Profile
Posts: 83
Reg: Jul 03, 2013
lawton
5,430
like
11/26/15 12:18 AM (9 years ago)
THIS IS WHAT I AM GETTING FOR THE LOG WINDOW /Users/briancraig/Desktop/tramp4life-for-Android-Studio-2/app/src/main/java/com/tramp4life/BT_screen_map.java:188: error: cannot find symbol myfrag = (MapFragment) (getChildFragmentManager).findFragmentById(R.id.mapView); ^ symbol: variable getChildFragmentManager location: class BT_screen_map /Users/briancraig/Desktop/tramp4life-for-Android-Studio-2/app/src/main/java/com/tramp4life/BT_screen_map.java:188: error: illegal start of type myfrag = (MapFragment) (getChildFragmentManager).findFragmentById(R.id.mapView);
 
ehwright
Aspiring developer
Profile
Posts: 57
Reg: Feb 21, 2012
Perth
2,370
like
11/26/15 02:51 AM (9 years ago)
It's in the maps plugin file. Where the map is created
 
ehwright
Aspiring developer
Profile
Posts: 57
Reg: Feb 21, 2012
Perth
2,370
like
11/26/15 03:01 AM (9 years ago)
It's in the maps plugin file. Where the map is created
 
ehwright
Aspiring developer
Profile
Posts: 57
Reg: Feb 21, 2012
Perth
2,370
like
11/26/15 03:04 AM (9 years ago)
Sorry about the extra posts Check if these support libraries are added to the grade modules file dependencies { compile 'com.android.support:support-v4:21.0.3' compile 'com.android.support:appcompat-v7:21.0.3' } If not try adding ten as dependencies
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
08/05/16 04:09 PM (8 years ago)
RonBo - your solution fixed my problems. TY!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.