Android 单击搜索图标时应用程序崩溃?

Android App crashes when clicked on the search Icon?

各位开发者大家好, 所以我开发了一个 android 应用程序来显示通过 Flickr API 公开的图像。在我将搜索功能添加到主页横幅之前,一切都很顺利。单击搜索图标时,应用程序崩溃,而不是显示带有占位符消息的下拉菜单,如下面的快照所示。 我相信错误在 FlickrRecyclerViewAdapter.java 文件

FlickrRecyclerViewAdapter.java 文件:

package com.example.flickrbrowser;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import androidx.recyclerview.widget.RecyclerView;

public class FlickrRecyclerViewAdapter extends RecyclerView.Adapter<FlickrImageViewHolder> {
private List<Photo> mPhotosList;
private Context mContext;
private final String LOG_TAG = FlickrRecyclerViewAdapter.class.getSimpleName();

public FlickrRecyclerViewAdapter(Context context, List<Photo> photosList) {
    mContext = context;
    this.mPhotosList = photosList;
}

@Override
public FlickrImageViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.browse, null);
    FlickrImageViewHolder flickrImageViewHolder = new FlickrImageViewHolder(view);
    return flickrImageViewHolder;
}

@Override
public void onBindViewHolder(FlickrImageViewHolder flickrImageViewHolder, int i) {
    Photo photoItem = mPhotosList.get(i);
    Log.d(LOG_TAG, " processing: " + photoItem.getmTitle() + " --> " + Integer.toString(i));

    Picasso.with(mContext).load(photoItem.getmImages())
            .error(R.drawable.placeholder)
            .placeholder(R.drawable.placeholder)
            .into(flickrImageViewHolder.thumbnail);
    flickrImageViewHolder.title.setText(photoItem.getmTitle());
}

@Override
public int getItemCount() {
    return (null != mPhotosList ? mPhotosList.size() : 0);
}
}

SearchActivity.java 文件:

package com.example.flickrbrowser;

import android.app.SearchManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.SearchView;

import androidx.annotation.RequiresApi;

public class SearchActivity extends BaseActivity {

private SearchView mSearchView;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_search);
    activateToolbarWithHomeEnabled();
}

public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    final MenuItem searchItem = menu.findItem(R.id.search_view);
    mSearchView = (SearchView) searchItem.getActionView();
    SearchManager searchManager = (SearchManager) 
 getSystemService(Context.SEARCH_SERVICE);
    

 mSearchView.setSearchableInfo(searchManager.getSearchableInfo
(getComponentName()) 
);
    mSearchView.setIconified(false);
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() 
{
        @Override
        public boolean onQueryTextSubmit(String s) {
            SharedPreferences sharedPref = 
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            sharedPref.edit().putString(FLICKR_QUERY, s).apply();
            mSearchView.clearFocus();
            finish();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });
    mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            finish();
            return false;
        }
    });
    return true;
}

public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
}

LogCat 错误:

2020-07-09 18:55:21.908 10809-10809/? E/e.flickrbrowse: Unknown bits set in runtime_flags: 0x8000
2020-07-09 18:55:22.647 10809-10809/com.example.flickrbrowser E/RecyclerView: No adapter attached; 
skipping layout
2020-07-09 18:55:23.440 10809-10809/com.example.flickrbrowser E/RecyclerView: No adapter attached; 
skipping layout

gitHub link for the app code

Snap shots of the Emulator(LFR: App Home page, When app crashes, Desired result)

堆栈跟踪:

