Я создаю новое приложение, и я столкнулся с проблемой. Когда я запускаю приложение (на моем физическом устройстве и в genymotion с сервисом google play, которое было включено как протестировано), приложение запускается нормально, но экран серый, я могу видеть только кнопку местоположения и приближать и уменьшать масштаб. Я видел других людей, имеющих эту проблему, но ни один из ответов не помог. Вот мой код. Ошибки были сделаны? Заранее спасибо:>Google Maps Android V2 Gray/Blank Screen App
MainActivity.java
package tk.chom.randomstudio.alcofinder;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class MainActivity extends ActionBarActivity {
// Constant for defining latitude and longitude
static final LatLng myPosition = new LatLng(40 , -79);
// GoogleMap class
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// verify we can interact with the Google Map
try {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().
findFragmentById(R.id.map)).getMap();
}
// Show a satellite map with roads, MapType is used here
/* MAP_TYPE_NORMAL: Basic map with roads.
MAP_TYPE_SATELLITE: Satellite view with roads.
MAP_TYPE_TERRAIN: Terrain view without roads.
*/
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
// Place dot on current location
googleMap.setMyLocationEnabled(true);
// Turns traffic layer on
googleMap.setTrafficEnabled(true);
// Enables indoor maps
googleMap.setIndoorEnabled(true);
// Turns on 3D buildings
googleMap.setBuildingsEnabled(true);
// Show Zoom buttons
googleMap.getUiSettings().setZoomControlsEnabled(true);
// Create a marker in the map at a given position with a title
Marker marker = googleMap.addMarker(new MarkerOptions().
position(myPosition).title("Siemano, tu jesteś"));
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tk.chom.randomstudio.alcofinder" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission
android:name="tk.chom.randomstudio.alcofinder.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".SplashScreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="@string/app_name"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBEZVa9R8xxxxxxxxxxxxxxxxxxxx"/>
</application>
... нет подключение к интернету ... – Selvin
Что вы имеете в виду? – TheGalax