2013-07-20 107 views
1

控制檯顯示以下comments.but在模擬器中所需的應用程序不顯示任何內容。模擬器不顯示任何內容

[2013-07-20 12:09:41 - searchdb] Android Launch! 
[2013-07-20 12:09:41 - searchdb] adb is running normally. 
[2013-07-20 12:09:41 - searchdb] Performing com.example.searchdb.MainActivity activity launch 
[2013-07-20 12:09:41 - searchdb] Automatic Target Mode: Preferred AVD 'Api17' is available on emulator 'emulator-5554' 
[2013-07-20 12:09:46 - searchdb] Uploading searchdb.apk onto device 'emulator-5554' 
[2013-07-20 12:09:46 - searchdb] Installing searchdb.apk... 
[2013-07-20 12:10:00 - searchdb] Success! 
[2013-07-20 12:10:01 - searchdb] Starting activity com.example.searchdb.MainActivity on device emulator-5554 

這是alll我workspace.I項目的logcat的文件。這個同樣的問題,有AVD一個問題,所以我從來沒有進入我的projects.please幫我解決提前issue.Thanks 。

logcat的文件

07-20 07:13:42.034: E/System(11988): ****************************************** 
07-20 07:13:42.114: E/System(11988): ************ Failure starting core service 
07-20 07:13:42.114: E/System(11988): java.lang.RuntimeException: Unable to get provider com.android.providers.settings.SettingsProvider: android.database.sqlite.SQLiteException: Can't downgrade database from version 95 to 94 
07-20 07:13:42.114: E/System(11988): at android.app.ActivityThread.installProvider(ActivityThread.java:4820) 
07-20 07:13:42.114: E/System(11988): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4430) 
07-20 07:13:42.114: E/System(11988): at android.app.ActivityThread.installSystemProviders(ActivityThread.java:4968) 
07-20 07:13:42.114: E/System(11988): at com.android.server.am.ActivityManagerService.installSystemProviders(ActivityManagerService.java:6898) 
07-20 07:13:42.114: E/System(11988): at com.android.server.ServerThread.run(SystemServer.java:282) 
07-20 07:13:42.114: E/System(11988): Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 95 to 94 
07-20 07:13:42.114: E/System(11988): at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:361) 
07-20 07:13:42.114: E/System(11988): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:255) 
07-20 07:13:42.114: E/System(11988): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164) 
07-20 07:13:42.114: E/System(11988): at com.android.providers.settings.SettingsProvider.establishDbTracking(SettingsProvider.java:386) 
07-20 07:13:42.114: E/System(11988): at com.android.providers.settings.SettingsProvider.onCreate(SettingsProvider.java:326) 
07-20 07:13:42.114: E/System(11988): at android.content.ContentProvider.attachInfo(ContentProvider.java:1058) 
07-20 07:13:42.114: E/System(11988): at android.app.ActivityThread.installProvider(ActivityThread.java:4817) 
07-20 07:13:42.114: E/System(11988): ... 4 more 
07-20 07:13:42.114: I/SystemServer(11988): Input Method Service 
07-20 07:13:42.454: W/InputMethodManagerService(11988): Couldn't create dir.: /data/system/inputmethod 
07-20 07:13:42.626: D/ActivityThread(11988): Loading provider settings: com.android.providers.settings.SettingsProvider 
07-20 07:13:43.634: W/SystemServer(11988): *********************************************** 
07-20 07:13:43.666: A/SystemServer(11988): BOOT FAILURE starting Input Manager Service 
07-20 07:13:43.666: A/SystemServer(11988): java.lang.RuntimeException: Unable to get provider com.android.providers.settings.SettingsProvider: android.database.sqlite.SQLiteException: Can't downgrade database from version 95 to 94 
07-20 07:13:43.666: A/SystemServer(11988): at android.app.ActivityThread.installProvider(ActivityThread.java:4820) 
07-20 07:13:43.666: A/SystemServer(11988): at android.app.ActivityThread.acquireProvider(ActivityThread.java:4471) 
07-20 07:13:43.666: A/SystemServer(11988): at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:1987) 
07-20 07:13:43.666: A/SystemServer(11988): at android.content.ContentResolver.acquireProvider(ContentResolver.java:1085) 
07-20 07:13:43.666: A/SystemServer(11988): at android.provider.Settings$NameValueCache.lazyGetProvider(Settings.java:749) 
07-20 07:13:43.666: A/SystemServer(11988): at android.provider.Settings$NameValueCache.getStringForUser(Settings.java:796) 
07-20 07:13:43.666: A/SystemServer(11988): at android.provider.Settings$Secure.getStringForUser(Settings.java:2757) 
07-20 07:13:43.666: A/SystemServer(11988): at com.android.server.InputMethodManagerService$InputMethodSettings.getSelectedInputMethod(InputMethodManagerService.java:3832) 
07-20 07:13:43.666: A/SystemServer(11988): at com.android.server.InputMethodManagerService.<init>(InputMethodManagerService.java:669) 
07-20 07:13:43.666: A/SystemServer(11988): at com.android.server.ServerThread.run(SystemServer.java:361) 
07-20 07:13:43.666: A/SystemServer(11988): Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 95 to 94 
07-20 07:13:43.666: A/SystemServer(11988): at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:361) 
07-20 07:13:43.666: A/SystemServer(11988): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:255) 
07-20 07:13:43.666: A/SystemServer(11988): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164) 
07-20 07:13:43.666: A/SystemServer(11988): at com.android.providers.settings.SettingsProvider.establishDbTracking(SettingsProvider.java:386) 
07-20 07:13:43.666: A/SystemServer(11988): at com.android.providers.settings.SettingsProvider.onCreate(SettingsProvider.java:326) 
07-20 07:13:43.666: A/SystemServer(11988): at android.content.ContentProvider.attachInfo(ContentProvider.java:1058) 
07-20 07:13:43.666: A/SystemServer(11988): at android.app.ActivityThread.installProvider(ActivityThread.java:4817) 
07-20 07:13:43.666: A/SystemServer(11988): ... 9 more 
07-20 07:13:43.866: I/SystemServer(11988): Accessibility Manager 
07-20 07:13:44.056: W/SystemServer(11988): *********************************************** 
07-20 07:13:44.056: A/SystemServer(11988): BOOT FAILURE making display ready 
07-20 07:13:44.056: A/SystemServer(11988): java.lang.NullPointerException 
07-20 07:13:44.056: A/SystemServer(11988): at com.android.server.ServerThread.run(SystemServer.java:377) 
07-20 07:13:44.095: W/dalvikvm(11988): threadid=11: thread exiting with uncaught exception (group=0xb5e2f908) 
07-20 07:13:44.095: E/AndroidRuntime(11988): *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThread 
07-20 07:13:44.095: E/AndroidRuntime(11988): java.lang.NullPointerException 
07-20 07:13:44.095: E/AndroidRuntime(11988): at com.android.server.am.ActivityManagerService.showBootMessage(ActivityManagerService.java:4353) 
07-20 07:13:44.095: E/AndroidRuntime(11988): at com.android.server.ServerThread.run(SystemServer.java:389) 

