mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 913 forks source link

Plugin is not defined when the app is built on PhoneGap Build #411

Closed svarc closed 9 years ago

svarc commented 9 years ago

Hello there. I have seen many issues reported for this same problem but none of them solves or suits the issue i encounter.

I installed the plugin automatically and when i type "phonegap plugin list" i get this result: android.support.v4 21.0.1 "Android Support v4" com.google.playservices 21.0.0 "Google Play Services for Android" plugin.google.maps 1.2.4 "phonegap-googlemaps-plugin" plugin.http.request 1.0.0 "phonegap-http-request"

This is how i call the map: var map; var div = document.getElementById("map_canvas"); map = plugin.google.maps.Map.getMap(div);

I get this error: ReferenceError: plugin is not defined map = plugin.google.maps.Map.getMap(div);

The app is compiling without error, the map div (map_canvas) is shown but the map is blank no buttons no nothing. Anyone have any idea about how to fix this? Thanks in advance and best wishes.

wf9a5m75 commented 9 years ago

Do you use Android phone or emulator? And does it have Google Play Services?

svarc commented 9 years ago

i am using android 4.4.2 phone (Lenovo S820) yes it have google play services.

wf9a5m75 commented 9 years ago

Ok, is there any error message in logcat?

wf9a5m75 commented 9 years ago

Could you show me the whole logcat log?

svarc commented 9 years ago

"adb logcat" gives me result: 'abd' is not recognized as an internal or external command, operable program or batch file.

i have android platform-tools and tools added in Environment Variables but... i am new to android development so i dont know how to handle this. sorry for being pain in the a**. i am using windows 7

wf9a5m75 commented 9 years ago

http://stackoverflow.com/questions/19168643/how-to-easily-view-and-filter-androids-logcat-in-windows

wf9a5m75 commented 9 years ago

or http://stackoverflow.com/a/7829983

svarc commented 9 years ago

thanks for the reply, its too late here i will have to read and research tomorrow. i will let you know what i will find out. thanks for the fast response.

svarc commented 9 years ago

ok finally i managed to get the log. for those who run into the same problem here is how to get the log: first of all go to (on your phone) settings -> developer options and check USB debugging and Stay awake. connect the USB cable from the PC to your phone and in the phone select connect as usb device and click enable usb. go to "Android\android-sdk\platform-tools" in command prompt where your Android SDK is installed and execute this command "adb devices" the result of the command should be something like List of devices attached 0123456789ABCDEF device if instead "device" it says "offline" then you should disconnect and reconnect your phone. if there is no device displayed then you done something wrong with the settings. next go to "Android\android-sdk\tools" and start "ddms.bat" which will start Dalvik Debug Monitor. next go to your project folder thru command prompt and execute this command: phonegap run android --device the application will be started on your phone and the log messages will start showing in the Dalvik Debug Monitor, you can then easy save the log messages to file from there.

ok now back to the issue, here is my log file (i will work on my filtering skills next, so sorry for the long log): http://www.fun-kids-games.biz/test/log.txt

wf9a5m75 commented 9 years ago

Thanks, @svarc I checked your log, but it seems it doesn't have any related messages from plugin, that's really weird. Please send me your apk file to my email address : wf9a5m75@gmail.com

svarc commented 9 years ago

ok i will send you the apk and the whole source of my project. will reach you in few seconds. thanks for your help.

wf9a5m75 commented 9 years ago

@svarc This plugin does not support PhoneGap Build, yet.

svarc commented 9 years ago

oh well :( then i wasted few days for nothing it seems. thanks for your help, i really appreciate that. i am really sorry for taking your time. thanks again and best wishes.

wf9a5m75 commented 9 years ago

Sorry, I'm planing to support Phonegap Build, but I don't have enough time for it currently.

MichaelGooden commented 9 years ago

Sorry to interrupt, but I use this plugin with Phonegap Build just fine :)

In my config.xml:

  <gap:plugin name="plugin.google.maps" source="plugins.cordova.io" version="~1.2.4">
    <param name="API_KEY_FOR_ANDROID" value="xyz" />
    <param name="API_KEY_FOR_IOS" value="123" />
  </gap:plugin>

Works on both Android and iOS. :)

wf9a5m75 commented 9 years ago

Thanks good information, @MichaelGooden I haven't tested PhoneGap Build yet. Would you write a tutorial page for PhoneGap Build?

wf9a5m75 commented 9 years ago

https://github.com/wf9a5m75/phonegap-googlemaps-plugin/wiki/PhoneGap-Build

Axel-CH commented 9 years ago

Hello, I am trying to integrate the module in my application but I have exactly the same problem as @svarc .(ReferenceError: plugin is not defined). So I have two questions. -I Have read previously that the module is not yet compatible with "phonegap build". How should I build my application to obtain an apk? -I Tried configuring config.xml, as indicated by @MichaelGooden but it still does not work. Apparently the same problem. Thank you in advance.

