2017-07-13 1 views
0

私のアプリケーションは、モバイルデバイスで起動したときに終了します。私のデバイスでアプリケーションを実行すると、アンドロイドデバイスが終了する

アプリケーションをSQLiteデータベースに接続しようとしていますが、正しく接続されません。 モバイルグラデーションを起動すると、起動は成功です。しかし、ログキャストエラーが表示されています:

待機中のデバイスは接続されていません。

データベースアプリケーションなしで実行すると、正常に実行されます。

これは、などMainActivityコードと以下URO、GASSのようなさまざまな活動名のコードがあり、

これはマニフェストのコードです:

<?xml version="1.0" encoding="utf-8"?> 
<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    package="com.example.asim.obaid"> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="Find a doctor" 
     android:supportsRtl="true" 
     android:theme="@style/Theme.AppCompat"> 
     <activity android:name=".MainActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".dentist" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".phy" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".der" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".gas" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".phyterapy" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".uro" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".ert" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".espec" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".gm" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".on" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".ped" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".ortped" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".redology" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".ls" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".npg" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity android:name=".doctorpannal" 
      android:parentActivityName=".MainActivity"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
    </application> 
</manifest> 

これはへDatabaseHelperクラスコードでありますSQLデータベースを接続します。ここで

package com.example.asim.obaid; 

import android.content.ContentValues; 
import android.content.Context; 
import android.database.sqlite.SQLiteDatabase; 
import android.database.sqlite.SQLiteOpenHelper; 

/** 
* Created by asim on 7/12/2017. 
*/ 
public class DatabaseHelper extends SQLiteOpenHelper { 

    public static final String DataBase_Name="Doctor.db"; 
    public static final String Table_Name="doctor_table"; 
    public static final String Col_1="ID"; 
    public static final String Col_2="DR_NAME"; 
    public static final String Col_3="EMAIL"; 
    public static final String Col_4="ADDRESS"; 

    public DatabaseHelper(Context context) { 
     super(context, DataBase_Name, null, 1); 
    } 

    @Override 
    public void onCreate(SQLiteDatabase db) { 
     db.execSQL("create table"+Table_Name+"(ID INTEGER PRIMARY KEY AUTOINCREMENT,DR_NAME TEXT,EMAIL TEXT,ADDRESS_TEXT)"); 
    } 

    @Override 
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 
     db.execSQL("DROP TABLE IF EXISTS" +Table_Name); 
     onCreate(db); 
    } 

    public boolean insertData(String dr_name, String email, String address) { 
     SQLiteDatabase db= this.getWritableDatabase(); 
     ContentValues contentValues= new ContentValues(); 
     contentValues .put(Col_2,dr_name); 
     contentValues .put(Col_3,email); 
     contentValues .put(Col_4,address); 
     long result= db.insert(Table_Name,null,contentValues); 
     if (result == -1) 
      return false; 
     else 
      return true; 
    } 
} 

はGradleのコンソールメッセージである:プロセスはオンライン
に表示されるプロセスを待ってタイムアウトしましてくるのを待っ

Executing tasks: [:app:assembleDebug] 

Configuration on demand is an incubating feature. 
Incremental java compilation is an incubating feature. 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:app:preReleaseBuild UP-TO-DATE 
:app:prepareComAndroidSupportAnimatedVectorDrawable2330Library UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72330Library UP-TO-DATE 
:app:prepareComAndroidSupportDesign2330Library UP-TO-DATE 
:app:prepareComAndroidSupportRecyclerviewV72330Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42330Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportVectorDrawable2330Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library UP-TO-DATE 
:app:prepareComGoogleAndroidGmsPlayServicesBasement810Library UP-TO-DATE 
:app:prepareDebugDependencies 
:app:compileDebugAidl UP-TO-DATE 
:app:compileDebugRenderscript UP-TO-DATE 
:app:generateDebugBuildConfig UP-TO-DATE 
:app:mergeDebugShaders UP-TO-DATE 
:app:compileDebugShaders UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:mergeDebugAssets UP-TO-DATE 
:app:generateDebugResValues UP-TO-DATE 
:app:generateDebugResources UP-TO-DATE 
:app:mergeDebugResources UP-TO-DATE 
:app:processDebugManifest 
:app:processDebugResources 
:app:generateDebugSources 
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE 
:app:compileDebugJavaWithJavac UP-TO-DATE 
:app:compileDebugNdk UP-TO-DATE 
:app:compileDebugSources UP-TO-DATE 
:app:buildInfoDebugLoader 
:app:transformClassesWithExtractJarsForDebug UP-TO-DATE 
:app:transformClassesWithInstantRunVerifierForDebug UP-TO-DATE 
:app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE 
:app:mergeDebugJniLibFolders UP-TO-DATE 
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE 
:app:processDebugJavaRes UP-TO-DATE 
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE 
:app:transformResourcesAndNative_libsWithJavaResourcesVerifierForDebug UP-TO-DATE 
:app:transformClassesWithInstantRunForDebug UP-TO-DATE 
:app:transformClasses_enhancedWithInstant+reloadDexForDebug UP-TO-DATE 
:app:incrementalDebugTasks 
:app:prePackageMarkerForDebug 
:app:fastDeployDebugExtractor UP-TO-DATE 
:app:generateDebugInstantRunAppInfo 
:app:transformClassesWithDexForDebug 
To run dex in process, the Gradle daemon needs a larger heap. 
It currently has approximately 910 MB. 
For faster builds, increase the maximum heap size for the Gradle daemon to more than 4096 MB. 
To do this set org.gradle.jvmargs=-Xmx4096M in the project gradle.properties. 
For more information see https://docs.gradle.org/current/userguide/build_environment.html 
:app:validateDebugSigning 
:app:packageDebug 
:app:zipalignDebug 
:app:fullDebugBuildInfoGenerator 
:app:assembleDebug 

BUILD SUCCESSFUL 

Total time: 15.218 secs 

そしてここでは、logcatメッセージですlge-lg_d800-09ce27a110668ee5

+2

あなたのlogcatを投稿してください –

+0

plz私はこれを数日から修正しようとしています –

+0

あなたがlogcatを投稿しないようにするにはどうすればいいですか? –

答えて

0
  1. 列名がADDRESS_TEXTの表を作成しましたが、列ADRESSSにアクセスしようとしています。コードのこの部分から "_"を削除してみてください。

    db.execSQL( "create table" + Table_Name + "(ID INTEGERプライマリキー自動化、DR_NAME TEXT、EMAIL TEXT、ADDRESS_TEXT)");あなたは、またtable

の後にスペースを追加する必要がありますが、すでに列名の文字列変数を作成した場合、あなたにもテーブルの作成でそれらを使用する必要がありますので

  • 文字列"create table"+Table_Nameは「"create tabledoctor_tableとして解釈される。

  • 関連する問題