首页 > 解决方案 > 删除 webAPI 不适用于发布模式 apk

问题描述

我已经使用 Web API 开发了一个 android 应用程序。我正在HttpDelete通过 .NET Web API 删除一行。应用程序在调试模式下完美运行。但是当我发布签名发布模式 apk 时,该应用程序在删除 Web API 时崩溃。请为我提供解决方案。
附上安卓删除代码

private class DeleteData extends AsyncTask<Integer, Void, Void> {

    @Override
    protected Void doInBackground(Integer... params) {

        int id = params[0];

        Log.d("got id",""+id);
        try {

            URL url = new URL("My URL");

            Log.d("URL",""+url);
            HttpURLConnection httpURLConnection=(HttpURLConnection)url.openConnection();
            httpURLConnection.setRequestMethod("DELETE");
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setDoInput(true);
            httpURLConnection.connect();

            InputStream is = httpURLConnection.getInputStream();
            int byteCharacter;
            String result="";
            while ((byteCharacter = is.read()) != -1)
            {
                result += (char)byteCharacter;
            }
            Log.d("json api",result);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }

}

在此处输入图像描述

标签: androidasp.net-web-apihttp-delete

解决方案


推荐阅读