Android Explicit Intent 抛出 NoClassDefFounderror

标签 android android-intent maps explicit

我正在尝试使用明确的 Intent 在我的 Android 应用程序中显示 MapView。虽然我没有发现我的代码有任何问题,但当我尝试开始我的 Activity 时,我总是收到“NoClassDefFoundError”。 基本上,在我的主要 Activity (SetCriteria) 中,我会在用户按下按钮时创建明确的 Intent :

 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

我的 list 看起来像这样:

<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。那有什么问题呢?我可以使用 Intent(Intent.ACTION_VIEW, uri) 启动 map ,但我希望我的特定 Activity 能够处理 map 。

最佳答案

您应该在第二个 Activity 声明中删除类名前的“.”(点),这样它看起来像:

<activity android:name="AddLocation" android:label="@string/add_location">

关于Android Explicit Intent 抛出 NoClassDefFounderror,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5848769/

相关文章:

android - ListView 中 View 上的动画

java - 如何制作一个编码良好的启动画面

android - 根据 Intent Extra 的值禁用 Android 向上导航

readOGR (rgdal) 无法从 XML 获取多边形名称

android - 将 mapView 缩放到 osmdroid 上的某个边界框

java - 在 AsyncTask 中使用从 LoaderManager 返回的 Cursor

android - 结合 layout_weight 和 maxHeight?

java - 如何快速地将位图从一个 Activity 传递到另一个 Activity ?

android - 在有 Intent 地启动 Activity 之前清除 Activity 堆栈

android - 在印度使用 PIN 码在谷歌地图上定位地点