我在Android中的谷歌地图会产生一张黑色地图。是因为我的文件设置不正确(图书馆在错误的地方等等吗?)
图片:
黑屏:
图书馆等等:
我所有导入的库都是正确的吗?
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sonnet"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<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="com.example.barcodelibrary.permission.MAPS_RECEIVE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.sonnet.FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.sonnet.Map"
android:label="@string/title_activity_map" >
</activity>
<activity
android:name="com.example.sonnet.MapActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_map"
android:theme="@style/FullscreenTheme" >
</activity>
<uses-library android:name="com.google.android.maps"/>
<meta-data
android:name="com.google.android.maps.v2.stuff"
android:value="stuff" />
</application>
</manifest>
'stuff'意味着我的API密钥。
我的Logcat:
02-06 16:14:44.735: D/AndroidRuntime(5651): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-06 16:14:44.735: D/AndroidRuntime(5651): CheckJNI is OFF
02-06 16:14:44.745: D/dalvikvm(5651): Trying to load lib libjavacore.so 0x0
02-06 16:14:44.745: D/dalvikvm(5651): Added shared lib libjavacore.so 0x0
02-06 16:14:44.755: D/dalvikvm(5651): Trying to load lib libnativehelper.so 0x0
02-06 16:14:44.755: D/dalvikvm(5651): Added shared lib libnativehelper.so 0x0
02-06 16:14:44.895: D/AndroidRuntime(5651): Calling main entry com.android.commands.pm.Pm
02-06 16:14:44.895: D/AndroidRuntime(5651): Shutting down VM
02-06 16:14:44.895: D/dalvikvm(5651): Debugger has detached; object registry had 1 entries
02-06 16:14:44.895: I/AndroidRuntime(5651): NOTE: attach of thread 'Binder_1' failed
02-06 16:14:45.365: D/AndroidRuntime(5661): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-06 16:14:45.365: D/AndroidRuntime(5661): CheckJNI is OFF
02-06 16:14:45.375: D/dalvikvm(5661): Trying to load lib libjavacore.so 0x0
02-06 16:14:45.375: D/dalvikvm(5661): Added shared lib libjavacore.so 0x0
02-06 16:14:45.385: D/dalvikvm(5661): Trying to load lib libnativehelper.so 0x0
02-06 16:14:45.385: D/dalvikvm(5661): Added shared lib libnativehelper.so 0x0
02-06 16:14:45.515: D/AndroidRuntime(5661): Calling main entry com.android.commands.am.Am
02-06 16:14:45.525: D/dalvikvm(5661): Note: class Landroid/app/ActivityManagerNative; has 163 unimplemented (abstract) methods
02-06 16:14:45.525: I/ActivityManager(432): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.sonnet/.FullscreenActivity} from pid 5661
02-06 16:14:45.565: D/AndroidRuntime(5661): Shutting down VM
02-06 16:14:45.565: D/jdwp(5661): Got wake-up signal, bailing out of select
02-06 16:14:45.565: D/dalvikvm(5661): Debugger has detached; object registry had 1 entries
02-06 16:14:45.565: D/dalvikvm(5672): Late-enabling CheckJNI
02-06 16:14:45.575: I/ActivityManager(432): Start proc com.example.sonnet for activity com.example.sonnet/.FullscreenActivity: pid=5672 uid=10031 gids={50031, 3003, 1015, 1028}
02-06 16:14:45.595: D/dalvikvm(122): GC_EXPLICIT freed 40K, 2% free 7478K/7584K, paused 1ms+2ms, total 29ms
02-06 16:14:45.625: D/dalvikvm(122): GC_EXPLICIT freed <1K, 2% free 7478K/7584K, paused 1ms+2ms, total 27ms
02-06 16:14:45.655: D/dalvikvm(122): GC_EXPLICIT freed <1K, 2% free 7478K/7584K, paused 1ms+2ms, total 28ms
02-06 16:14:45.995: D/libEGL(5672): loaded /system/lib/egl/libEGL_tegra.so
02-06 16:14:46.035: D/libEGL(5672): loaded /system/lib/egl/libGLESv1_CM_tegra.so
02-06 16:14:46.055: D/libEGL(5672): loaded /system/lib/egl/libGLESv2_tegra.so
02-06 16:14:46.095: D/OpenGLRenderer(5672): Enabling debug mode 0
02-06 16:14:46.125: I/ActivityManager(432): Displayed com.example.sonnet/.FullscreenActivity: +566ms
02-06 16:14:46.395: D/TilesManager(5672): Starting TG #0, 0x641e71c8
02-06 16:14:46.395: D/TilesManager(5672): new EGLContext from framework: 62607d38
02-06 16:14:46.395: D/GLWebViewState(5672): Reinit shader
02-06 16:14:46.405: D/GLWebViewState(5672): Reinit transferQueue
02-06 16:14:48.705: W/ProcessStats(432): Skipping unknown process pid 5698
02-06 16:14:48.705: W/ProcessStats(432): Skipping unknown process pid 5709
02-06 16:14:48.705: W/ProcessStats(432): Skipping unknown process pid 5710
答案 0 :(得分:1)
查看您的清单文件,我发现至少有一个问题:
1 - 为application
代码
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
然后,请确保您已在Google API控制台中启用了Google Maps API,并且您根据用于签署该应用的证书使用了正确的API密钥。
此处描述了所有程序:https://developers.google.com/maps/documentation/android/start