2015-05-25 34 views
1

走進呼叫:調試並進入getSystemService()在Studio中顯示錯誤的行?

SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); 

顯示在調試器錯線,這是爲什麼?

enter image description here

我已經下載源,並設置如下:

android { 
    compileSdkVersion 21 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     applicationId "com.example.android.searchabledict" 
     minSdkVersion 14 
     targetSdkVersion 21 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
} 

我連接的Android API是:Android的API 21平臺

它適用於這一呼籲:

UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); 
+0

當您處於「調試」模式時,您可能會'添加/刪除'任何'代碼行'。只需停止「調試」並再試一次 – hrskrs

+0

一個調用可以工作,但另一個不可用(請參閱上面的文章)。但是當我從啓動AVD API 22變更爲AVD API 21時,它的工作原理!? – powder366

回答

2

這是因爲您運行的SDK不是th您使用的目標SDK。因此,正在運行的進程的調試元數據不會與源代碼同步。

嘗試將目標SDK更改爲您正在運行的設備上的SDK,並確保您擁有正確版本的源代碼。

+0

我的targetSdkVersion是21,我的圖書館是21 ?.我發現如果我用API 21啓動AVD,它就可以工作。這是你的意思嗎(看我上面的評論)? – powder366

+0

準確地說,目標SDK和被調試設備應該使用相同的SDK版本。確定。 – shem

+1

好的。 UriMatcher調用雖然工作。看起來有些工作,但不是全部。有趣的是要更詳細地瞭解爲什麼它是這樣的。 – powder366

相關問題