07/09 21:47:52: Launching 'app' on Pixel 2 API 29.
$ adb shell am start -n 
"com.example.flickrbrowser/com.example.flickrbrowser.MainActivity" -a 
android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 11584 on device 'emulator-5554'.
Capturing and displaying logcat messages from application. This behavior can 
be disabled in the "Logcat output" section of the "Debugger" settings page.
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
W/RenderThread: type=1400 audit(0.0:45): avc: denied { write } for 
name="property_service" dev="tmpfs" ino=8414 
scontext=u:r:untrusted_app:s0:c134,c256,c512,c768 
tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0
W/libc: Unable to set property "qemu.gles" to "1": connection failed; 
errno=13 (Permission denied)
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
W/e.flickrbrowse: Accessing hidden method Landroid/view/View;- 
>computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z 
(greylist, reflection, allowed)
W/e.flickrbrowse: Accessing hidden method Landroid/view/ViewGroup;- 
>makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
I/AppCompatViewInflater: app:theme is now deprecated. Please move to using 
android:theme instead.
D/NetworkSecurityConfig: No Network Security Config specified, using platform 
default
D/HostConnection: HostConnection::get() New Host Connection established 
0xde71ef50, tid 11618
E/RecyclerView: No adapter attached; skipping layout
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 
ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 
ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem 
ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 
ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands 
ANDROID_EMU_vulkan_null_optional_strings 
ANDROID_EMU_vulkan_create_resources_with_requirements 
ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache 
ANDROID_EMU_async_unmap_buffer ANDROID_EMU_vulkan_free_memory_sync 
GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object 
GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0 
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, 
retrying without...
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation: eglCreateContext: 0xebd64ba0: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xebd64ba0: ver 3 0 (tinfo 0xebd552f0)
W/Gralloc3: mapper 3.x is not supported
D/HostConnection: createUnique: call
D/HostConnection: HostConnection::get() New Host Connection established 
0xde720620, tid 11618
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 
ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 
ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem 
ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 
ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands 
ANDROID_EMU_vulkan_null_optional_strings 
ANDROID_EMU_vulkan_create_resources_with_requirements 
ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache 
ANDROID_EMU_async_unmap_buffer ANDROID_EMU_vulkan_free_memory_sync 
GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object 
GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0 
D/eglCodecCommon: allocate: Ask for block of size 0x1000
allocate: ioctl allocate returned offset 0x3ffff4000 size 0x2000
D/EGL_emulation: eglMakeCurrent: 0xebd64ba0: ver 3 0 (tinfo 0xebd552f0)
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0
E/RecyclerView: No adapter attached; skipping layout
V/GetRawData: Data returned was: {
        "title": "Recent Uploads tagged google",
        "link": "https:\/\/www.flickr.com\/photos\/tags\/google\/",
        "description": "",
        "modified": "2020-07-09T23:31:44Z",
        "generator": "https:\/\/www.flickr.com",
        "items": [
       {
            "title": "Google AdWords for Beginners: A Do-It-Yourself Guide to 
PPC Advertising",
            "link": 
"https:\/\/www.flickr.com\/photos\/189116251@N07\/50095518006\/",
            "media": 
{"m":"https:\/\/live.staticflickr.com\/65535\/50095518006_cd109b191e_m.jpg"},
            "date_taken": "2020-07-09T16:31:44-08:00",
            "description": " <p><a 

 href=\"https:\/\/www.flickr.com\/people\/189116251@N07\/\">oliviacolman000 
<\/a> posted a photo:<\/p> <p><a 
href=\"https:\/\/www.flickr.com\/photos\/189116251@N07\/50095518006\/\" 
title=\"Google AdWords for Beginners: A Do-It-Yourself Guide to PPC 
Advertising\"><img 
src=\"https:\/\/live.staticflickr.com\/65535\/50095518006_cd109b191e_m.jpg\" 
width=\"240\" height=\"148\" alt=\"Google AdWords for Beginners: A Do-It- 
Yourself Guide to PPC Advertising\" \/><\/a><\/p> <p>Google AdWords for 
Beginners: A Do-It-Yourself Guide to PPC Advertising. Price:[=14=] Reviews: 66 
Ratings: 4.2 #Best_AdWords_Books <a href=\"https:\/\/ift.tt\/2O8E4lF\" 
rel=\"noreferrer nofollow\">ift.tt\/2O8E4lF<\/a><\/p>",
            "published": "2020-07-09T23:31:44Z",
            "author": "nobody@flickr.com (\"oliviacolman000\")",
            "author_id": "189116251@N07",
            "tags": "google adwords for beginners a doityourself guide ppc 
advertising best books business english"
       },
       {
            "title": "Google AdWords for Beginners: A Do-It-Yourself Guide to 
PPC Advertising",
            "link": 
"https:\/\/www.flickr.com\/photos\/189115917@N03\/50095522181\/",
            "media": 
{"m":"https:\/\/live.staticflickr.com\/65535\/50095522181_04476df700_m.jpg"},
            "date_taken": "2020-07-09T16:33:19-08:00",
            "description": " <p><a 

href=\"https:\/\/www.flickr.com\/people\/189115917@N03\/\">Angelababy0000
<\/a> posted a photo:<\/p> <p><a 
href=\"https:\/\/www.flickr.com\/photos\/189115917@N03\/50095522181\/\" 
title=\"Google AdWords for Beginners: A Do-It-Yourself Guide to PPC 
Advertising\"><img 
src=\"https:\/\/live.staticflickr.com\/65535\/50095522181_04476df700_m.jpg\" 
width=\"240\" height=\"148\" alt=\"Google AdWords for Beginners: A Do-It- 
Yourself Guide to PPC Advertising\" \/><\/a><\/p> <p>Google AdWords for 
Beginners: A Do-It-Yourself Guide to PPC Advertising. Price:[=14=] Reviews: 66 
Ratings: 4.2 #Best_AdWords_Books <a href=\"https:\/\/ift.tt\/2O8E4lF\" 
rel=\"noreferrer nofollow\">ift.tt\/2O8E4lF<\/a><\/p>",
            "published": "2020-07-09T23:33:19Z",
            "author": "nobody@flickr.com (\"Angelababy0000\")",
            "author_id": "189115917@N03",
            "tags": "google adwords for beginners a doityourself guide ppc 
advertising best books business english"
       },
       {
            "title": "Here Is Everything That You Need to Know About Google 
Pixel 5",
            "link": 
"https:\/\/www.flickr.com\/photos\/jaxson_uk\/50095217486\/",
            "media": 
{"m":"https:\/\/live.staticflickr.com\/65535\/50095217486_c2a01c0d61_m.jpg"},
            "date_taken": "2020-07-09T14:26:27-08:00",
            "description": " <p><a 
href=\"https:\/\/www.flickr.com\/people\/jaxson_uk\/\">jaxs3407<\/a> posted a 
photo:<\/p> <p><a 
href=\"https:\/\/www.flickr.com\/photos\/jaxson_uk\/50095217486\/\" 
title=\"Here Is Everything That You Need to Know About Google Pixel 5\"><img 
src=\"https:\/\/live.staticflickr.com\/65535\/50095217486_c2a01c0d61_m.jpg\" 
width=\"240\" height=\"149\" alt=\"Here Is Everything That You Need to Know 
About Google Pixel 5\" \/><\/a><\/p> <p>Due to the pandemic, several things 
have been postponed, and some industries have made some essential changes to 
launch a new product. There is no surety about releasing smartphones during 
this time, but some reports are assuring that the Google Pixel 5 is hitting 
the market this year.<br \/> <br \/> Source url: <a 
href=\"https:\/\/directory-fast.uk.com\/blog\/here-is-everything-that-you- 
need-to-know-about-google-pixel-5\/\" rel=\"noreferrer nofollow\">directory- 
fast.uk.com\/blog\/here-is-everything-that-you-ne...<\/a><\/p>",
        
V/GetFlickrJsonData: Photo{mTitle='Google AdWords for Beginners: A Do-It- 
Yourself Guide to PPC Advertising', mAuthor='nobody@flickr.com 
("oliviacolman000")', mAuthorId='189116251@N07', 
mLink='https://www.flickr.com/photos/189116251@N07/50095518006/', 
mTags='google adwords for beginners a doityourself guide ppc advertising best 
books business english', 
mImages='https://live.staticflickr.com/65535/50095518006_cd109b191e_m.jpg'}
Photo{mTitle='Google AdWords for Beginners: A Do-It-Yourself Guide to PPC 
Advertising', mAuthor='nobody@flickr.com ("Angelababy0000")', 
mAuthorId='189115917@N03', 
mLink='https://www.flickr.com/photos/189115917@N03/50095522181/', 
mTags='google adwords for beginners a doityourself guide ppc advertising best 
books business english', 
mImages='https://live.staticflickr.com/65535/50095522181_04476df700_m.jpg'}
Photo{mTitle='Here Is Everything That You Need to Know About Google Pixel 5', 
mAuthor='nobody@flickr.com ("jaxs3407")', mAuthorId='144845177@N07', 
mLink='https://www.flickr.com/photos/jaxson_uk/50095217486/', mTags='google 
pixel 5', 
mImages='https://live.staticflickr.com/65535/50095217486_c2a01c0d61_m.jpg'}
Photo{mTitle='LN20 OPM Gateshead Central Taxis', mAuthor='nobody@flickr.com 
("North East Malarkey")', mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094537383/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages gatesheadcentraltaxis 
centraltaxisgateshead ln20opm', 
mImages='https://live.staticflickr.com/65535/50094537383_1c0a4b0f5d_m.jpg'}
V/GetFlickrJsonData: Photo{mTitle='11503 SN69 ZRK & 11299 SN69 ZRE Stagecoach 
North East', mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094740781/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages stagecoach stagecoachuk 
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11503 sn69zrk 11299 sn69zre', 
mImages='https://live.staticflickr.com/65535/50094740781_a38a7a876b_m.jpg'}
V/GetFlickrJsonData: Photo{mTitle='Tue_14_04_2020_15_49_52', 
mAuthor='nobody@flickr.com ("harunor")', mAuthorId='188656857@N07', 
mLink='https://www.flickr.com/photos/188656857@N07/50094126693/', 
mTags='trump biden covid19 cnn amazon fiverr photoshop background removal 
google ebay usa uk etsy upwork business fashion clothing brand juwelary 
luxury poshmark editor photo image ecommerce product funny memes flickr 
youtube instagram', 
mImages='https://live.staticflickr.com/65535/50094126693_83ac3932e3_m.jpg'}
Photo{mTitle='11298 SN69 ZRD Stagecoach North East', 
mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094742781/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle  
flickr outdoor explore google googleimages stagecoach stagecoachuk 
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11298 sn69zrd', 
mImages='https://live.staticflickr.com/65535/50094742781_ea1a3f5225_m.jpg'}
Photo{mTitle='11503 SN69 ZRK Stagecoach North East (2)', 
mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094740166/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages stagecoach stagecoachuk 
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11503 sn69zrk', 
mImages='https://live.staticflickr.com/65535/50094740166_78d2a9e447_m.jpg'}
Photo{mTitle='11300 SN69 ZRF Stagecoach North East', 
mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094972502/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages stagecoach stagecoachuk 
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11300 sn69zrf', 
mImages='https://live.staticflickr.com/65535/50094972502_6838f460d1_m.jpg'}
Photo{mTitle='11293 SN69 ZPX Stagecoach North East', 
mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094162153/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages stagecoach stagecoachuk 
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11293 sn69zpx', 
mImages='https://live.staticflickr.com/65535/50094162153_f28ccb8fff_m.jpg'}
Photo{mTitle='11299 SN69 ZRE Stagecoach North East', 
mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094161113/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages stagecoach stagecoachuk 
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11299 sn69zre', 
mImages='https://live.staticflickr.com/65535/50094161113_a2e0636a88_m.jpg'}
V/GetFlickrJsonData: Photo{mTitle='11289 SN69 ZPT Stagecoach North East', 
mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094974942/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages stagecoach stagecoachuk 
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11289 sn69zpt', 
mImages='https://live.staticflickr.com/65535/50094974942_c7b8c856f5_m.jpg'}
Photo{mTitle='11292 SN69 ZPW Stagecoach North East', 
mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094974512/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages stagecoach stagecoachuk    
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11289 sn69zpt', 
mImages='https://live.staticflickr.com/65535/50094974512_e15b3a0813_m.jpg'}
Photo{mTitle='11501 SN69 ZRG Stagecoach North East', 
mAuthor='nobody@flickr.com ("North East Malarkey")', 
mAuthorId='80614130@N06', 
mLink='https://www.flickr.com/photos/adammalarkey/50094971892/', 
mTags='nebuses bus buses transport transportation publictransport public 
vehicle flickr outdoor explore google googleimages stagecoach stagecoachuk 
stagecoachgroup stagecoachinnewcastle stagecoachnortheast adl 
alexanderdennislimited alexanderdennisltd alexanderdennisenviro400 
alexanderdennisenviro400mmc alexanderdennise40d enviro400 enviro400mmc 
enviroe40d 69reg 11501 sn69zrg', 
mImages='https://live.staticflickr.com/65535/50094971892_5dbf540b08_m.jpg'}
Photo{mTitle='Calle de Preciados', mAuthor='nobody@flickr.com ("Franco & 
Lia")', mAuthorId='63608631@N03', 
mLink='https://www.flickr.com/photos/franco_p/50093944921/', mTags='street 
fotografiadistrada photographiederue strasenfotografie spain spagna madrid 
calledepreciados analog analogico pellicola film diapositiva dia slide fuji 
fujichrome analogefex google minolta x500 rokkor 50mm epson v500', 
mImages='https://live.staticflickr.com/65535/50093944921_62fa531f65_m.jpg'}
Photo{mTitle='Discover Cashback Debit', mAuthor='nobody@flickr.com ("vista 
1")', mAuthorId='189045963@N06', 
mLink='https://www.flickr.com/photos/189045963@N06/50093765236/', 
mTags='discover cashback debit atm fees google pay match offer code reddit 
review withdrawal limit', 
mImages='https://live.staticflickr.com/65535/50093765236_b70bc83bb9_m.jpg'}
Photo{mTitle='Your Own Google Adsense Empire (Ultimate Google Adsense guide 
Book 1)', mAuthor='nobody@flickr.com ("Angelababy0000")', 
mAuthorId='189115917@N03', 
mLink='https://www.flickr.com/photos/189115917@N03/50092888153/', mTags='your 
own google adsense empire ultimate guide book 1 best books business english', 
mImages='https://live.staticflickr.com/65535/50092888153_18d9d69fb2_m.jpg'}
Photo{mTitle='Your Own Google Adsense Empire (Ultimate Google Adsense guide 
Book 1)', mAuthor='nobody@flickr.com ("oliviacolman000")', 
mAuthorId='189116251@N07', 
mLink='https://www.flickr.com/photos/189116251@N07/50093466766/', mTags='your 
own google adsense empire ultimate guide book 1 best books business english', 
mImages='https://live.staticflickr.com/65535/50093466766_881d35f318_m.jpg'}
Photo{mTitle='Practical Java Machine Learning: Projects with Google Cloud 
Platform and Amazon Web Services', mAuthor='nobody@flickr.com 
("oliviacolman000")', mAuthorId='189116251@N07', 
mLink='https://www.flickr.com/photos/189116251@N07/50092566358/', 
mTags='practical java machine learning projects with google cloud platform 
amazon web services best books business english', 
mImages='https://live.staticflickr.com/65535/50092566358_4657ddd622_m.jpg'}
V/GetFlickrJsonData: Photo{mTitle='Google Forms in the Classroom', 
mAuthor='nobody@flickr.com ("oliviacolman000")', mAuthorId='189116251@N07', 
mLink='https://www.flickr.com/photos/189116251@N07/50093138561/', 
mTags='google forms classroom best books business english', 
mImages='https://live.staticflickr.com/65535/50093138561_de31e98ebc_m.jpg'}
D/FlickrRecyclerViewAdapter:  processing: Google AdWords for Beginners: A Do- 
It-Yourself Guide to PPC Advertising --> 0
W/Settings: Setting airplane_mode_on has moved from 
android.provider.Settings.System to android.provider.Settings.Global, 
returning read-only value.
D/FlickrRecyclerViewAdapter:  processing: Google AdWords for Beginners: A Do- 
It-Yourself Guide to PPC Advertising --> 1
D/FlickrRecyclerViewAdapter:  processing: Here Is Everything That You Need to   
Know About Google Pixel 5 --> 2
D/FlickrRecyclerViewAdapter:  processing: LN20 OPM Gateshead Central Taxis -- 
> 3
D/FlickrRecyclerViewAdapter:  processing: 11503 SN69 ZRK & 11299 SN69 ZRE 
Stagecoach North East --> 4
D/FlickrRecyclerViewAdapter:  processing: Tue_14_04_2020_15_49_52 --> 5
D/FlickrRecyclerViewAdapter:  processing: 11298 SN69 ZRD Stagecoach North 
East --> 6
D/FlickrRecyclerViewAdapter:  processing: 11503 SN69 ZRK Stagecoach North 
East (2) --> 7
D/FlickrRecyclerViewAdapter:  processing: 11300 SN69 ZRF Stagecoach North 
East --> 8
D/FlickrRecyclerViewAdapter:  processing: 11293 SN69 ZPX Stagecoach North 
East --> 9
I/e.flickrbrowse: Background young concurrent copying GC freed 34400(5509KB) 
AllocSpace objects, 12(360KB) LOS objects, 71% free, 2495KB/8639KB, paused 
2.134ms total 175.594ms
  

您的崩溃很可能是由于将 androidx 与旧的支持库组件混合使用造成的。将 SearchActivity 中 SearchView 的导入更改为

import androidx.appcompat.widget.SearchView;

您在 BaseActivity 中的工具栏代码也有问题。我建议使用单一方法

void activateToolbar(boolean enableHome) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar == null) {
        Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);

        if (toolbar != null) {
            setSupportActionBar(toolbar);
            actionBar = getSupportActionBar();
        }
    }

    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(enableHome);
    }
}

并根据需要传递 truefalse。如果您随后想将其拆分为 2 个方法,请确保保留相同的功能。

您的 layout_search 不包含工具栏。您需要一个来承载搜索,因此将包含的布局从 content_search 更改为工具栏

<include android:id="@+id/app_bar" layout="@layout/toolbar"/>

最后,您在 menu_search 中多了一个菜单项。您可以从该菜单中删除 action_settings。