Circled part is not working after uploading on play store
的活动:
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>
答案 0 :(得分:0)
我也曾经遇到过这个问题,并且在Play商店的Logcat中准备好APK进行了一些挖掘之后,我发现了问题;它也可能适用于您。
问题是NoClassDefFoundError
上的ShareActionProvider
例外!
解决方案是将此规则添加到您的ProGuard文件中,例如proguard-rules.pro
,就是这样!
-keep类android.support.v7.widget.ShareActionProvider {*; }