gpt4 book ai didi

无法导入 Android Studio 通知 channel

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:46:03 25 4
gpt4 key购买 nike

我正在检查 Android 的 firebase 消息传递功能,并检查了一个关于它的示例项目。当我编写代码时,我的应用程序可以导入 Notification Manager,但不能导入 Notification Channel。我的 gradle 文件可以在下面找到。

import android.app.NotificationChannel;
import android.app.NotificationManager;

我的gradle依赖

  compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-compat:25.0.0-beta2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.google.android.gms:play-services:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2

google 项目的依赖。

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
compile 'com.android.support:animated-vector-drawable:26.0.0-beta2'
compile 'com.android.support:support-compat:26.0.0-beta2'

compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'

// Testing dependencies
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:25.3.1'
}

谷歌代码链接:https://github.com/firebase/quickstart-android/blob/master/messaging/app/build.gradle'

编辑:所有gradle文件。

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId 'com.myapp.extranet'
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}


}




dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.iarcuschin:simpleratingbar:0.1.5'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-compat:25.0.0-beta2'
compile 'com.android.support:design:25.3.1'
compile 'com.intuit.sdp:sdp-android:1.0.3'
compile 'com.google.code.gson:gson:2.7'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
compile 'com.github.clans:fab:1.6.4'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.github.baoyachi:StepView:1.9'
compile 'com.google.android.gms:play-services:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

最佳答案

要导入通知 channel ,您需要更新您的compileSdkVersion

compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.notificationcomponent"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}

注意:在 API 版本 < 26 上运行时,它会在此行崩溃,因此您必须处理它。

final NotificationChannel notificationChannel = new
NotificationChannel(channelId, channelName, importance);

有以下异常(exception)

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/app/NotificationChannel;
...
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.app.NotificationChannel" on path: DexPathList

关于无法导入 Android Studio 通知 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45232457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com