2016-08-26 89 views
-1

我在android開發新的和正在此錯誤:無法爲Android的執行方法Android的運行時錯誤:運行我的應用程序時的onClick

FATAL EXCEPTION: main 
    Process: com.example.brayo.allgps, PID: 2204 
    java.lang.IllegalStateException: Could not execute method for android:onClick 
     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:275) 
     at android.view.View.performClick(View.java:5198) 
     at android.view.View$PerformClick.run(View.java:21147) 
     at android.os.Handler.handleCallback(Handler.java:739) 
     at android.os.Handler.dispatchMessage(Handler.java:95) 
     at android.os.Looper.loop(Looper.java:148) 
     at android.app.ActivityThread.main(ActivityThread.java:5417) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
    Caused by: java.lang.reflect.InvocationTargetException 
     at java.lang.reflect.Method.invoke(Native Method) 
     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:270) 
     at android.view.View.performClick(View.java:5198) 
     at android.view.View$PerformClick.run(View.java:21147) 
     at android.os.Handler.handleCallback(Handler.java:739) 
     at android.os.Handler.dispatchMessage(Handler.java:95) 
     at android.os.Looper.loop(Looper.java:148) 
     at android.app.ActivityThread.main(ActivityThread.java:5417) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
    Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.brayo.allgps/com.example.brayo.allgps.GPSDraw}; have you declared this activity in your AndroidManifest.xml? 
     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1794) 
     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512) 
     at android.app.Activity.startActivityForResult(Activity.java:3917) 
     at android.app.Activity.startActivityForResult(Activity.java:3877) 
     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784) 
     at android.app.Activity.startActivity(Activity.java:4200) 
     at android.app.Activity.startActivity(Activity.java:4168) 
     at com.example.brayo.allgps.MainActivity.onClickSwitchActivity(MainActivity.java:111) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:270) 
     at android.view.View.performClick(View.java:5198) 
     at android.view.View$PerformClick.run(View.java:21147) 
     at android.os.Handler.handleCallback(Handler.java:739) 
     at android.os.Handler.dispatchMessage(Handler.java:95) 
     at android.os.Looper.loop(Looper.java:148) 
     at android.app.ActivityThread.main(ActivityThread.java:5417) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
08-26 07:58:08.086 2204-2212/com.example.brayo.allgps W/art: Suspending all threads took: 458.626ms 

回答

0

通過你的錯誤日誌的樣子,好像你已經聲明瞭視圖的onClick屬性(可能是按鈕),但是沒有在你的activity類中定義函數。

請將您的活動和XML佈局文件發佈爲更清晰。

相關問題