在调试模式下,应用程序运行平稳,但是在尝试以发布模式构建时,应用程序构建失败。
这给我一个错误的说法
com.karriapps.smartsiddur.LocationsActivity$3: can't find enclosing method 'boolean onCreateOptionsMenu(android.view.Menu)' in program class com.karriapps.smartsiddur.LocationsActivity
但是我现在没有在此活动中使用菜单。我曾经有过beofre,但是我将其删除了。
package com.karriapps.smartsiddur;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import com.karriapps.smartsiddur.fragments.LocationSearchFragment;
import com.karriapps.smartsiddur.model.ElavationService;
import com.karriapps.smartsiddur.model.Location;
import com.karriapps.smartsiddur.model.listeners.LocationListener;
import com.karriapps.smartsiddur.model.response.LocationResponse;
import com.karriapps.smartsiddur.util.LocationHandler;
import com.karriapps.smartsiddur.util.SSApp;
import com.karriapps.smartsiddur.views.LocationViewHolder;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import io.realm.RealmResults;
public class LocationsActivity extends BaseActivity implements LocationSearchFragment.LocationSetListener {
public static final String BUNDLE_LOCATION_ID = "location_id";
public static final String BUNDLE_FROM_SEARCH = "from_search";
public static final int RESPONSE_OK = 0;
public static final int RESPONSE_SET = 1;
private Toolbar mToolbar;
private RecyclerView mLocationsRecyclerView;
private View mCurrentLocation;
private SearchView mSearchView;
private List<LocationResponse.Feature> mLocationsSuggestion;
private ArrayAdapter<String> mAdapter;
private LocationsAdapter mLocationsAdapter;
private RealmResults<Location> mLocations;
private View mProgressBar;
private boolean fromSearch;
private LocationSearchFragment mLocationSearchFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fromSearch = getIntent().getBooleanExtra(BUNDLE_FROM_SEARCH, false);
setContentView(R.layout.activity_locations);
mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
mCurrentLocation = findViewById(R.id.location_activity_current_location);
mProgressBar = findViewById(R.id.progressBar);
mLocationsRecyclerView = (RecyclerView) findViewById(R.id.locationsList);
mLocationsRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("");
loadLocations();
mLocationsAdapter = new LocationsAdapter();
mLocationsRecyclerView.setAdapter(mLocationsAdapter);
mLocationsRecyclerView.setItemAnimator(new DefaultItemAnimator());
mLocationSearchFragment = new LocationSearchFragment();
LocationHandler.getInstance().setLocationListener(new LocationListener() {
@Override
public void onLocationFailure() {
mProgressBar.setVisibility(View.GONE);
}
@Override
public void onLocationAchieved(Location location) {
SSApp.getInstance().addLocation(location);
loadLocations();
mLocationsAdapter.notifyDataSetChanged();
mProgressBar.setVisibility(View.GONE);
if (fromSearch) {
returnToCallingActivity();
}
}
});
findViewById(R.id.searchBtn).setOnClickListener(v -> {
mLocationSearchFragment.show(getSupportFragmentManager(), "places");
});
}
private void updateCurrentLocation() {
LocationViewHolder locationViewHolder = new LocationViewHolder(mCurrentLocation);
if (SSApp.getInstance().getLocation() != null) {
locationViewHolder.bind(SSApp.getInstance().getLocation(), new LocationViewHolder.OnLocationItemOperation() {
@Override
public void onDeleteLocationClick(int position) {
}
@Override
public void onDetailsChanged(int position, boolean inIsrael) {
updateIsInIsrael(SSApp.getInstance().getLocation(), inIsrael);
}
@Override
public void onSetLocationClick(int position) {
}
});
} else {
locationViewHolder.bind(SSApp.getInstance().getLocation(), null);
}
}
private void loadLocations() {
mLocations = SSApp.getInstance()
.getRealm()
.where(Location.class)
.equalTo("isActive", false)
.findAll();
updateCurrentLocation();
}
private void returnToCallingActivity() {
Intent intent = new Intent();
setResult(RESPONSE_SET, intent);
finish();
}
private void updateIsInIsrael(Location location, boolean inIsrael) {
if (location.isInIsrael() != inIsrael) {
SSApp.getInstance().getRealm().beginTransaction();
location.setIsInIsrael(inIsrael);
SSApp.getInstance().getRealm().commitTransaction();
mLocationsAdapter.notifyDataSetChanged();
updateCurrentLocation();
}
}
@Override
public void onLocationSet(@NotNull ElavationService.LatLng latLng) {
runOnUiThread(() -> {
if (mLocationSearchFragment != null && mLocationSearchFragment.isVisible()) {
mLocationSearchFragment.dismissAllowingStateLoss();
}
mProgressBar.setVisibility(View.VISIBLE);
});
LocationHandler.getInstance()
.setLocation(latLng.getLatitude(),
latLng.getLongitude(),
false
);
}
class LocationsAdapter extends RecyclerView.Adapter<LocationViewHolder> implements LocationViewHolder.OnLocationItemOperation {
@Override
public LocationViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(LocationsActivity.this)
.inflate(R.layout.location_row, parent, false);
return new LocationViewHolder(view);
}
@Override
public void onBindViewHolder(LocationViewHolder holder, int position) {
holder.bind(mLocations.get(position), this);
}
@Override
public int getItemCount() {
return mLocations == null ? 0 : mLocations.size();
}
@Override
public void onDeleteLocationClick(int position) {
SSApp.getInstance().removeLocation(mLocations.get(position));
loadLocations();
notifyItemRemoved(position);
}
@Override
public void onSetLocationClick(int position) {
SSApp.getInstance().setLocation(mLocations.get(position));
returnToCallingActivity();
}
@Override
public void onDetailsChanged(int position, boolean inIsrael) {
updateIsInIsrael(mLocations.get(position), inIsrael);
}
}
}
出于某种原因,它似乎仍在寻找,但我不知道为什么
答案 0 :(得分:0)
您的发行版构建中间件中可能有一些旧文件导致了该问题,它们引用的代码不再存在。
彻底的重建应该摆脱它们。