android studio 数据库应用程序崩溃没有错误

用户3115400

嗨,我叫西蒙,这是我第一次使用 android studio 甚至 java。但我需要为我的工作申请这样做,所以我一直在学习。

我正在制作一个将船舶添加到我的在线数据库的应用程序。当我尝试将船添加到我的数据库时,应用程序崩溃了。我仍然收到我的toast. 但我在我的数据库中没有看到新船。我在模拟器上运行它,所以我可以连接到我的内部 IP。

那么我还需要什么才能将船舶添加到我的数据库中?

package com.example.simon.myapplication;

import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

/**
 * Created by simon on 14-10-2017.
 */

public class BackgoundTasks extends AsyncTask<String,String,String> {
Context ctx;

BackgoundTasks (Context ctx)
{
    this.ctx = ctx;
}

@Override
protected void onPreExecute() {
    super.onPreExecute();
}

@Override
protected String doInBackground(String... params) {


String RegisterURL = "http://10.0.0.2.2/webapp/register.php";

String method = params[0];
   // if (method.equals("register")) {
        String Shipname = params[1];
        String manufacturer = params[2];
        String price = params[3];

        try {
            URL url = new URL(RegisterURL);
            HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection();

            httpConnect.setRequestMethod("POST");
            httpConnect.setDoOutput(true);
            OutputStream OS = httpConnect.getOutputStream();
            BufferedWriter bufferdWriter = new BufferedWriter(new OutputStreamWriter(OS, "UTF-8"));
            // send info to server
            Toast.makeText(ctx, "Sending data ...", Toast.LENGTH_SHORT).show();
            String data = URLEncoder.encode("Shipname", "UTF-8") + "=" + URLEncoder.encode(Shipname, "UTF-8") + "&" +
                    URLEncoder.encode("manufacturer", "UTF-8") + "=" + URLEncoder.encode(manufacturer, "UTF-8") + "&" +
                    URLEncoder.encode("price", "UTF-8") + "=" + URLEncoder.encode(price, "UTF-8");
            bufferdWriter.write(data);
            bufferdWriter.flush();
            bufferdWriter.close();
            OS.close();

            InputStream IS = httpConnect.getInputStream();
            IS.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
            return "Ship added";


    //}

}

@Override
protected void onProgressUpdate(String... values) {


}

@Override
protected void onPostExecute(String result) {
    Toast.makeText(ctx,result,Toast.LENGTH_LONG).show();
}
}

日志猫:

10-16 15:10:20.476 22877-22877/? E/Zygote: v2
10-16 15:10:20.476 22877-22877/? I/libpersona: KNOX_SDCARD checking this for 10300
10-16 15:10:20.476 22877-22877/? I/libpersona: KNOX_SDCARD not a persona
10-16 15:10:20.478 22877-22877/? E/Zygote: accessInfo : 0
10-16 15:10:20.499 22877-22877/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[1],  Con:u:r:zygote:s0 SPD:SEPF_SECMOBILE_7.0_0006 RAM:SEPF_SECMOBILE_7.0_0005, [-1 -1 0 1 0 1]
10-16 15:10:20.502 22877-22877/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.example.simon.myapplication 
10-16 15:10:20.508 22877-22877/? I/art: Late-enabling -Xcheck:jni
10-16 15:10:20.536 22877-22877/? D/ActivityThread: Added TimaKeyStore provider
10-16 15:10:20.642 22877-22877/com.example.simon.myapplication W/System: ClassLoader referenced unknown path: /data/app/com.example.simon.myapplication-2/lib/arm64
10-16 15:10:20.720 22877-22877/com.example.simon.myapplication D/ContextRelationMgrBrdg: loadKlass() : caller=com.samsung.android.bridge.multiscreen.common.ContextRelationManagerBridge.<clinit>:28 android.app.LoadedApk.makeApplication:840 
10-16 15:10:20.736 22877-22877/com.example.simon.myapplication I/InstantRun: starting instant run server: is main process
10-16 15:10:20.794 22877-22877/com.example.simon.myapplication W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
10-16 15:10:20.953 22877-22877/com.example.simon.myapplication D/InputTransport: Input channel constructed: fd=75
10-16 15:10:20.953 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8e6c3d3[MainActivity]: setView = DecorView@21ddb10[MainActivity] touchMode=true
10-16 15:10:21.090 22877-22931/com.example.simon.myapplication I/OpenGLRenderer: Initialized EGL, version 1.4
10-16 15:10:21.090 22877-22931/com.example.simon.myapplication D/OpenGLRenderer: Swap behavior 1
10-16 15:10:21.096 22877-22931/com.example.simon.myapplication D/libGLESv1: STS_GLApi : DTS is not allowed for Package : com.example.simon.myapplication
10-16 15:10:21.098 22877-22931/com.example.simon.myapplication D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [1080x1920]-format:1
10-16 15:10:21.243 22877-22877/com.example.simon.myapplication W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
10-16 15:10:21.249 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8e6c3d3[MainActivity]: MSG_RESIZED_REPORT: ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1
10-16 15:10:21.249 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8e6c3d3[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
10-16 15:10:21.252 22877-22877/com.example.simon.myapplication V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@bf8eeed nm : com.example.simon.myapplication ic=com.android.internal.widget.EditableInputConnection@a182122
10-16 15:10:21.252 22877-22877/com.example.simon.myapplication I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
10-16 15:10:21.259 22877-22898/com.example.simon.myapplication D/InputTransport: Input channel constructed: fd=85
10-16 15:10:21.274 22877-22877/com.example.simon.myapplication V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@8aaa7b3 nm : com.example.simon.myapplication ic=com.android.internal.widget.EditableInputConnection@7342170
10-16 15:10:22.844 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8e6c3d3[MainActivity]: ViewPostImeInputStage processPointer 0
10-16 15:10:22.846 22877-22877/com.example.simon.myapplication W/System: ClassLoader referenced unknown path: /system/framework/QPerformance.jar
10-16 15:10:22.849 22877-22877/com.example.simon.myapplication E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]
10-16 15:10:22.849 22877-22877/com.example.simon.myapplication V/BoostFramework: BoostFramework() : mPerf = null
10-16 15:10:23.050 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8e6c3d3[MainActivity]: ViewPostImeInputStage processPointer 1
10-16 15:10:23.072 22877-23154/com.example.simon.myapplication D/NetworkSecurityConfig: No Network Security Config specified, using platform default
10-16 15:10:23.075 22877-23154/com.example.simon.myapplication I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-16 15:10:23.076 22877-23154/com.example.simon.myapplication I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-16 15:10:23.093 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8e6c3d3[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
10-16 15:10:23.442 22877-23154/com.example.simon.myapplication W/System.err: java.io.FileNotFoundException: http://myserveradres
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:254)
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at com.example.simon.myapplication.BackgoundTasks.doInBackground(BackgoundTasks.java:82)
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at com.example.simon.myapplication.BackgoundTasks.doInBackground(BackgoundTasks.java:22)
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:304)
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
10-16 15:10:23.462 22877-23154/com.example.simon.myapplication W/System.err:     at java.lang.Thread.run(Thread.java:762)
10-16 15:10:23.496 22877-22877/com.example.simon.myapplication D/InputTransport: Input channel destroyed: fd=85
10-16 15:10:23.496 22877-22877/com.example.simon.myapplication W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
10-16 15:10:23.496 22877-22877/com.example.simon.myapplication W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
10-16 15:10:23.504 22877-22877/com.example.simon.myapplication D/InputTransport: Input channel constructed: fd=88
10-16 15:10:23.504 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8477c46[Toast]: setView = android.widget.LinearLayout{2716e07 V.E...... ......I. 0,0-0,0} touchMode=true
10-16 15:10:23.511 22877-22931/com.example.simon.myapplication D/OpenGLRenderer: endAllActiveAnimators on 0x776d5f7c00 (RippleDrawable) with handle 0x778198ae60
10-16 15:10:23.581 22877-22931/com.example.simon.myapplication D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [156x132]-format:1
10-16 15:10:23.582 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8477c46[Toast]: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
10-16 15:10:23.868 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8e6c3d3[MainActivity]: dispatchDetachedFromWindow
10-16 15:10:23.886 22877-22877/com.example.simon.myapplication D/InputTransport: Input channel destroyed: fd=75
10-16 15:10:27.017 22877-22877/com.example.simon.myapplication D/ViewRootImpl@8477c46[Toast]: dispatchDetachedFromWindow
10-16 15:10:27.033 22877-22877/com.example.simon.myapplication D/InputTransport: Input channel destroyed: fd=88
乔瓦尼

