编程语言
首页 > 编程语言> > java-FragmentMapActivity中的NoClassDefFoundError

java-FragmentMapActivity中的NoClassDefFoundError

作者:互联网

我经常看到这个问题,但是所提出的解决方案似乎都不适合我.我越来越

E/AndroidRuntime(897): java.lang.NoClassDefFoundError: android.support.v4.app.FragmentMapActivity$4

尝试打开新的FragmentMapActivity时.

码:

public class Maps extends FragmentMapActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maps_simple);

  //MapView for the lose :(
    Toast.makeText(this, R.string.map_warning, Toast.LENGTH_LONG).show();

    MapView mapView = (MapView)findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}
}

R.layout.maps_simple包含:

<?xml version="1.0" encoding="utf-8"?>  
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="<key removed for security>"
    />

表现:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="osmstudios.mappingapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="13" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 

<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/Theme.MapApp" android:hardwareAccelerated="true">

    <uses-library android:name="com.google.android.maps" />

    <activity android:label="@string/app_name" android:name=".AppMainActivity">
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
  <activity android:label="@string/app_name" android:name="com.keyes.youtube.OpenYouTubePlayerActivity"></activity>
    <activity android:label="@string/app_name" android:name=".Maps">
        <intent-filter>
                   <action android:name="android.intent.action.VIEW" />
                   <category android:name="osmstudios.mappingapp" />
                </intent-filter>
    </activity>

</application>

</manifest>

这是打开FragmentMapActivity意图的按钮按下的内部代码:

Intent intent = new Intent(ctx, Maps.class); 
startActivity(intent);

最后,这是我的Java Build Path工具中的Libraries文件夹的样子:

我真的一直在把头撞在墙上.任何帮助,将不胜感激.

解决方法:

这有点晚了,但是我遇到了完全相同的问题,并且至少可以解决“ java.lang.NoClassDefFoundError:”.在项目属性-> java构建路径->中库,我从android sdk路径中包含了android-support-v4.jar.该库在编译时可用,但在运行时不可用.您需要将此jar从sdk路径复制到应用程序库位置,这样该库将被静态添加到您的应用程序中,并且可以在运行时找到.希望这可以帮助.我在StackOverFlow中进行了大量搜索后找到了这个解决方案.她是链接. Trying to use DialogFragments via v4 compatability causes NoClassDefFoundErrors

标签:android-fragments,google-maps,actionbarsherlock,java,android
来源: https://codeday.me/bug/20191101/1985748.html