Миграция из appcompat-v7:21.0.1 в appcompat-v7:23.1.1 теперь мне грустно
Миграция из appcompat-v7:21.0.1 в appcompat-v7: 23.1.1 OnPrepareOptionsMenu не вызывается, теперь мне грустно.
До того, как я перенес библиотеку поддержки, проблем не было вообще. Затем между 2-3 сборками / запусками (если я добавляю код или добавляю ресурсы) меню внезапно исчезает без ошибок во время выполнения или компиляции. я LOG
onPrepareOptionsMenu
звонки и, как и ожидалось, не вызывается. Я попытался вернуться к 21.0.1, но столкнулся с гораздо более пугающими проблемами. Короче говоря, я не могу вернуться.
Что я всегда делаю, так это делаю
Build->Clean
И это покажет мое меню снова.
Если это будет полезно, я опубликую то, что считаю уместным:
dependencies {
// compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/mqttv3-1.0.0.jar')
compile 'com.github.traex.rippleeffect:library:1.3'
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
// exclusion is not neccessary, but generally a good idea.
exclude group: 'com.google.android', module: 'support-v4'
}
// Google Activity Recognition
// Google Maps
// Google+'
// Google Account Login
dependencies {
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4@aar') {
transitive = true
}
}
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile files('libs/dexmaker-mockito-1.0.jar')
testCompile files('libs/dexmaker-1.0.jar')
testCompile 'junit:junit:4.12'
testCompile('org.robolectric:robolectric:3.0') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
testCompile 'com.squareup:fest-android:1.0.+'
testCompile 'org.robolectric:shadows-multidex:3.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
transitive = true;
}
compile 'com.wdullaer:materialdatetimepicker:1.4.2'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
compile 'com.andreabaccega:android-form-edittext:1.1.0@aar'
compile 'com.shehabic.droppy:Droppy:0.2.5.1@aar'
compile 'com.andreabaccega:android-form-edittext:1.1.0@aar'
compile 'com.github.gcacace:signature-pad:1.0.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.github.anrwatchdog:anrwatchdog:1.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.google.code.gson:gson:2.5'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.romainpiel.shimmer:library:1.3.0@aar'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'info.hoang8f:fbutton:1.0.5'
compile 'com.wrapp.floatlabelededittext:library:0.0.6'
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
compile 'com.github.markushi:circlebutton:1.1'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.sothree.slidinguppanel:library:3.2.0'
compile 'com.daimajia.swipelayout:library:1.1.9@aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.0@aar'
compile 'com.daimajia.androidanimations:library:1.1.2@aar'
compile 'com.roomorama:caldroid:1.1.8'
compile 'joda-time:joda-time:2.3'
compile 'com.github.bmelnychuk:atv:1.2.7'
// compile 'org.apache.commons:commons-lang3:3.0'
// compile('com.github.afollestad.material-dialogs:core:0.8.5.+@aar') {
// transitive = true
// }
// compile('com.github.afollestad.material-dialogs:commons:0.8.5.+@aar') {
// transitive = true
// }
compile 'com.github.PhilJay:MPAndroidChart:v2.1.0'
compile 'com.android.support:design:23.1.1'
compile 'com.github.machinarius:preferencefragment:0.1.1'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile project(':commons')
compile project(':core')
}
мой MainMenu
который распространяется на AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// omitted some butterknife injections
if(mToolbar != null ){
setSupportActionBar(mToolbar);
}
mDrawerToggler = new ActionBarDrawerToggle(this ,mDrawer , mToolbar , R.string.drawer_open , R.string.drawer_close ){
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
invalidateOptionsMenu();
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
invalidateOptionsMenu();
}
};
mDrawer.setDrawerListener(mDrawerToggler);
}
@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
final int currentIndex = savedInstanceState.getInt(Constants.CURRENT_POSITION);
selectItem(currentIndex);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(Constants.CURRENT_POSITION, mListView.getSelectedItemPosition());
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
boolean drawerOpen = mDrawer.isDrawerOpen(mLeftDrawer);
hideMenuItems(menu, !drawerOpen);
Log.w(TAG , "onPrepareOptionsMenu(Menu menu)" );
return super.onPrepareOptionsMenu(menu);
}
private void hideMenuItems(Menu menu, boolean visible){
for(int i = 0; i < menu.size(); i++){
menu.getItem(i).setVisible(visible);
}
}
private void selectItem(int position){
final ActionBar actionBar = getSupportActionBar();
Fragment frag = null;
// omitted some fragment selection process
if(frag != null){
getSupportFragmentManager().beginTransaction()
.replace(R.id.content_frame, frag)
//.setTransition(FragmentTransaction.TRANSIT_ENTER_MASK)
// commitAllowingStateLoss() instead of commit()
// this is a known bug on API > 11
// http://stackru.com/a/10261449/3974048
.commitAllowingStateLoss();
}
if( position != Constants.A_LOGOUT || position != Constants.S_LOGOUT ) {
mListView.setItemChecked(position, true);
}
mDrawer.closeDrawer(mLeftDrawer);
mCurrentPosition = position;
}
Я в настоящее время использую gradle 2.0.0.alhpa6. последняя андроид студия из Канарских островов.