我無法使用Android L.中的android.app.Notification.Builder.setVisibility()。我已將Android Studio更新爲Beta版,下載了L SDK,並將我的compileSdkVersion和targetSdkVersion設置爲20.但Android Studio仍然無法解析setVisibility方法。Android L Notification.Builder.setVisibility()未通過Android Studio解決
(編輯:我更新了compileSdkVersion並根據下面的評論targetSdkVersion,並更新從20 +到21 +我的支持庫)
沒有setVisibility()行我的代碼編譯和運行。如果我嘗試使用NotificationCompat.Builder,我會得到相同的錯誤。
有誰知道如何解決這個問題?
android {
compileSdkVersion 'android-L' // was 20
buildToolsVersion '20'
defaultConfig {
minSdkVersion 13
targetSdkVersion 'L' // was 20
...
...
compile 'com.android.support:support-v13:21.+'
compile 'com.android.support:appcompat-v7:21.+'
import android.app.Notification;
...
noti = new Notification.Builder(InfoPanel.getContext())
.setContentTitle(notiTitle)
.setContentText("text")
.setSmallIcon(notifyIcon)
.setOngoing(true)
.addAction(firstActionIcon, firstActionText, firstActionPI)
.addAction(R.drawable.optionsmenuicon, InfoPanel.getContext().getString(R.string.options), piOptions)
.addAction(R.drawable.exit, InfoPanel.getContext().getString(R.string.remove), piExitNotification)
.setContentIntent(upperPendingIntent)
.setPriority(Notification.PRIORITY_HIGH)
.setVisibility(VISIBILITY_PUBLIC)
.build() ;
我得到了IDE錯誤「無法解析法‘setVisibility(?)’」和「無法解析符號‘VISIBILITY_PUBLIC’」
編輯:第一搖籃建立自己的錯誤「無法解析法「setVisibility( ?)''在我更新了我的compileSdkVersion之後就消失了,但它仍然在IDE中顯示爲紅色。第二個錯誤仍然在兩個地方。
哪個支持庫?我正在使用這些: compile'com.android.support:support-v4:20.+' compile'com.android.support:support-v13:20.+' compile'com.android.support:appcompat -v7:20. +' – elliptic1
'support-v13'和'appcompat-v7'都包含'support-v4',因此您可以完全刪除該行。其他人需要':21. +'才能使用'L'預覽功能。 – ianhanniballake
好吧,我現在有 compileSdkVersion'android-L' targetSdkVersion'L' compile'com.android.support:support-v13:21.+' compile'com.android.support:appcompat-v7:21 +' 我仍然有Gradle編譯錯誤: 錯誤:(175,40)錯誤:無法找到符號變量VISIBILITY_PUBLIC 和相同的紅色IDE消息。 – elliptic1