gpt4 book ai didi

android - 无法构建发布应用程序,gradle 说找不到封闭方法 'boolean onCreateOptionsMenu(android.view.Menu)

转载 作者:太空宇宙 更新时间:2023-11-03 10:57:00 24 4
gpt4 key购买 nike

在 Debug模式下,应用程序运行平稳,但在 Release模式下尝试构建时,应用程序构建失败。

它给我一个错误提示com.karriapps.smartsiddur.LocationsActivity$3:在程序类 com.karriapps.smartsiddur.LocationsActivity 中找不到封闭方法“boolean onCreateOptionsMenu(android.view.Menu)”
但是我现在在这个 Activity 中没有使用菜单。我以前有 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);
}
}
}

出于某种原因,它似乎仍在寻找它,但我不知道为什么

最佳答案

您的发布构建中间件中可能有一些旧文件导致了问题,引用了不再存在的代码。

干净的重建应该摆脱它们。

关于android - 无法构建发布应用程序,gradle 说找不到封闭方法 'boolean onCreateOptionsMenu(android.view.Menu),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57259994/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com