Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logcat警告android.app.Notification$Builder_Android_Google Drive Api_Google Play Services - Fatal编程技术网

Logcat警告android.app.Notification$Builder

Logcat警告android.app.Notification$Builder,android,google-drive-api,google-play-services,Android,Google Drive Api,Google Play Services,开始在我的应用程序中使用Google Play服务,突然我开始在我的应用程序中收到这些警告 12-18 20:31:50.320: I/dalvikvm(8579): Could not find method android.app.Notification$Builder.setPriority, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.a 12-18 20:31:50.320:

开始在我的应用程序中使用Google Play服务,突然我开始在我的应用程序中收到这些警告

12-18 20:31:50.320: I/dalvikvm(8579): Could not find method android.app.Notification$Builder.setPriority, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.a
12-18 20:31:50.320: W/dalvikvm(8579): VFY: unable to resolve virtual method 230: Landroid/app/Notification$Builder;.setPriority (I)Landroid/app/Notification$Builder;
12-18 20:31:50.320: D/dalvikvm(8579): VFY: replacing opcode 0x6e at 0x0035
12-18 20:31:50.320: D/dalvikvm(8579): DexOpt: unable to opt direct call 0x00cf at 0x3f in Lcom/google/android/gms/common/GooglePlayServicesUtil;.a

我的应用程序的minTarget是16。你知道那里发生了什么吗?

我厌倦了使用
setPriority()
跟踪通知代码,它没有问题:

import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContentTitle("My notification")
                        .setContentText("Hello World!")
                        .setPriority(5);

// Creates an explicit intent for an Activity in your app
        Intent resultIntent = new Intent(this, MainActivity.class);

// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addParentStack(MainActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent =
                stackBuilder.getPendingIntent(
                        0,
                        PendingIntent.FLAG_UPDATE_CURRENT
                );
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
        mNotificationManager.notify(2, mBuilder.build());

    }
 }
它将弹出一个简单的通知

和我的
build.gradle
应用程序文件夹:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.myapplication2"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

您用于编译的目标版本是什么?您正在导入哪些库?