7

明示的なインテントを使用して、AndroidアプリにMapViewを表示しようとしています。コードに問題はありませんが、アクティビティを開始しようとすると「NoClassDefFoundError」が発生し続けます。基本的に、私のメインアクティビティ(SetCriteria)から、ユーザーがボタンを押したときに明示的なインテントを作成します。

 Log.i(TAG, "Showing map..");
 try{
   Intent intentMap = new Intent(view.getContext(), AddLocation.class);
   startActivity(intentMap);
}catch(Throwable ex) {
   Log.e(TAG, "Error occured while trying to display map", ex);
}

LogCatは次のように表示されます。

 java.lang.NoClassDefFoundError: com.adm.AddLocation
 ...
 Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

私のマニフェストは次のようになります。

<application android:label="@string/app_name" android:icon="@drawable/ic_launcher_red">
    <uses-library android:name="com.google.android.maps"/>              
    <activity android:name=".SetCriteria"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>        
    <activity android:name=".AddLocation" 
          android:label="@string/add_location">         
    </activity>
</application>

私はcom.admという1つのパッケージしか持っていません。では、何が間違っている可能性がありますか?Intent(Intent.ACTION_VIEW、uri)を使用してマップを起動することに問題はありませんが、マップを処理する特定のアクティビティが必要です。

4

2 に答える 2

1

マニフェストスニペットからは、どのパッケージを定義したかが明確ではありません。

あなたはそれをトップレベルのマニフェスト要素に入れる必要があります:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.adm"
          >

    <application android:icon="@drawable/icon" android:label="@string/app_name" ...

これを追加しない場合、システムはパッケージを使用せず、アクティビティ「.AddLocation」はクラスなしで「AddLocation」として終了します。これは。と同じではありませんcom.adm.AddLocation

于 2011-05-01T14:29:02.687 に答える
1

2番目のアクティビティ宣言でクラス名の前の""(ドット)を削除する必要があり.ます。これにより、次のようになります。

<activity android:name="AddLocation" android:label="@string/add_location">
于 2011-05-01T14:56:24.600 に答える