问题描述
我试图用一个明确的意图,以显示在我的Android应用程序一个图形页面。虽然我看不出什么毛病我的code,我不断收到一个NoClassDefFoundError的当我想开始我的活动。 基本上,从我的主要活动(SetCriteria),我创建了明确的意图,当用户presses一个按钮:
I'm trying to use an explicit intent to display a MapView in my android app. Although I don't see anything wrong with my code, I keep getting a "NoClassDefFoundError" when I try to start my activity. Basically, from my main activity (SetCriteria), I create the explicit intent when user presses a button :
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中显示:
My LogCat displays:
java.lang.NoClassDefFoundError: com.adm.AddLocation
...
Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
我的清单看起来是这样的:
My Manifest looks like this:
<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.ACTION_VIEW,URI)推出了地图,但我想我处理地图的具体活动。
I have only one package: com.adm. So what could be wrong? I have no problem launching a map by using Intent(Intent.ACTION_VIEW, uri) but I want my specific activity dealing with the map.
推荐答案
您应该删除。
(点)之前,你的类名中第二个活动的声明,所以它看起来像:
You should remove the ".
" (dot) before your class name in the second activity declaration, so it would look like:
<activity android:name="AddLocation" android:label="@string/add_location">
这篇关于Android的明确意图引发NoClassDefFound错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!