這是我的清單文件 清單文件:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.searchdb" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="17" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.example.searchdb.MainActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

這是我的主要活動類: 主要活動:

package com.example.searchdb; 

import android.app.Activity; 
import android.database.Cursor; 
import android.database.sqlite.SQLiteDatabase; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.EditText; 
import android.widget.ListAdapter; 
import android.widget.ListView; 
import android.widget.SimpleCursorAdapter; 

public class MainActivity extends Activity { 

     protected EditText searchText; 
     protected SQLiteDatabase db; 
     protected Cursor cursor; 
     protected ListAdapter adapter; 
     protected ListView employeeList; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     db = (new DatabaseHelper(this)).getWritableDatabase(); 
     searchText = (EditText) findViewById (R.id.searchText); 
     employeeList = (ListView) findViewById (R.id.list); 
    } 

    @SuppressWarnings("deprecation") 
    public void search(View view) { 
     // || is the concatenation operation in SQLite 
       cursor = db.rawQuery("SELECT _id, firstName, lastName, title FROM employee WHERE firstName || ' ' || lastName LIKE ?", 
               new String[]{"%" + searchText.getText().toString() + "%"}); 
       adapter = new SimpleCursorAdapter(
           this, 
           R.layout.list_item, 
           cursor, 
           new String[] {"firstName", "lastName", "title"}, 
           new int[] {R.id.firstName, R.id.lastName, R.id.title}); 
       employeeList.setAdapter(adapter); 
    } 

} 

這是另一種使用sqlite數據庫的類: DatabaseHelper.java:

package com.example.searchdb; 
import android.content.ContentValues; 
import android.content.Context; 
import android.database.sqlite.SQLiteDatabase; 
import android.database.sqlite.SQLiteOpenHelper; 

