创建了类ActivityAdd,onClick定义。此布局上的任何按钮和类都有效。请告诉我这里有什么问题?
我的错误日志:
12-20 10:48:47.780: E/AndroidRuntime(21934): FATAL EXCEPTION: main
12-20 10:48:47.780: E/AndroidRuntime(21934): java.lang.IllegalStateException: Could not execute method of the activity
12-20 10:48:47.780: E/AndroidRuntime(21934): at android.view.View$1.onClick(View.java:3601)
12-20 10:48:47.780: E/AndroidRuntime(21934): at android.view.View.performClick(View.java:4206)
12-20 10:48:47.780: E/AndroidRuntime(21934): at android.view.View$PerformClick.run(View.java:17357)
12-20 10:48:47.780: E/AndroidRuntime(21934): at android.os.Handler.handleCallback(Handler.java:725)
12-20 10:48:47.780: E/AndroidRuntime(21934): at android.os.Handler.dispatchMessage(Handler.java:92)
12-20 10:48:47.780: E/AndroidRuntime(21934): at android.os.Looper.loop(Looper.java:137)
12-20 10:48:47.780: E/AndroidRuntime(21934): at android.app.ActivityThread.main(ActivityThread.java:5041)
12-20 10:48:47.780: E/AndroidRuntime(21934): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 10:48:47.780: E/AndroidRuntime(21934): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 10:48:47.780: E/AndroidRuntime(21934): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-20 10:48:47.780: E/AndroidRuntime(21934): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-20 10:48:47.780: E/AndroidRuntime(21934): at dalvik.system.NativeStart.main(Native Method)
12-20 10:48:47.780: E/AndroidRuntime(21934): Caused by: java.lang.reflect.InvocationTargetException
12-20 10:48:47.780: E/AndroidRuntime(21934): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 10:48:47.780: E/AndroidRuntime(21934): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 10:48:47.780: E/AndroidRuntime(21934): at android.view.View$1.onClick(View.java:3596)
12-20 10:48:47.780: E/AndroidRuntime(21934): ... 11 more
12-20 10:48:47.780: E/AndroidRuntime(21934): Caused by: java.lang.NoClassDefFoundError: mk.run4rebate.ActivityAdd
12-20 10:48:47.780: E/AndroidRuntime(21934): at mk.run4rebate.ActivityAddSearch.startAddActivity(ActivityAddSearch.java:144)
12-20 10:48:47.780: E/AndroidRuntime(21934): at mk.run4rebate.ActivityAddSearch.activities(ActivityAddSearch.java:115)
12-20 10:48:47.780: E/AndroidRuntime(21934): at mk.run4rebate.ActivityAddSearch.AddOnClick(ActivityAddSearch.java:72)
12-20 10:48:47.780: E/AndroidRuntime(21934): ... 14 more
AddOnClick方法:
public void AddOnClick(View view){
Intent intent = new Intent();
intent.setClass(this, ActivityAdd.class);
startActivity(intent);
finish();
}
布局按钮:
<ImageButton
android:id="@+id/buttonAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageBig"
android:layout_alignRight="@+id/imageBig"
android:layout_marginBottom="@dimen/margin_button_add_top"
android:layout_marginRight="@dimen/margin_button_add_left"
android:background="@null"
android:onClick="AddOnClick"
android:src="@drawable/main_button_add" />
更正了完整的Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="mk.run4rebate"
android:versionCode="1"
android:versionName="1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto" >
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="mk.run4rebate.ActivityStart"
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="mk.run4rebate.ActivityRegistration"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
/>
<activity android:name="mk.run4rebate.ActivityAccount"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
/>
<activity android:name="mk.run4rebate.ActivityAddSearch"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
/>
<activity android:name="mk.run4rebate.ActivityAdd"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
/>
<activity android:name="mk.run4rebate.ActivityCategoryList"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
/>
<activity android:name="mk.run4rebate.ActivitySearch"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
/>
<activity android:name="mk.run4rebate.ActivityOption"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
/>
</application>
</manifest>
答案 0 :(得分:0)
如果您使用外部jar,请确保将其导出到apk。
你可以这样做
Go to Properties -> Java Build Path -> "Order and Export"
并检查所有导出的库