-1

App share button on action bar is not working after i upload the app update on the play store as it works on the testing devices and also works on emulator.. ? thank you in advance .

Circled part is not working after uploading on play store

Activity:

public class RecommendetableActivity extends AppCompatActivity {

    Button button;
    Intent ShareIntent;
    ShareActionProvider mShareActionProvider;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setContentView(R.layout.recommended_table);
        ShareIntent = new Intent();
        ShareIntent.setAction(Intent.ACTION_SEND);
        ShareIntent.setType("text/plain");
        ShareIntent.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/............app name ");
        button = (Button)findViewById(R.id.close_button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                overridePendingTransition(R.anim.backfadein, R.anim.backfadeout);
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.popup_menu, menu);
        MenuItem item = menu.findItem(R.id.menu_item_share);
        // Get its ShareActionProvider
        mShareActionProvider =  (ShareActionProvider) MenuItemCompat.getActionProvider(item);
        // Connect the dots: give the ShareActionProvider its Share Intent
        if (mShareActionProvider != null) {
            mShareActionProvider.setShareIntent(ShareIntent);
        }
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        if (item.getItemId() == android.R.id.home) {
            finish();
            overridePendingTransition(R.anim.backfadein, R.anim.backfadeout);
            return true;
        }
        return false;
    }

    @Override
    public void onBackPressed() {
        finish();
        overridePendingTransition(R.anim.backfadein, R.anim.backfadeout);
        super.onBackPressed();
    }
}

popup_menu.xml:

<?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/menu_item_share"
    android:title=""
    app:showAsAction="always"
    app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
    />
</menu>
Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55
Viney Dhiman
  • 183
  • 1
  • 3
  • 15

1 Answers1

0

I had this issue as well once and after some digging inside the Logcat of Play store ready APK, I found the problem; it might apply to you as well.

The Issue was NoClassDefFoundError exception on ShareActionProvider ! Solution is to add this rule to your ProGuard file such as proguard-rules.pro and that's it!

-keep class android.support.v7.widget.ShareActionProvider { *; }

kevoroid
  • 5,052
  • 5
  • 34
  • 43