public class DatabaseHelper extends SQLiteOpenHelper { 

     public static final String DATABASE_NAME = "employee_directory"; 

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

     @Override 
     public void onCreate(SQLiteDatabase db) { 
       /* 
       * Create the employee table and populate it with sample data. 
       * In step 6, we will move these hardcoded statements to an XML document. 
       */ 
       String sql = "CREATE TABLE IF NOT EXISTS employee (" + 
               "_id INTEGER PRIMARY KEY AUTOINCREMENT, " + 
               "firstName TEXT, " + 
               "lastName TEXT, " + 
               "title TEXT, " + 
               "officePhone TEXT, " + 
               "cellPhone TEXT, " + 
               "email TEXT, " + 
               "managerId INTEGER)"; 
       db.execSQL(sql); 

       ContentValues values = new ContentValues(); 

       values.put("firstName", "John"); 
       values.put("lastName", "Smith"); 
       values.put("title", "CEO"); 
       values.put("officePhone", "617-219-2001"); 
       values.put("cellPhone", "617-456-7890"); 
       values.put("email", "[email protected]"); 
       db.insert("employee", "lastName", values); 

       values.put("firstName", "Robert"); 
       values.put("lastName", "Jackson"); 
       values.put("title", "VP Engineering"); 
       values.put("officePhone", "617-219-3333"); 
       values.put("cellPhone", "781-444-2222"); 
       values.put("email", "[email protected]"); 
       values.put("managerId", "1"); 
       db.insert("employee", "lastName", values); 

       values.put("firstName", "Marie"); 
       values.put("lastName", "Potter"); 
       values.put("title", "VP Sales"); 
       values.put("officePhone", "617-219-2002"); 
       values.put("cellPhone", "987-654-3210"); 
       values.put("email", "[email protected]"); 
       values.put("managerId", "1"); 
       db.insert("employee", "lastName", values); 

       values.put("firstName", "Lisa"); 
       values.put("lastName", "Jordan"); 
       values.put("title", "VP Marketing"); 
       values.put("officePhone", "617-219-2003"); 
       values.put("cellPhone", "987-654-7777"); 
       values.put("email", "[email protected]"); 
       values.put("managerId", "2"); 
       db.insert("employee", "lastName", values); 

       values.put("firstName", "Christophe"); 
       values.put("lastName", "Coenraets"); 
       values.put("title", "Evangelist"); 
       values.put("officePhone", "617-219-0000"); 
       values.put("cellPhone", "617-666-7777"); 
       values.put("email", "[email protected]"); 
       values.put("managerId", "2"); 
       db.insert("employee", "lastName", values); 

       values.put("firstName", "Paula"); 
       values.put("lastName", "Brown"); 
       values.put("title", "Director Engineering"); 
       values.put("officePhone", "617-612-0987"); 
       values.put("cellPhone", "617-123-9876"); 
       values.put("email", "[email protected]"); 
       values.put("managerId", "2"); 
       db.insert("employee", "lastName", values); 

       values.put("firstName", "Mark"); 
       values.put("lastName", "Taylor"); 
       values.put("title", "Lead Architect"); 
       values.put("officePhone", "617-444-1122"); 
       values.put("cellPhone", "617-555-3344"); 
       values.put("email", "[email protected]"); 
       values.put("managerId", "2"); 
       db.insert("employee", "lastName", values); 

     } 

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

} 
+0

請將您的清單和MainActivity – arjoan

+0

從命令提示符調試應用程序? – KOTIOS

+0

使您的模擬器停止保存其快照。這應該正確地清除錯誤。 –

回答

0

它看起來好像你的喜歡沒有相當正確的語法。我會嘗試:

+ " LIKE \"%" + searchText.getText().toString() + "%\"" 

另外,我很困惑你爲什麼'喜歡'?而不僅僅是'LIKE',因爲我假設'searchText.getText()。toString()'的值就是你正在搜索的內容。如果這是正確的情況,那麼你也可以爲null參數傳遞null。

希望這會有所幫助。

4

不知道這是否真的是解決方案,但是在編輯它的某些設置(包括API級別)後,我卻遇到了一些問題,而不是刪除並創建新的設置。

我確實得到了「無法降級數據庫從版本95到94」的錯誤,你提到的AVD甚至不會啓動。

刪除並創建新的avd後,問題似乎消失了。