MichaelGooden commented 9 years ago

Please view your app on PhoneGap Build, and go to the "Plugins" tab on your app (Next to "Builds" tab). Do you see plugin.google.maps under the "Installed Plugins" header?

Axel-CH commented 9 years ago

Hi thank you for your response, -I'm sorry but i'm a little bit confused when you talk about "PhoneGap Build". Usually i use the command line in order to build my app with this command "phonegap build android" . So, when you talk about PhoneGap Build, it is a reference to "Adobe® PhoneGap™ Build cloud service". -When i lanch "phonegap plugin list" in my console i see this list:

android.support.v4 21.0.1 "Android Support v4" com.google.playservices 21.0.0 "Google Play Services for Android" com.phonegap.plugins.PushPlugin 2.4.0 "PushPlugin" com.plugin.datepicker 0.4.0 "DatePicker" org.apache.cordova.device 0.2.13-dev "Device" org.apache.cordova.file 1.3.2-dev "File" org.apache.cordova.file-transfer 0.4.6 "File Transfer" org.apache.cordova.geolocation 0.3.12 "Geolocation" org.apache.cordova.network-information 0.2.12 "Network Information" plugin.google.maps 1.2.4 "phonegap-googlemaps-plugin" plugin.http.request 1.0.4 "phonegap-http-request"

So, i the google map plugin are in the list , i hope that i responded to your question. Thank you

MichaelGooden commented 9 years ago

Yes, I was referring to the "Adobe® PhoneGap™ Build cloud service". This issue is also specifically about that. If you use my code in your config.xml it will only work if you are using the PhoneGap Build service.

This issue will not resolve your problems. Follow all the instructions in the wiki, and if you are still having problems open a new issue :)

Axel-CH commented 9 years ago

Thank you very much ;-) i'll try tomorow.

wf9a5m75 commented 9 years ago

@MichaelGooden :+1:

svarc commented 9 years ago

Thanks @MichaelGooden and @wf9a5m75 for your help. i still havent tried what you said but i will do it in the next few days and post the results here. @Axel-CH i found out something which might help in some way. when building your app use this command: phonegap -d build android > build.log this will save all the build messages to a file "build.log" (which might be useful for debugging)in the same path from where you execute the command. same works for cordova too you just need to replace phonegap with cordova in the command.

Axel-CH commented 9 years ago

Hi, finally the map is working ^^ . I had a SHA1 key mismatch. this link helped me : https://developers.google.com/games/services/android/troubleshooting (now i have a css issue with my framework, so i'll chek the forum for similar issue) Thank you guys ! @MichaelGooden @sangariv @svarc

wf9a5m75 commented 9 years ago

Congrats, @Axel-CH

@svarc Have you tested ?

wf9a5m75 commented 9 years ago

I close this issue at once. If @svarc has any updates, please just post here. I will open this issue again.

paganm commented 9 years ago

I had problem with Phonegap Build Service. I used the solution as @MichaelGooden metioned above. Android apk was running perfect but in ios i received the message "Api key is not setted. Please replace 'API_KEY_FOR_IOS' in the platforms/ios/.../...Info.plist with your API key."

For some reason, API_KEY_FOR_IOS value was ignored.

I used the solution

<gap:config-file platform="ios" parent="Google Maps API Key" mode="replace">      
    <string>xxx</string>
</gap:config-file>

https://stackoverflow.com/questions/30435391/plugin-plugin-google-maps-using-phonegap-build-service-doesnt-work-on-ios

Menusito commented 8 years ago

hello, good day, im trying to implement this plugin on my phonegap build app but when I put the follow code the compiler fails:

<gap:plugin name="plugin.google.maps" source="plugins.cordova.io" version="1.2.4">
    <param name="API_KEY_FOR_ANDROID" value="here-my-api-key" />
</gap:plugin>

and the compiler display this: http://coderbeat.com/uploads/log

any documentation how to use on phonegap build or has an example?

paganm commented 8 years ago

Can you try the latest version 1.2.5 first?

Menusito commented 8 years ago

hi, i detect the problem, this plugin is not working with the last version of "Phonegap Build" cli-5.1.1 Android 4.0.2, if I use the old version 3.7 compile OK. I dont know if is a bug of cloud service or of the plugin.

paganm commented 8 years ago

https://github.com/wf9a5m75/phonegap-googlemaps-plugin/pull/516

Menusito commented 8 years ago

thank you! working good with @Nipher version.

prasoon0304 commented 8 years ago

i have used the plugin and tried to build through Phonegap build.Map is just displayed as GREY area . in config file i have given under param name the value of android and ios. but it shows grey. why does it shows like that?

Leomhl commented 8 years ago