检查您的 Logcat 后,我​​们可以看到以下行:

java.net.MalformedURLException:找不到协议:10.0.0.2.2/webapp/register.php

这意味着,您应该尝试http://在您引用的地址前面添加由于异常,应用程序将直接跳转到代码:

 catch (MalformedURLException e) {
        e.printStackTrace();
 }

这意味着它上面的所有代码都没有被执行,这可能是崩溃的原因。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

尝试将记录插入数据库时 Android Studio 应用程序崩溃,错误消息没有意义

来自分类Dev

不幸的是,该应用程序已停止 Android Studio 并且没有错误

来自分类Dev

带有 Retrofit2 的 Android 应用程序崩溃而没有错误消息

来自分类Dev

第一次Android应用程序崩溃,但代码中没有错误

来自分类Dev

当用户没有插入任何值时,我的应用程序崩溃 android studio

来自分类Dev

Android Studio崩溃应用程序

来自分类Dev

Android Studio 4.1数据库检查器未检测到应用程序数据库

来自分类Dev

尽管有UncaughtExceptionHandler,但间歇性Android应用程序崩溃,没有错误日志

来自分类Dev

当我的应用程序在 android oreo 8.1 上崩溃时没有错误报告

来自分类Dev

Android Studio:创建了数据库,但没有表

