开发者

Google Api Key doesn't work

I took an api key from Google for to use Google Maps for my android app. Yesterday it was working like charm but today i got an error when trying to load map. I opened logcat and it said

Failed to find prov开发者_如何转开发ider info for com.google.settings

Can anyone tell me how to fix this problem?

EDIT: My real issue is not because of that. That's because i got nullpointer exception error.

01-18 17:38:18.174: ERROR/AndroidRuntime(1348): Caused by: java.lang.NullPointerException
01-18 17:38:18.174: ERROR/AndroidRuntime(1348):     at com.android.listxml.MyMap.onCreate(Map.java:69)

At this 69th line i have this code:

View zoomView = mapView.getZoomControls();


Can you please post the error you're getting, as the "Failed to find provider info..." is not related to this issue. Also, what changes were done recently that made it stopped working ?

Are you seening a stacktrace in logcat, or are you just seeing an empty map (no tiles being loaded) ?

You should double-check the following requirements for displaying maps in your Activity :

  • A MapView component needs to be added to the layout that you're inflating in your Activity, and it should contain a valid Google Maps API key
  • The Google Maps API key is linked to your SDK keystore. If you change the keystore, your API key will no longer be valid.
  • The Activity that will be responsible for showing the map needs to extend from MapActivity
  • The application manifest needs to be setup with the android.permission.INTERNET permission
  • The application manifest needs to be setup with the com.google.android.maps library
  • The application needs to run on an emulator with a target that includes the Google APIs

Some basic info is available in the android sdk docs.

The nullpointer exception can only be caused by the fact that mapView is null. Assuming your code contains something like this :

setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview1);

Double check that the layout you're inflating (main.xml in this case), contains a MapView component with id mapview1, like the snippet below :

<com.google.android.maps.MapView 
    android:id="@+id/mapview1"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:enabled="true" 
    android:clickable="true" 
    android:apiKey="your api key here" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