2016-02-29 73 views
-2

任何人都可以請幫我,爲什麼我不能運行這個簡單的應用程序,它是在Udemy教程,我都檢查過很多次了,完全像它在教程爲什麼我的應用程序停止工作

package com.example.hp250.actions; 

    import android.net.Uri; 
    import android.support.v7.app.AppCompatActivity; 
    import android.os.Bundle; 
    import android.view.View; 
    import java.lang.reflect.InvocationTargetException; 

    public class MainActivity extends AppCompatActivity { 

    @Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
} 

public void OpenApp(View view) { 

    Intent intent=new Intent(Intent.ACTION_VIEW); 
    intent.setData(Uri.parse("market://details?id=com.soundcloud.android")); 
    startActivity(intent); 


    } 
} 

日誌貓:

02-29 06:56:17.774 4886-4886/com.example.hp250.actions I/art: Not  late-enabling -Xcheck:jni (already on) 
02-29 06:56:17.775 4886-4886/com.example.hp250.actions I/art: Late-enabling JIT 
02-29 06:56:17.777 4886-4886/com.example.hp250.actions I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000 
02-29 06:56:17.843 4886-4886/com.example.hp250.actions W/System: ClassLoader referenced unknown path: /data/app/com.example.hp250.actions-1/lib/x86 
02-29 06:56:18.013 4886-4910/com.example.hp250.actions D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true 
02-29 06:56:18.056 4886-4910/com.example.hp250.actions I/OpenGLRenderer: Initialized EGL, version 1.4 
02-29 06:56:18.190 4886-4910/com.example.hp250.actions W/EGL_emulation: eglSurfaceAttrib not implemented 
02-29 06:56:18.190 4886-4910/com.example.hp250.actions W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xad7607e0, error=EGL_SUCCESS 
02-29 06:56:20.394 4886-4886/com.example.hp250.actions D/AndroidRuntime: Shutting down VM 
02-29 06:56:20.395 4886-4886/com.example.hp250.actions E/AndroidRuntime: FATAL EXCEPTION: main 
                     Process: com.example.hp250.actions, PID: 4886 
                     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: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.soundcloud.android } 
                      at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798) 
                      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.hp250.actions.MainActivity.OpenApp(MainActivity.java:23) 
                      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)  
02-29 06:56:22.922 4886-4886/? I/Process: Sending signal. PID: 4886 SIG: 9 
+1

您可以從logcat添加日誌嗎? – TechnoBlahble

+0

02-29 06:56:20.395 4886-4886/com.example.hp250.actions E/AndroidRuntime:致命例外:main 進程:com.example.hp250.actions,PID:4886 java.lang.IllegalStateException:可能不執行Android的方法:onClick at android.support.v7.app.AppCompatViewInflater $ DeclaredOnClickListener.onClick(AppCompatViewInflater.java:275) –

+0

請將完整的logcat放入原始問題中,而不是作爲註釋。 –

回答

3
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.soundcloud.android } 

您運行的缺乏Play商店或處理market://detailsUriACTION_VIEW任何其他活動的設備或仿真器上的應用程序。

+0

我怎麼能糾正這PLZ,知道我已經跑了另一個應用程序在相同的AVD「地理:經度和緯度」沒有問題 –

+0

@ZahraaFatma:事實上,你有一個地圖應用程序不意味着你有Play商店。使用具有Play商店或其他響應該「Uri」的設備。或者,不要使用'Uri'。 – CommonsWare

相關問題