来自分类Dev

Android 应用程序崩溃,没有 logcat 错误

来自分类Dev

Android Studio 数据库 SQLite 错误

来自分类Dev

Visual Studio数据库项目无法发布,没有错误消息

来自分类Dev

android studio 中的 LogCat 错误,运行时应用程序崩溃

来自分类Dev

我的应用程序在Android Studio中不断崩溃

来自分类Dev

我的应用程序在Android Studio中不断崩溃

来自分类Dev

单击按钮后,Android Studio应用程序不断崩溃

来自分类Dev

单击按钮导致应用程序崩溃 Android Studio

来自分类Dev

应用程序在 android studio 中的 managedQuery 行中崩溃

来自分类Dev

由于 Android Studio 中的 ClassCastException,应用程序崩溃

来自分类Dev

在 studio 3.0 canery7 升级后,android studio 没有构建我的应用程序

来自分类Dev

在Android的SQLite数据库中插入数据时,应用程序崩溃

来自分类Dev

有没有办法将 sql server 数据库从 windows 窗体应用程序导出到 Visual Studio 中的 web 应用程序?

来自分类Dev

Xamarin - android 空白应用程序在启动时停止,没有错误或警告

来自分类Dev

Firebase实时数据库写崩溃的Android应用程序

来自分类Dev

尝试打开sqlite数据库后,我的android应用程序崩溃

来自分类Dev

Android应用程序离线使用时,Firebase实时数据库崩溃

来自分类Dev

Android Studio应用程序模块到库模块

来自分类Dev

Android Studio 启动错误的活动,但当清除应用程序的数据和缓存时,应用程序正常启动

Related 相关文章

  1. 1

    尝试将记录插入数据库时 Android Studio 应用程序崩溃,错误消息没有意义

  2. 2

    不幸的是,该应用程序已停止 Android Studio 并且没有错误

  3. 3

    带有 Retrofit2 的 Android 应用程序崩溃而没有错误消息

  4. 4

    第一次Android应用程序崩溃,但代码中没有错误

  5. 5

    当用户没有插入任何值时,我的应用程序崩溃 android studio

  6. 6

    Android Studio崩溃应用程序

  7. 7

    Android Studio 4.1数据库检查器未检测到应用程序数据库

  8. 8

    尽管有UncaughtExceptionHandler,但间歇性Android应用程序崩溃,没有错误日志

  9. 9

    当我的应用程序在 android oreo 8.1 上崩溃时没有错误报告

  10. 10

    Android Studio:创建了数据库,但没有表

  11. 11

    Android 应用程序崩溃,没有 logcat 错误

  12. 12

    Android Studio 数据库 SQLite 错误

  13. 13

    Visual Studio数据库项目无法发布,没有错误消息

  14. 14

    android studio 中的 LogCat 错误,运行时应用程序崩溃

  15. 15

    我的应用程序在Android Studio中不断崩溃

  16. 16

    我的应用程序在Android Studio中不断崩溃

  17. 17

    单击按钮后,Android Studio应用程序不断崩溃

  18. 18

    单击按钮导致应用程序崩溃 Android Studio

  19. 19

    应用程序在 android studio 中的 managedQuery 行中崩溃

  20. 20

    由于 Android Studio 中的 ClassCastException,应用程序崩溃

  21. 21

    在 studio 3.0 canery7 升级后,android studio 没有构建我的应用程序

  22. 22

    在Android的SQLite数据库中插入数据时,应用程序崩溃

  23. 23

    有没有办法将 sql server 数据库从 windows 窗体应用程序导出到 Visual Studio 中的 web 应用程序?

  24. 24

    Xamarin - android 空白应用程序在启动时停止,没有错误或警告

  25. 25

    Firebase实时数据库写崩溃的Android应用程序

  26. 26

    尝试打开sqlite数据库后,我的android应用程序崩溃

  27. 27

    Android应用程序离线使用时,Firebase实时数据库崩溃

  28. 28

    Android Studio应用程序模块到库模块

  29. 29

    Android Studio 启动错误的活动,但当清除应用程序的数据和缓存时,应用程序正常启动

热门标签

归档