【问题标题】:Can't find referenced method 'void setLatestEventInfo(找不到引用的方法 'void setLatestEventInfo(
【发布时间】:2016-02-11 00:18:58
【问题描述】:

我正在更新我的应用,使其与 Android 6.0 中的新权限模型保持一致。更新了我的 build.gradle 文件,但是我现在收到了正在停止构建的编译消息:

Warning:com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification

我的 build.grade 在这里:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.myspace.ian.myapp"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 65
        versionName "3.21"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'jcifs:jcifs:1.3.17'
    compile files('libs/gson-2.3.1.jar')
    compile files('libs/logback-android-1.1.1-3.jar')
    compile files('libs/slf4j-api-1.7.6.jar')
    compile 'com.google.android.gms:play-services:6.5.87'

    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
}

...这是我的 proguard-rules.pro 文件:

-keepclassmembers class com.dom925.xxxx {
   public *;
}
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
-dontwarn javax.mail.**
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.octo.android.robospice.SpiceService
-dontwarn android.support.v4.**

有人可以帮忙吗? (我是一个相对的菜鸟!)

【问题讨论】:

    标签: android


    【解决方案1】:
    compile 'com.google.android.gms:play-services:6.5.87'
    

    这是非常过时的。要么:

    • 更新到最新的 Play 服务(或者,更好的是,您正在使用的 Play 服务的各个工件),或者

    • 将您的 compileSdkVersion 降级为 6.5.87 将支持的内容

    就目前而言,您使用的是旧版 Play Services 代码,该代码需要一些旧版本的 Android SDK,而不是 compileSdkVersion 23,其中 setLatestEventInfo() 不再存在。

    【讨论】:

    • 谢谢 - 我已经更新到 com.google.android.gms:play-services:8.4.0 并且似乎已经解决了问题
    【解决方案2】:

    不再支持“setLatestEventInfo”方法。尝试使用 NotificationBuilder 创建通知。

    【讨论】:

    • 我没有在任何地方使用 setLatestEventInfo(也从未使用过)——我已经在使用 NotificationBuilder
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-04
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    相关资源
    最近更新 更多