Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio unable to import WearableExtender NotificationManagerCompat and RemoteInput

I have a project class with the following imports:

import android.app.Activity;
import android.app.Fragment;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.RemoteInput;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.Action;
import android.support.v4.app.NotificationCompat.WearableExtender;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.app.RemoteInput;
import android.text.Html;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

In android studio the following three bring up a 'cannot resolve symbol' error:

import android.support.v4.app.NotificationCompat.WearableExtender;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.app.RemoteInput;

Wierdly, the import for NotificationCompat and NotificationCompat.Action in android.support.v4.app are successful

import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.Action;

I have tried to use the same imports on eclipse (pointing to the same SDK as android studio) and the same worked and ran without any errors.

I've also tried Minto's solution of invalidating caches/restarting android studio ...my SDK is up to date as at the time of posting. Thanks for any help in advance

like image 410
Tom Avatar asked Oct 29 '25 06:10

Tom


1 Answers

Make sure that you put the following entry into your application's build.gradle file to provide the necessary dependencies:

dependencies {
    compile 'com.android.support:support-v4:20.0+'
}

The version number is important, if you specify an older version it will be missing the new Notification code for wearables.

like image 195
Wayne Piekarski Avatar answered Nov 01 '25 14:11

Wayne Piekarski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!