我的项目内容粘贴在下面。我想我已经有了从所有这些不同的帖子中推荐的一切,但是,像许多其他人一样,我得到了这个通货膨胀运行时错误。
这个实际的项目取自Vogella教程,它甚至不会编译。我从其他帖子中应用了相同问题的修复。
谁能告诉我如何使这工作?有人知道任何地方有一个可行的例子吗?谢谢,加里
清单文件。..
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.mapdemo.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="I have a valid V2 key here" />
</manifest>
我的主布局XML文件。...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.mapdemo.MainActivity"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
MainActivity.java文件。..(祝代码粘贴在此论坛上有效)
package com.example.mapdemo;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
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 android.support.v4.app.FragmentActivity {
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
}
Logcat...(粘贴这些东西有什么秘诀吗?)
08-12 13:00:52.380: W/dalvikvm(8118): VFY: unable to resolve instance field 28
08-12 13:00:52.550: W/dalvikvm(8118): Unable to resolve superclass of Lmaps/p/w; (734)
08-12 13:00:52.550: W/dalvikvm(8118): Link of class 'Lmaps/p/w;' failed
08-12 13:00:52.550: W/dalvikvm(8118): Unable to resolve superclass of Lmaps/ap/as; (6056)
08-12 13:00:52.550: W/dalvikvm(8118): Link of class 'Lmaps/ap/as;' failed
08-12 13:00:52.550: W/dalvikvm(8118): Unable to resolve superclass of Lmaps/af/k; (5085)
08-12 13:00:52.550: W/dalvikvm(8118): Link of class 'Lmaps/af/k;' failed
08-12 13:00:52.550: E/dalvikvm(8118): Could not find class 'maps.af.k', referenced from method maps.ag.an.a
08-12 13:00:52.550: W/dalvikvm(8118): VFY: unable to resolve new-instance 4928 (Lmaps/af/k;) in Lmaps/ag/an;
08-12 13:00:52.681: W/dalvikvm(8118): threadid=1: thread exiting with uncaught exception (group=0x40017560)
08-12 13:00:52.691: E/AndroidRuntime(8118): FATAL EXCEPTION: main
08-12 13:00:52.691: E/AndroidRuntime(8118): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapdemo/com.example.mapdemo.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.os.Looper.loop(Looper.java:130)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-12 13:00:52.691: E/AndroidRuntime(8118): at java.lang.reflect.Method.invokeNative(Native Method)
08-12 13:00:52.691: E/AndroidRuntime(8118): at java.lang.reflect.Method.invoke(Method.java:507)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
08-12 13:00:52.691: E/AndroidRuntime(8118): at dalvik.system.NativeStart.main(Native Method)
08-12 13:00:52.691: E/AndroidRuntime(8118): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.app.Activity.setContentView(Activity.java:1657)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.example.mapdemo.MainActivity.onCreate(MainActivity.java:26)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-12 13:00:52.691: E/AndroidRuntime(8118): ... 11 more
08-12 13:00:52.691: E/AndroidRuntime(8118): Caused by: java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
08-12 13:00:52.691: E/AndroidRuntime(8118): at maps.ag.bb.a(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at maps.ag.bb.a(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at maps.ag.an.a(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at maps.ag.bi.a(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at maps.ag.bh.a(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at blf.onTransact(SourceFile:107)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.os.Binder.transact(Binder.java:279)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.google.android.gms.internal.bh$4.b(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.google.android.gms.internal.bh.a(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.google.android.gms.internal.bh.onCreateView(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)
08-12 13:00:52.691: E/AndroidRuntime(8118): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
08-12 13:00:52.691: E/AndroidRuntime(8118): ... 20 more
08-12 13:00:52.691: E/AndroidRuntime(8118): Caused by: java.lang.RuntimeException: API key not found
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.commonsware.android.mapsv2.basic"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="false"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar">
<activity
android:name="MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyC4iyT46cB00IdKGcy5EmAxK5uCOQX2Oy8"/>
<activity android:name="LegalNoticesActivity">
</activity>
</application>
</manifest>
所以我看到了一个特殊的例外,我敢肯定的是谷歌地图的绘图代码。 我有一个片段,在那里我以编程方式添加了一个支持地图片段,然后我在其中操纵谷歌地图实例。 这是stacktrace: 我无法可靠地复制它(尽管这种情况经常发生),我已经查看了ReadWriteDirectByteBuffer和ShortToByteBufferAdapter,但没有任何东西突然出现在我面前。 有什么想法吗?
我认为问题是我需要添加构建提示。我可以找到在哪里添加他们,但我不确定他们应该是什么格式。我也不知道要补充什么。我想我发现了一个帖子,说我需要添加Android.xapplication=Android:value=“Your Key”/>Android.xPermissions= 但我不确定构建提示条目表单中的格式是什么
LSV默认的对谷歌影像进行了加载,如果需要加载其他的谷歌地图数据,可以通过LSV中直接点击即可加载。
最近Chrome开始发出以下警告: [违规]将非被动事件侦听器添加到阻止滚动的触摸移动事件。考虑将事件处理程序标记为“被动”,以使页面更具响应性。看https://www.chromestatus.com/feature/5745543795965952 这些都来自JavaScript谷歌地图API代码。我可以在自己的代码中将{passive:true}添加到addEventListener(),
02-14 13:09:38.184:e/databaseUtils(2348):向包写入异常02-14 13:09:38.184:e/databaseUtils(2348):java.lang.securityexception:权限拒绝:用户的get/set设置要求以用户-2的身份运行,但从用户0调用;这需要Android.permission.interact_across_users_fu
我正在尝试创建如何使用MapView获取。我创建了一个片段和一个XML来使用它。问题是,当我尝试打开MapView时,它会抛出NullPointerException,但我无法理解为什么。 我该怎么解决呢? XML 碎片 例外