1

I'm trying to add the share button on the action bar but the build fails because:

Error:(21) No resource identifier found for attribute 'actionProviderClass' in package '...'

My menu/detail.xml has:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item1.../>
<item2.../>

<item android:id="@+id/action_share"
    android:icon="@android:drawable/ic_menu_share"
    android:title="@string/action_share"
    android:showAsAction="always"
    app:actionProviderClass="android.support.v7.widget.ShareActionProvider"/>

</menu>

(This is probably irrelevant but the instructions say to make android:showAsAction be app:showAsAction but that gets underlined and it says "Should use android:showAsAction when not using the appcompat library")

My thanks!

Philippe Le Point
  • 255
  • 1
  • 3
  • 13
  • And what happens when you remove support. v7 from the actionProviderClass ? – Simas Jul 26 '14 at 05:20
  • try to change xmlns:app="http://schemas.android.com/apk/res-auto" to xmlns:app="http://schemas.android.com/apk/res/com.exapmle.mypackage" where com.exapmle.mypackage will be your package name. – Giru Bhai Jul 26 '14 at 05:20
  • @PhilippeLePoint Happy to help.Please revert back to original question so it will be useful for others having same issue And always post new problem with new question. – Giru Bhai Jul 26 '14 at 05:44
  • @PhilippeLePoint Anyway this may help for your second problem http://stackoverflow.com/questions/19118051/unable-to-cast-action-provider-to-share-action-provider – Giru Bhai Jul 26 '14 at 05:48

2 Answers2

3

Change

xmlns:app="schemas.android.com/apk/res-auto";

to

 xmlns:app="schemas.android.com/apk/res/com.exapmle.mypackage";

where com.exapmle.mypackage will be your package name.

Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
0

Edit: Also -

android:showAsAction="always"

should instead be:

app:showAsAction="always"

In DetailActivity.java, did you remember to add:

import android.support.v7.widget.ShareActionProvider;

Mine is below, it's exactly the same, although I did experience the same thing you're describing here. I had accidentally put:

xmlns:android="http://schemas.android.com/apk/res-auto

instead of:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" >
    <item android:id="@+id/action_share"
        android:title="@string/action_share"
        app:showAsAction="always"
        app:actionProviderClass="android.support.v7.widget.ShareActionProvider" />
</menu>
Jacob
  • 588
  • 1
  • 4
  • 14