每次我发出一个GET语句时,应用程序都会崩溃。我怎样才能解决这个问题?

时间:2015-05-21 02:45:48

标签: java android android-asynctask get

我真的很困惑为什么我遇到这个问题。我对android开发很新,所以我不确定在解决这个问题时从哪里开始。我在清单文件中拥有所有必需的权限。和。

如果我使用像"http://www.google.com"这样的网址,则应用可以正常工作。我已经使用"https://api.discogs.com/users/mrblahblahblacksheep/collection/folders/0/releases?page=1&per_page=1"测试了我尝试使用的网址("https://www.hurl.it/"),它运行正常。但出于某种原因,当我尝试使用我的应用程序运行它时会崩溃。

当按下按钮时,调用myClickHandler并将url发送到downloadWebPageTask,后者启动ASyncTask。此AsyncTank获取URL,然后发送GET请求。这是我的代码。

public void myClickHandler(View view) {
    SetText url = new SetText();
    //String string_url = url.createURL(artist_text.getText().toString(), release_text.getText().toString());
    new DownloadWebpageTask().execute("https://api.discogs.com/users/mrblahblahblacksheep/collection/folders/0/releases?page=1&per_page=1");
}

public class DownloadWebpageTask extends AsyncTask<String, Void, String> {
    @Override
    protected String doInBackground(String... urls) {

        String url = urls[0];
        String final_response = "FAILED!";

        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet(url);

        HttpResponse response;
        try {
            response = client.execute(request);

            final_response = EntityUtils.toString(response.getEntity());
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return final_response;
    }
    // onPostExecute displays the results of the AsyncTask.
    @Override
    protected void onPostExecute(String result) {
        if(result == null) {
            result_text.setText("Try Again");
        } else {
            result_text.setText(result);
        }
    }
}

最后,这是按下按钮时logcat打印出来的错误消息:

05-20 22:34:50.404      485-550/system_process W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
05-20 22:34:50.568    2014-2031/blahblahblacksheep.com.searchfordiscogs I/art﹕ Background partial concurrent mark sweep GC freed 4038(228KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 2MB/4MB, paused 73.938ms total 138.022ms
05-20 22:34:50.791    2014-2170/blahblahblacksheep.com.searchfordiscogs A/libc﹕ Fatal signal 4 (SIGILL), code 2, fault addr 0xb721f5ce in tid 2170 (AsyncTask #5)
05-20 22:34:50.893        87-87/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-20 22:34:50.893        87-87/? I/DEBUG﹕ Build fingerprint: 'generic/vbox86p/vbox86p:5.1/LMY47D/buildbot04091026:userdebug/test-keys'
05-20 22:34:50.893        87-87/? I/DEBUG﹕ Revision: '0'
05-20 22:34:50.893        87-87/? I/DEBUG﹕ ABI: 'x86'
05-20 22:34:50.893        87-87/? I/DEBUG﹕ pid: 2014, tid: 2170, name: AsyncTask #5  >>> blahblahblacksheep.com.searchfordiscogs <<<
05-20 22:34:50.893        87-87/? I/DEBUG﹕ signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr 0xb721f5ce
05-20 22:34:50.901        87-87/? I/DEBUG﹕ eax a20c201c  ebx a1f012ec  ecx 00000014  edx a20c2018
05-20 22:34:50.905        87-87/? I/DEBUG﹕ esi a1f012e8  edi b73033e4
05-20 22:34:50.905        87-87/? I/DEBUG﹕ xcs 00000073  xds 0000007b  xes 0000007b  xfs 000000a7  xss 0000007b
05-20 22:34:50.905        87-87/? I/DEBUG﹕ eip b721f5ce  ebp 00000010  esp a1f01238  flags 00210202
05-20 22:34:50.905        87-87/? I/DEBUG﹕ backtrace:
05-20 22:34:50.905        87-87/? I/DEBUG﹕ #00 pc 000965ce  /system/lib/libcrypto.so (CRYPTO_memcmp+126)
05-20 22:34:50.905        87-87/? I/DEBUG﹕ #01 pc 0002b1f9  /system/lib/libssl.so (ssl3_read_bytes+1353)
05-20 22:34:50.905        87-87/? I/DEBUG﹕ #02 pc 0001e398  /system/lib/libssl.so (ssl3_get_message+312)
05-20 22:34:50.905        87-87/? I/DEBUG﹕ #03 pc 0001dc16  /system/lib/libssl.so (ssl3_get_finished+70)
05-20 22:34:50.905        87-87/? I/DEBUG﹕ #04 pc 000207ae  /system/lib/libssl.so (ssl3_connect+2222)
05-20 22:34:50.905        87-87/? I/DEBUG﹕ #05 pc 00015cc4  /system/lib/libjavacrypto.so
05-20 22:34:50.905        87-87/? I/DEBUG﹕ #06 pc 003a901c  /data/dalvik-cache/x86/system@framework@boot.oat
05-20 22:34:51.147        87-87/? I/DEBUG﹕ Tombstone written to: /data/tombstones/tombstone_06
05-20 22:34:51.148      485-507/system_process I/BootReceiver﹕ Copying /data/tombstones/tombstone_06 to DropBox (SYSTEM_TOMBSTONE)
05-20 22:34:51.223      485-525/system_process W/InputDispatcher﹕ channel '32c3b9fd blahblahblacksheep.com.searchfordiscogs/blahblahblacksheep.com.searchfordiscogs.SearchForDiscogs (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
05-20 22:34:51.223      485-525/system_process E/InputDispatcher﹕ channel '32c3b9fd blahblahblacksheep.com.searchfordiscogs/blahblahblacksheep.com.searchfordiscogs.SearchForDiscogs (server)' ~ Channel is unrecoverably broken and will be disposed!
05-20 22:34:51.292      485-502/system_process I/ActivityManager﹕ Process blahblahblacksheep.com.searchfordiscogs (pid 2014) has died
05-20 22:34:51.292     485-1004/system_process I/WindowState﹕ WIN DEATH: Window{32c3b9fd u0 blahblahblacksheep.com.searchfordiscogs/blahblahblacksheep.com.searchfordiscogs.SearchForDiscogs}
05-20 22:34:51.292     485-1004/system_process W/InputDispatcher﹕ Attempted to unregister already unregistered input channel '32c3b9fd blahblahblacksheep.com.searchfordiscogs/blahblahblacksheep.com.searchfordiscogs.SearchForDiscogs (server)'
05-20 22:34:51.294      485-502/system_process W/ActivityManager﹕ Force removing ActivityRecord{31d393c7 u0 blahblahblacksheep.com.searchfordiscogs/.SearchForDiscogs t55}: app died, no saved state
05-20 22:34:51.295        95-95/? I/Zygote﹕ Process 2014 exited due to signal (4)
05-20 22:34:51.302      190-190/? W/SurfaceFlinger﹕ couldn't log to binary event log: overflow.
05-20 22:34:51.383      485-535/system_process I/OpenGLRenderer﹕ Initialized EGL, version 1.4
05-20 22:34:51.453      746-983/com.android.launcher3 W/EGL_emulation﹕ eglSurfaceAttrib not implemented
05-20 22:34:51.453      746-983/com.android.launcher3 W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa08b01a0, error=EGL_SUCCESS
05-20 22:34:51.470      485-535/system_process W/EGL_emulation﹕ eglSurfaceAttrib not implemented
05-20 22:34:51.470      485-535/system_process W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x9f46ac20, error=EGL_SUCCESS
05-20 22:34:51.559      485-535/system_process W/EGL_emulation﹕ eglSurfaceAttrib not implemented
05-20 22:34:51.559      485-535/system_process W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x9f46ac20, error=EGL_SUCCESS
05-20 22:34:52.017      746-983/com.android.launcher3 W/OpenGLRenderer﹕ Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
05-20 22:34:53.753      485-550/system_process W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
05-20 22:34:53.807      485-535/system_process D/OpenGLRenderer﹕ endAllStagingAnimators on 0xa1b07200 (RippleDrawable) with handle 0xaf28d7f0
05-20 22:34:53.815     485-1004/system_process W/InputMethodManagerService﹕ Got RemoteException sending setActive(false) notification to pid 2014 uid 10060

感谢您一看。

1 个答案:

答案 0 :(得分:0)

稍晚,但SSL是具有不同加密方案的复杂协议,因此不同的站点可以触发不同的代码路径。在这种情况下,看起来您的libcrypto是为具有比您更高级功能的系统编译的 - 也许它想要SSE4并且您的CPU没有这些指令。

你在用什么CPU?您需要一个相当高级的CPU来支持x86_64。即使x86 Android ABI也需要一个64位芯片(从技术上讲,它需要仅在Atom CPU或64位桌面CPU上的指令)。尝试将您的Android图像更改为普通x86。