The plugin works only with wifi. How to use with 3G?

prasoon0304 commented 8 years ago

It works with all network.2G,3G,Wifi. You need to give permission to access your network.

On Tue, Jul 7, 2015 at 8:41 AM, Leomhl notifications@github.com wrote:

The plugin works only with wifi. How to use with 3G?

— Reply to this email directly or view it on GitHub https://github.com/wf9a5m75/phonegap-googlemaps-plugin/issues/411#issuecomment-119057667 .

Thanks and Regards,

Prasoon P

Leomhl commented 8 years ago

How? It does not work without wi fi. With 3G turned it asks to enable wi fi.

erasmo-marin commented 8 years ago

@007pRASoon did you solve this? I have this problem, and sometimes it works if I open an app with geolocation permissions first (ie waze), so, I think it's a problem with the plugin activating geolocation.

I added this to config.xml with no success:

<feature name="http://api.phonegap.com/1.0/geolocation"/>

pd: I'm using phonegap build service

grtapps commented 8 years ago

@erasmo-marin the url in the name attribute isn't even working though.

If you're using the phonegap build cloud services, use it this way.

davidluthiers commented 8 years ago

@MichaelGooden your solution doesn't work anymore, plugins.cordova.io just got deprecated and can't be used.

I tried any other combination, from the one PhonegapBuild offers in his Plugin page (why it's still there? It doesn't load!) to the ones on the npm and the most promising seems this one: https://www.npmjs.com/package/cordova-plugin-googlemaps , that would translate into this on config.xml:

plugin name="plugin.google.maps" source="plugins.cordova.io" version="~1.2.4

But this plugin on npmjs doesn't seem to have any version below 1.3.0 and the ones above require some gradle configuration which I couldn't set properly (the prefence called "android-minSdkVersion" doesn't do anything), probably requires an AndroidManifest tweak.

I'm really puzzled about the state of this, isn't anyone using google map on phonegap build?

lengoyvaerts commented 8 years ago

I tried installing it with Phonegap Build today and got the following error:

<gap:plugin name="cordova-plugin-googlemaps" source="npm">
    <param name="API_KEY_FOR_ANDROID" value="XXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
    <param name="API_KEY_FOR_IOS" value="XXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
</gap:plugin>

untitled

This is the page the error links to but I don't see anything to fix it: http://docs.build.phonegap.com/en_US/support_failed-builds.md.html#gradle_required

Adding preference name="android-build-tool" value="gradle" gave the following error (although shouldn't be required because from cli-5.1.1 onwards, gradle should be the default build): untitled

MilestoneCMS commented 8 years ago

@lengoyvaerts I have no problem with "Oh geez. Your build failed ...". In my case, the building process works. Fortunately PhoneGap Build resolved the issue: https://twitter.com/PhoneGapBuild/status/649051981936365568

davidluthiers commented 8 years ago

@MilestoneCMS Yes, I found that gradle solution today on Twitter too :D but my problem is that I have to use a cordova version below 4, because of Drupalgap requiring it, so I can't use the last plugin with the gradle fix. I also found a previous version of the same plugin (forked) so it could work with Phonegap 3.7.0, but then I have the "Oh geez". If anyone is interested I opened a thread in the Phonegap forum: http://community.phonegap.com/nitobi/topics/cant-build-with-google-maps-plugin

joaoibsilva commented 8 years ago

Hello When building with PGB cli 5.2 using this plugin: gap:plugin name="cordova-plugin-googlemaps" source="npm" version="1.3.4" param name="API_KEY_FOR_ANDROID" value="My key" param name="API_KEY_FOR_IOS" value="My other key" gap:plugin i get the following error erro1 I have checked and the most updated version of this plugin is 1.3.4 Any thoughts would be much appreciatted.

trknov commented 8 years ago

image

mogiman commented 8 years ago

Hi, I am using the phonegap google map plugin that you have mentioned, I use the online phonegap to build my apk

Just wondering where My config.xml should sit, in the root directory, res/xml/config.xml, www/config.xml, or root directory.

where should My index.xml sit in the root directory or www/index.html or root directory where .cordova.CORDOVA file should sit, I have in the same directory as my index.html,

and where the following files should sit. I have them in my root directory.

- AndroidManifest.xml
- package.json
- plugin.xml

also if I could get a copy of someone's index.html for code for the google maps plugin

At the moment I am getting a blank screen, but the google logo appears in the lower left hand corner. The only reason why I get the blank google screen with the logo even showing is because I have

< script type="text/javascript" src="cordova.js">< /script>

in my index.html and the ".corodva.CORDOVA" file sitting in the same directory which is the www directory.

If I dont have this line of code I dont even get a blank google map screen, nothing appears at all

If I could get some answers on this from someone who has the plugin working that would be great.

Thanks