我正在关注mybringback网站的android教程。我已经正确地遵循了,但是我遇到了错误,我不明白为什么:
public class Main extends MapActivity {
MapView map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = (MapView) findViewById(R.id.mvMain);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
logcat的:
02-24 14:58:12.603:E / AndroidRuntime(1483):致命异常:主
02-24 14:58:12.603:E / AndroidRuntime(1483):流程: com.prashant.maps,PID:1483
02-24 14:58:12.603:E / AndroidRuntime(1483): java.lang.RuntimeException:无法启动活动 ComponentInfo {com.prashant.maps / com.prashant.maps.Main}: android.view.InflateException:二进制XML文件行#7:错误 充气类com.google.android.maps.Mapview
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.ActivityThread.access $ 800(ActivityThread.java:144)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1278)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.os.Handler.dispatchMessage(Handler.java:102)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.os.Looper.loop(Looper.java:135)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.ActivityThread.main(ActivityThread.java:5221)
02-24 14:58:12.603:E / AndroidRuntime(1483):at java.lang.reflect.Method.invoke(Native Method)
02-24 14:58:12.603:E / AndroidRuntime(1483):at java.lang.reflect.Method.invoke(Method.java:372)
02-24 14:58:12.603:E / AndroidRuntime(1483):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:899)
02-24 14:58:12.603:E / AndroidRuntime(1483):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
02-24 14:58:12.603:E / AndroidRuntime(1483):引起: android.view.InflateException:二进制XML文件行#7:错误 充气类com.google.android.maps.Mapview
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
02-24 14:58:12.603:E / AndroidRuntime(1483):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.Activity.setContentView(Activity.java:2144)
02-24 14:58:12.603:E / AndroidRuntime(1483):at com.prashant.maps.Main.onCreate(Main.java:15)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.Activity.performCreate(Activity.java:5933)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
02-24 14:58:12.603:E / AndroidRuntime(1483):... 10更多
02-24 14:58:12.603:E / AndroidRuntime(1483):引起: java.lang.ClassNotFoundException:没找到类 " com.google.android.maps.Mapview"在路径上:DexPathList [[zip文件 " /system/framework/com.google.android.maps.jar" ;, zip文件 #&34; /data/app/com.prashant.maps-2/base.apk"],nativeLibraryDirectories = [/供应商/ lib中, /系统/ lib中]]
02-24 14:58:12.603:E / AndroidRuntime(1483):at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
02-24 14:58:12.603:E / AndroidRuntime(1483):at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
02-24 14:58:12.603:E / AndroidRuntime(1483):at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.view.LayoutInflater.createView(LayoutInflater.java:571)
02-24 14:58:12.603:E / AndroidRuntime(1483):at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
02-24 14:58:12.603:E / AndroidRuntime(1483):... 20更多
02-24 14:58:12.603:E / AndroidRuntime(1483):抑制: java.lang.ClassNotFoundException:com.google.android.maps.Mapview
02-24 14:58:12.603:E / AndroidRuntime(1483):at java.lang.Class.classForName(Native Method)
02-24 14:58:12.603:E / AndroidRuntime(1483):at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
02-24 14:58:12.603:E / AndroidRuntime(1483):at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
02-24 14:58:12.603:E / AndroidRuntime(1483):at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
02-24 14:58:12.603:E / AndroidRuntime(1483):... 23更多
02-24 14:58:12.603:E / AndroidRuntime(1483):引起: java.lang.NoClassDefFoundError:使用引导类找不到类 装载机;没有可用的堆栈
答案 0 :(得分:0)
可能没有引用com.google.android.maps库。检查它是否包含在解决方案中(在构建路径,订单和导出选项卡中,应该检查此库)或者您可以作为开源包含到项目中
答案 1 :(得分:0)