在使用异常的MapView - java.lang.RuntimeException的:存根 [英] Exception when using MapView - java.lang.RuntimeException: stub

查看:217
本文介绍了在使用异常的MapView - java.lang.RuntimeException的:存根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行以下操作例外是有意义的吗?我竭力要查明原因。当我打开它出现的活动(ActivityMap)从MapActivity的子类,即使MapActivity的布局不包含图形页面元素。

我怀疑这是一个项目的问题。我使用的IntelliJ IDEA。我给自己定的项目以构建针对8级地图API。 IDE将不突出任何问题,我在源代码中使用MapActivity的,它建立没有错误 - 在运行时,但随后这个异常

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
>
< com.google.android.maps.MapView
     机器人:layout_width =FILL_PARENT
     机器人:layout_height =FILL_PARENT
     机器人:apiKey =<地图API密钥是在这里与GT;
 />
< / LinearLayout中>
 

和那么活动:

 公共类ActivityMap扩展MapActivity
{
@覆盖
公共无效的onCreate(包savedInstanceState)
{
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activitymap);
}

@覆盖
保护的布尔isRouteDisplayed(){
    返回false;
}

@覆盖
保护的布尔isLocationDisplayed(){
    返回super.isLocationDisplayed();
}
 

}

 了java.lang.RuntimeException:无法实例活动ComponentInfo {com.someapp.myapp / com.someapp.myapp.ActivityMap}:java.lang.RuntimeException的:存根
        在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
        在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
        在android.app.ActivityThread.access $ 1500(ActivityThread.java:117)
        在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:931)
        在android.os.Handler.dispatchMessage(Handler.java:99)
        在android.os.Looper.loop(Looper.java:130)
        在android.app.ActivityThread.main(ActivityThread.java:3683)
        在java.lang.reflect.Method.invokeNative(本机方法)
        在java.lang.reflect.Method.invoke(Method.java:507)
        在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
        在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        在dalvik.system.NativeStart.main(本机方法)
        致:java.lang.RuntimeException的:存根
        在com.google.android.maps.MapActivity< INIT>(来源不明)
        在com.someapp.myapp.ActivityMap< INIT>(ActivityMap.java:7)
        在java.lang.Class.newInstanceImpl(本机方法)
        在java.lang.Class.newInstance(Class.java:1409)
        在android.app.Instrumentation.newActivity(Instrumentation.java:1021)
        在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
 

解决方案

通常运行单元测试,其中的类路径中还包括了Android JAR文件时出现此错误(Android的罐子还包含了JUnit测试包,junit.framework和junit.runner )。

不过,由于你没有运行任何单元测试,问题l​​must在别处。

前阵子,我写了关于如何整合地图一篇文章:的http://blog.doityourselfandroid.com/2011/01/18/using-google-maps-in-your-android-app/

它涵盖了所有的细节所需的步骤,并在集成的地图人拥有。一些常见的错误

Does the following exception make sense to you? I'm struggling to identify the cause. It occurs when I open a an activity (ActivityMap) subclassed from MapActivity, even if the MapActivity's layout doesn't contain a mapview element.

I suspect it's a project issue. I'm using IntelliJ IDEA. I've set the project up to build against the level 8 Maps API. The IDE is not highlighting any issues with my use of MapActivity in the source, and it builds without error - but then this exception at runtime.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:apiKey="<maps api key is here>"
 />
</LinearLayout>

And then the activity:

public class ActivityMap extends MapActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activitymap);
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}

@Override
protected boolean isLocationDisplayed() {
    return super.isLocationDisplayed();
}

}

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.someapp.myapp/com.someapp.myapp.ActivityMap}: java.lang.RuntimeException: stub
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
        at android.app.ActivityThread.access$1500(ActivityThread.java:117)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:130)
        at android.app.ActivityThread.main(ActivityThread.java:3683)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.RuntimeException: stub
        at com.google.android.maps.MapActivity.<init>(Unknown Source)
        at com.someapp.myapp.ActivityMap.<init>(ActivityMap.java:7)
        at java.lang.Class.newInstanceImpl(Native Method)
        at java.lang.Class.newInstance(Class.java:1409)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)

解决方案

This error usually occurs when running unit tests where the classpath also includes the Android JAR file (Android jar also contains junit test packages, junit.framework and junit.runner).

However, as you're not running any unit tests, the problem lmust be somewhere else.

A while back, I've written an article on how to integrate maps : http://blog.doityourselfandroid.com/2011/01/18/using-google-maps-in-your-android-app/

It covers all the steps required in detail, and some common errors people are having when integrating maps.

这篇关于在使用异常的MapView - java.lang.RuntimeException的:存根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