kandi background
Explore Kits

MaterialSearchView | Cute library to implement SearchView | Android library

 by   MiguelCatalan Java Version: vv1.3.1 License: Apache-2.0

 by   MiguelCatalan Java Version: vv1.3.1 License: Apache-2.0

Download this library from

kandi X-RAY | MaterialSearchView Summary

MaterialSearchView is a Java library typically used in Mobile, Android applications. MaterialSearchView has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub.
Cute library to implement SearchView in a Material Design Approach. Works from Android API 14 (ICS) and above. #Native version Maybe it would be useful to take a look into the new official approach http://www.materialdoc.com/search-filter/.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • MaterialSearchView has a medium active ecosystem.
  • It has 3767 star(s) with 632 fork(s). There are 83 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 144 open issues and 63 have been closed. On average issues are closed in 192 days. There are 25 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of MaterialSearchView is vv1.3.1
MaterialSearchView Support
Best in #Android
Average in #Android
MaterialSearchView Support
Best in #Android
Average in #Android

quality kandi Quality

  • MaterialSearchView has 0 bugs and 43 code smells.
MaterialSearchView Quality
Best in #Android
Average in #Android
MaterialSearchView Quality
Best in #Android
Average in #Android

securitySecurity

  • MaterialSearchView has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • MaterialSearchView code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
MaterialSearchView Security
Best in #Android
Average in #Android
MaterialSearchView Security
Best in #Android
Average in #Android

license License

  • MaterialSearchView is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
MaterialSearchView License
Best in #Android
Average in #Android
MaterialSearchView License
Best in #Android
Average in #Android

buildReuse

  • MaterialSearchView releases are available to install and integrate.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • MaterialSearchView saves you 1060 person hours of effort in developing the same functionality from scratch.
  • It has 2402 lines of code, 104 functions and 39 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
MaterialSearchView Reuse
Best in #Android
Average in #Android
MaterialSearchView Reuse
Best in #Android
Average in #Android
Top functions reviewed by kandi - BETA

kandi has reviewed MaterialSearchView and discovered the below as its top functions. This is intended to give you an instant insight into MaterialSearchView implemented functionality, and help decide if they suit your requirements.

  • Initializes a MaterialSearchView
  • Initializes the search view .
  • Returns a filter based on the specified constraint .
  • Refresh a view .
  • Simplified method for fadeInView
  • start click .
  • Get the Suggestions view
  • Override when the search view is complete .
  • Creates the menu item menu
  • On back pressed .

MaterialSearchView Key Features

Cute library to implement SearchView in a Material Design Approach

Usage

copy iconCopydownload iconDownload
	dependencies {
    	compile 'com.miguelcatalan:materialsearchview:1.4.0'
	}

Use VoiceSearch

copy iconCopydownload iconDownload
	searchView.setVoiceSearch(true); //or false

Add suggestions

copy iconCopydownload iconDownload
    <string-array name="query_suggestions">
        <item>Android</item>
        <item>iOS</item>
        <item>SCALA</item>
        <item>Ruby</item>
        <item>JavaScript</item>
    </string-array>

Style it!

copy iconCopydownload iconDownload
    <style name="MaterialSearchViewStyle">
        <!-- Background for the search bar -->
        <item name="searchBackground">@color/theme_primary</item>

        <!-- Change voice icon -->
        <item name="searchVoiceIcon">@drawable/ic_action_voice_search_inverted</item>

        <!-- Change clear text icon -->
        <item name="searchCloseIcon">@drawable/ic_action_navigation_close_inverted</item>

        <!-- Change up icon -->
        <item name="searchBackIcon">@drawable/ic_action_navigation_arrow_back_inverted</item>
        
        <!-- Change icon for the suggestions -->
        <item name="searchSuggestionIcon">@drawable/ic_suggestion</item>

        <!-- Change background for the suggestions list view -->
        <item name="searchSuggestionBackground">@android:color/white</item>

        <!-- Change text color for edit text. This will also be the color of the cursor -->
        <item name="android:textColor">@color/theme_primary_text_inverted</item>

        <!-- Change hint text color for edit text -->
        <item name="android:textColorHint">@color/theme_secondary_text_inverted</item>

        <!-- Hint for edit text -->
        <item name="android:hint">@string/search_hint</item>
    </style>

Using AppBarLayout?

copy iconCopydownload iconDownload
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!— Irrelevant stuff —>
    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/appbarlayout"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <!— Must be last for right layering display —>
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbarlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/search_layover_bg">

        <FrameLayout
            android:id="@+id/toolbar_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/theme_primary" />

            <com.miguelcatalan.materialsearchview.MaterialSearchView
                android:id="@+id/search_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone" />
        </FrameLayout>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/theme_primary"
            app:tabGravity="fill"
            app:tabMode="fixed" />

    </android.support.design.widget.AppBarLayout>

</RelativeLayout>

Bonus

copy iconCopydownload iconDownload
    @Override
    public void onBackPressed() {
        if (searchView.isSearchOpen()) {
            searchView.closeSearch();
        } else {
            super.onBackPressed();
        }
    }

License

copy iconCopydownload iconDownload
Copyright 2015 Miguel Catalan Bañuls

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

How can I resolve Android Studio 4.2 build errors after removing jcenter()?

copy iconCopydownload iconDownload
repositories {
    google()
    mavenCentral()
    maven { url 'https://maven.preemptive.com/' }
    maven { url 'https://jitpack.io' }
    //jcenter()
}
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
-----------------------
repositories {
    google()
    mavenCentral()
    maven { url 'https://maven.preemptive.com/' }
    maven { url 'https://jitpack.io' }
    //jcenter()
}
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')

A ListView overlaps a SearchView in a CoordinatorLayout

copy iconCopydownload iconDownload
<?xml version="1.0" encoding="UTF-8" ?>
<com.google.android.material.appbar.AppBarLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar_container"
    android:theme="@style/AppTheme.AppBarOverlay"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        app:theme="@style/ToolBarStyle"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary" />

    <com.miguelcatalan.materialsearchview.MaterialSearchView
        android:id="@+id/search_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</com.google.android.material.appbar.AppBarLayout>
-----------------------
<?xml version="1.0" encoding="UTF-8" ?>
<com.google.android.material.appbar.AppBarLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            app:theme="@style/ToolBarStyle"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary" />

        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </FrameLayout>

</com.google.android.material.appbar.AppBarLayout>

A ListView is not displaying any data on OnCreate/OnStart after AndroidX migration

copy iconCopydownload iconDownload
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include layout="@layout/search_container" />
        <ListView
            android:id="@+id/lstOtherRuins"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:nestedScrollingEnabled="true"
            android:layout_margin="8dp"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:choiceMode="singleChoice"
            android:layout_below="@id/toolbar_container"
            android:layout_gravity="left|start" />
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:adSize="SMART_BANNER"
        app:adUnitId="@string/banner_ad_unit_id" />
</LinearLayout>
<?xml version="1.0" encoding="UTF-8" ?>
<com.google.android.material.appbar.AppBarLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            app:theme="@style/ToolBarStyle"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary" />

        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </FrameLayout>

</com.google.android.material.appbar.AppBarLayout>
-----------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include layout="@layout/search_container" />
        <ListView
            android:id="@+id/lstOtherRuins"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:nestedScrollingEnabled="true"
            android:layout_margin="8dp"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:choiceMode="singleChoice"
            android:layout_below="@id/toolbar_container"
            android:layout_gravity="left|start" />
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:adSize="SMART_BANNER"
        app:adUnitId="@string/banner_ad_unit_id" />
</LinearLayout>
<?xml version="1.0" encoding="UTF-8" ?>
<com.google.android.material.appbar.AppBarLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            app:theme="@style/ToolBarStyle"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary" />

        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </FrameLayout>

</com.google.android.material.appbar.AppBarLayout>

Search not working using recyclerview - Android

copy iconCopydownload iconDownload
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String s) {
                return false;
            }

            @Override
            public boolean onQueryTextChange(String s) {

                Query query = FirebaseDatabase.getInstance()
                        .getReference()
                        .child("posts").orderByChild("title").equalTo(s);

                if(s.equals("")){
                    query = FirebaseDatabase.getInstance()
                            .getReference()
                            .child("posts");
                }

                fetch(query);

                return false;
            }
        });


private void fetch(Query query) {

        FirebaseRecyclerOptions<Model> options =
                new FirebaseRecyclerOptions.Builder<Model>()
                        .setQuery(query, new SnapshotParser<Model>() {
                            @NonNull
                            @Override
                            public Model parseSnapshot(@NonNull DataSnapshot snapshot) {
                                return new Model(snapshot.child("id").getValue().toString(),
                                        snapshot.child("title").getValue().toString(),
                                        snapshot.child("desc").getValue().toString());
                            }
                        })
                        .build();

        adapter = new CustomFirebaseRecylerAdapter<Model, CustomFirebaseRecylerAdapter.ViewHolder>(options);
        adapter.startListening();
        recyclerView.setAdapter(adapter);
    }

com.google.firebase.database.Query cannot be cast to com.google.firebase.database.DatabaseReference

copy iconCopydownload iconDownload
private Query UsersRef;

Need Each fragment to return to home screen when user presess back(without any button in app)

copy iconCopydownload iconDownload
    @Override
    public void onBackPressed() {
        if (!(getSupportFragmentManager().findFragmentById(R.id.container) instanceof Home)) {
            fragmentManager = getSupportFragmentManager();
            fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.replace(R.id.container, new Home());
            fragmentTransaction.commit();
            titleText.setText(R.string.home);
        } else {
            super.onBackPressed();
        }
    }

Scroll behaviour of Tablayout with ActionBar is not working properly

copy iconCopydownload iconDownload
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/toolbar_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:elevation="0dp"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">


        </androidx.appcompat.widget.Toolbar>

        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|enterAlways|snap" />

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_marginTop="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            app:elevation="0dp"
            app:tabIndicatorColor="#ffffff"
            app:tabMode="fixed"
            app:layout_scrollFlags="noScroll"
            app:tabSelectedTextColor="#ffffff"
            app:tabTextColor="#d3d3d3" />

    </com.google.android.material.appbar.AppBarLayout>


    <com.example.fragmentcontroller.view_pager.LockableViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

Issue with Android Studio and Main Activity.kt expecting member declaration

copy iconCopydownload iconDownload
var searchView: MaterialSearchView? = null
val toolbar: Toolbar = view.findViewById(R.id.toolbar) as Toolbar 
-----------------------
Toolbar toolbar; // Declare the variable here so it's accessible outside of onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2); // Inflate view hierarchy.
    toolbar = (Toolbar) view.findViewById(R.id.toolbar); // Find your views.
    setSupportActionBar(toolbar);
}
lateinit var toolbar: Toolbar

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    toolbar = findViewById(R.id.toolbar) as Toolbar
    setSupportActionBar(toolbar)
}
val toolbar: Toolbar by lazy(LayzThreadSafetyMode.NONE) {
    toolbar = findViewById(R.id.toolbar) as Toolbar
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
private lateinit var binding: ActivityMain2Binding

@Override
fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    binding = ActivityMain2Binding.inflate(layoutInflater)
    setContentView(binding.root)
    setSupportActionBar(binding.toolbar)
}
-----------------------
Toolbar toolbar; // Declare the variable here so it's accessible outside of onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2); // Inflate view hierarchy.
    toolbar = (Toolbar) view.findViewById(R.id.toolbar); // Find your views.
    setSupportActionBar(toolbar);
}
lateinit var toolbar: Toolbar

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    toolbar = findViewById(R.id.toolbar) as Toolbar
    setSupportActionBar(toolbar)
}
val toolbar: Toolbar by lazy(LayzThreadSafetyMode.NONE) {
    toolbar = findViewById(R.id.toolbar) as Toolbar
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
private lateinit var binding: ActivityMain2Binding

@Override
fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    binding = ActivityMain2Binding.inflate(layoutInflater)
    setContentView(binding.root)
    setSupportActionBar(binding.toolbar)
}
-----------------------
Toolbar toolbar; // Declare the variable here so it's accessible outside of onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2); // Inflate view hierarchy.
    toolbar = (Toolbar) view.findViewById(R.id.toolbar); // Find your views.
    setSupportActionBar(toolbar);
}
lateinit var toolbar: Toolbar

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    toolbar = findViewById(R.id.toolbar) as Toolbar
    setSupportActionBar(toolbar)
}
val toolbar: Toolbar by lazy(LayzThreadSafetyMode.NONE) {
    toolbar = findViewById(R.id.toolbar) as Toolbar
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
private lateinit var binding: ActivityMain2Binding

@Override
fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    binding = ActivityMain2Binding.inflate(layoutInflater)
    setContentView(binding.root)
    setSupportActionBar(binding.toolbar)
}
-----------------------
Toolbar toolbar; // Declare the variable here so it's accessible outside of onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2); // Inflate view hierarchy.
    toolbar = (Toolbar) view.findViewById(R.id.toolbar); // Find your views.
    setSupportActionBar(toolbar);
}
lateinit var toolbar: Toolbar

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    toolbar = findViewById(R.id.toolbar) as Toolbar
    setSupportActionBar(toolbar)
}
val toolbar: Toolbar by lazy(LayzThreadSafetyMode.NONE) {
    toolbar = findViewById(R.id.toolbar) as Toolbar
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
private lateinit var binding: ActivityMain2Binding

@Override
fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    binding = ActivityMain2Binding.inflate(layoutInflater)
    setContentView(binding.root)
    setSupportActionBar(binding.toolbar)
}
-----------------------
Toolbar toolbar; // Declare the variable here so it's accessible outside of onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2); // Inflate view hierarchy.
    toolbar = (Toolbar) view.findViewById(R.id.toolbar); // Find your views.
    setSupportActionBar(toolbar);
}
lateinit var toolbar: Toolbar

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    toolbar = findViewById(R.id.toolbar) as Toolbar
    setSupportActionBar(toolbar)
}
val toolbar: Toolbar by lazy(LayzThreadSafetyMode.NONE) {
    toolbar = findViewById(R.id.toolbar) as Toolbar
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
private lateinit var binding: ActivityMain2Binding

@Override
fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    binding = ActivityMain2Binding.inflate(layoutInflater)
    setContentView(binding.root)
    setSupportActionBar(binding.toolbar)
}
-----------------------
setOnClickListener { ​onClick(item) }

Execution failed for task ':app:processDebugResources'. Gradle Build Failed

copy iconCopydownload iconDownload
apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
     defaultConfig {
        applicationId "com.atmajaa.adda"
        minSdkVersion 16
        targetSdkVersion 26
        ...
        resConfigs "auto"
        ...
     }
}
android {
    defaultConfig {
        ...
        resConfigs "en"
    }
}
-----------------------
apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
     defaultConfig {
        applicationId "com.atmajaa.adda"
        minSdkVersion 16
        targetSdkVersion 26
        ...
        resConfigs "auto"
        ...
     }
}
android {
    defaultConfig {
        ...
        resConfigs "en"
    }
}

Android Studio- Program type already present: com.google.android.gms.internal.measurement.zzwp

copy iconCopydownload iconDownload
  dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support:customtabs:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

        implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'

        implementation 'com.facebook.android:audience-network-sdk:4.28.0'
        implementation 'com.facebook.android:facebook-login:4.32.0'
        implementation 'com.android.support:multidex:1.0.3'

        implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'

        implementation 'com.android.support:support-v4:27.1.1'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

        implementation 'com.google.firebase:firebase-core:15.0.2'
        implementation 'com.google.firebase:firebase-database:15.0.0'
        implementation 'com.google.firebase:firebase-crash:15.0.2'
        implementation 'com.google.firebase:firebase-auth:15.0.0'
        implementation 'com.google.firebase:firebase-storage:15.0.2'
        implementation 'com.firebaseui:firebase-ui-database:3.3.1'

        implementation 'com.google.android.gms:play-services-auth:15.0.0'
        implementation 'com.google.android.gms:play-services-plus:15.0.0'
        implementation 'com.google.android.gms:play-services-location:15.0.0'

        implementation 'com.android.support:cardview-v7:27.1.1'
        implementation 'com.android.support:recyclerview-v7:27.1.1'

        implementation 'com.squareup.picasso:picasso:2.5.2'
        implementation 'com.squareup.retrofit2:retrofit:2.3.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

        implementation 'com.stepstone.apprating:app-rating:2.2.0'
        implementation 'com.android.support:design:27.1.1'
        implementation 'com.github.lguipeng:BubbleView:1.0.1'

        implementation 'uk.co.chrisjenx:calligraphy:2.3.0'

        implementation 'com.miguelcatalan:materialsearchview:1.4.0'

        implementation 'com.github.MdFarhanRaja:SearchableSpinner:1.9'

        implementation 'com.github.sillebille:dynamic-calendar:1.0.1'

        implementation 'com.google.api-client:google-api-client:1.22.0'
        implementation 'com.google.api-client:google-api-client-android:1.22.0'
        implementation 'com.google.apis:google-api-services-people:v1-rev4-1.22.0'
    }
-----------------------
implementation 'com.google.firebase:firebase-crash:15.0.0'
implementation 'com.google.firebase:firebase-crash:15.0.2'
-----------------------
implementation 'com.google.firebase:firebase-crash:15.0.0'
implementation 'com.google.firebase:firebase-crash:15.0.2'
-----------------------
implementation "com.google.firebase:firebase-messaging:15.0.2"
buildscript {
    dependencies {

        classpath 'com.google.gms:google-services:3.2.1'

    }
 }
-----------------------
implementation "com.google.firebase:firebase-messaging:15.0.2"
buildscript {
    dependencies {

        classpath 'com.google.gms:google-services:3.2.1'

    }
 }
-----------------------
dependencies {

        classpath 'com.google.gms:google-services:3.2.1'

    }
https://firebase.google.com/support/release-notes/android
implementation 'com.google.firebase:firebase-config:15.0.0'
implementation 'com.google.firebase:firebase-config:15.0.2'
-----------------------
dependencies {

        classpath 'com.google.gms:google-services:3.2.1'

    }
https://firebase.google.com/support/release-notes/android
implementation 'com.google.firebase:firebase-config:15.0.0'
implementation 'com.google.firebase:firebase-config:15.0.2'
-----------------------
dependencies {

        classpath 'com.google.gms:google-services:3.2.1'

    }
https://firebase.google.com/support/release-notes/android
implementation 'com.google.firebase:firebase-config:15.0.0'
implementation 'com.google.firebase:firebase-config:15.0.2'
-----------------------
dependencies {

        classpath 'com.google.gms:google-services:3.2.1'

    }
https://firebase.google.com/support/release-notes/android
implementation 'com.google.firebase:firebase-config:15.0.0'
implementation 'com.google.firebase:firebase-config:15.0.2'
-----------------------
-        classpath 'com.android.tools.build:gradle:3.1.0'
+        classpath 'com.android.tools.build:gradle:3.0.1'
-----------------------
buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:4.1.0' // google-services plugin
    }
}

allprojects {
    // ...
    repositories {
        // ...
        google() // Google's Maven repository
    }
}
Firebase Core                com.google.firebase:firebase-core:16.0.3
Ads                          com.google.firebase:firebase-ads:15.0.1
Analytics                    com.google.firebase:firebase-analytics:16.0.3
App Indexing                 com.google.firebase:firebase-appindexing:16.0.1
Authentication               com.google.firebase:firebase-auth:16.0.3
Cloud Firestore              com.google.firebase:firebase-firestore:17.1.0
Cloud Functions              com.google.firebase:firebase-functions:16.1.0
Cloud Messaging              com.google.firebase:firebase-messaging:17.3.2
Cloud Storage   c            om.google.firebase:firebase-storage:16.0.2
Crash Reporting              com.google.firebase:firebase-crash:16.2.0
Crashlytics                  com.crashlytics.sdk.android:crashlytics:2.9.5
Dynamic Links                com.google.firebase:firebase-dynamic-links:16.1.1
Invites                      com.google.firebase:firebase-invites:16.0.3
In-App Messaging             com.google.firebase:firebase-inappmessaging:17.0.1
In-App Messaging Display     com.google.firebase:firebase-inappmessaging-display:17.0.1
ML Kit: Model Interpreter    com.google.firebase:firebase-ml-model-interpreter:16.2.0
ML Kit: Vision               com.google.firebase:firebase-ml-vision:17.0.0
ML Kit: Image Labeling       com.google.firebase:firebase-ml-vision-image-label-model:15.0.0
Performance Monitoring       com.google.firebase:firebase-perf:16.1.0
Realtime Database            com.google.firebase:firebase-database:16.0.2
Remote Config                com.google.firebase:firebase-config:16.0.0
-----------------------
buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:4.1.0' // google-services plugin
    }
}

allprojects {
    // ...
    repositories {
        // ...
        google() // Google's Maven repository
    }
}
Firebase Core                com.google.firebase:firebase-core:16.0.3
Ads                          com.google.firebase:firebase-ads:15.0.1
Analytics                    com.google.firebase:firebase-analytics:16.0.3
App Indexing                 com.google.firebase:firebase-appindexing:16.0.1
Authentication               com.google.firebase:firebase-auth:16.0.3
Cloud Firestore              com.google.firebase:firebase-firestore:17.1.0
Cloud Functions              com.google.firebase:firebase-functions:16.1.0
Cloud Messaging              com.google.firebase:firebase-messaging:17.3.2
Cloud Storage   c            om.google.firebase:firebase-storage:16.0.2
Crash Reporting              com.google.firebase:firebase-crash:16.2.0
Crashlytics                  com.crashlytics.sdk.android:crashlytics:2.9.5
Dynamic Links                com.google.firebase:firebase-dynamic-links:16.1.1
Invites                      com.google.firebase:firebase-invites:16.0.3
In-App Messaging             com.google.firebase:firebase-inappmessaging:17.0.1
In-App Messaging Display     com.google.firebase:firebase-inappmessaging-display:17.0.1
ML Kit: Model Interpreter    com.google.firebase:firebase-ml-model-interpreter:16.2.0
ML Kit: Vision               com.google.firebase:firebase-ml-vision:17.0.0
ML Kit: Image Labeling       com.google.firebase:firebase-ml-vision-image-label-model:15.0.0
Performance Monitoring       com.google.firebase:firebase-perf:16.1.0
Realtime Database            com.google.firebase:firebase-database:16.0.2
Remote Config                com.google.firebase:firebase-config:16.0.0
-----------------------
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-core:16.0.4"
-----------------------
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-core:16.0.4"
-----------------------
implementation 'com.google.android.gms:play-services-analytics::16.0.7'
-----------------------
allprojects {
    repositories {
    //start here
    configurations.all {
 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
   def requested = details.requested
       if (requested.group == 'com.google.android.gms') {
          details.useVersion '12.0.1'
       }
       if (requested.group == 'com.google.firebase') {
          details.useVersion '12.0.1'
         }
       }
     }
    //end
     jcenter()
       maven {
         url "https://maven.google.com"
       }
     }
 }

Community Discussions

Trending Discussions on MaterialSearchView
  • How can I resolve Android Studio 4.2 build errors after removing jcenter()?
  • A ListView overlaps a SearchView in a CoordinatorLayout
  • A ListView is not displaying any data on OnCreate/OnStart after AndroidX migration
  • Native Exception on a Pixel 2 XL
  • Search not working using recyclerview - Android
  • com.google.firebase.database.Query cannot be cast to com.google.firebase.database.DatabaseReference
  • Need Each fragment to return to home screen when user presess back(without any button in app)
  • Error inflating class material.bottomnavigation.BottomNavigationView
  • IOException cannot delete path
  • Scroll behaviour of Tablayout with ActionBar is not working properly
Trending Discussions on MaterialSearchView

QUESTION

How can I resolve Android Studio 4.2 build errors after removing jcenter()?

Asked 2021-Jun-10 at 17:04

I have upgraded Android Studio from 4.1.3 to 4.2, using latest gradle and gradle plugin. Now references to using jcenter() in the build script are deprecated due to jcenter being end-of-lifed:

enter image description here

The suggestion is to "migrate" to mavenCentral(). I have various dependencies that are seemingly not on mavenCentral(), because gradle cannot find them, for example:

enter image description here

I Googled the artifact ("materialsearchview" in this case) and found it on the search platform "MVNrepository":

enter image description here

So here is what I have tried (all unsuccessful) to put a reference into my build script to have gradle find this artifact:

  1. I added a reference to the mvnrepository to my project level build.gradle file (which I didn't expect to work given that mvnrepository is a search mechanism) highlighted in the red box in the pic, i.e.:

    maven { url 'https://mvnrepository.com/artifact/' }

  2. I added a reference to the repository identified in the blue box at the bottom where mvnrepository says the artifact is located, i.e.

    maven {url 'https://repo.spring.io/plugins-release/'}

This generated a slightly different error:

Could not HEAD 'https://repo.spring.io/plugins-release/com/miguelcatalan/materialsearchview/1.4.0/materialsearchview-1.4.0.pom'. Received status code 401 from server: Unauthorized
  1. I found the .aar file for this dependency, added it to my 'libs' directory and updated my app module level build.gradle file like this:

    implementation fileTree(include: ['.jar','.aar'], dir: 'libs')

  2. I did an 'invalidate caches and restart' at this point, thinking AS needed to index the newly added .aar file before gradle would recognize it. No joy.

  3. I specifically added the .aar file to the libs directory, then added a reference to it in the app module build.gradle:

    implementation(name:'materialsearchview-1.4.0', ext:'aar')

then did another invalidate cache/restart. No joy.

So I guess I have three questions:

  1. Once I find a reference to an artiface in mvnrepository, is there a proper way to reference it in my gradle script so that the build system can reconcile what it needs?

  2. What other ways are there to find what other repositories that gradle CAN address to see if the item is there?

  3. Why is using the .aar file in the libs directory as I am doing it failing? Why can't Gradle see it there?

Thanks!

ANSWER

Answered 2021-May-11 at 02:44

After discussing this with Mark Murphy of CommonsWare, I realized I was under a misunderstanding about the relationship between the repositories section of the project level build.gradle file, and the implementation statements of the module level build.gradle file.

Here is a good way to think of it thanks to Mark:

Project level build.gradle, i.e.:

repositories {
    google()
    mavenCentral()
    maven { url 'https://maven.preemptive.com/' }
    maven { url 'https://jitpack.io' }
    //jcenter()
}

Think of these as "Gradle, look into these repositories to reconcile all the 'implementation' statements."

Then in the module level build.gradle I had this:

implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')

Think of this as "Oh yeah, grab all these things too, even if I didn't mention them as specific dependencies".

My mistake #1 was in thinking I could have an .aar file in the libs directory which ALSO had a corresponding 'implementation' statement. You can't.

My mistake #2 was that I had an implementation statement that referenced a .aar file that was in maven (which is fine since maven is in my repositories block) which itself referenced an .aar file that was not in maven but only in jcenter (which is not since I just removed jcenter from the repositories block). When I removed the reference to jcenter in the repositories block this dependency ("transitive dependency") was not reconciled and the build failed.

So lessons learned:

Any resource referenced in an 'implementation' statement AND ANY RESOURCE THAT IS IN ITS POM THAT IT DEPENDS ON must ALL be in repositories that you define in the repositories block.

If ANY of the dependencies were in jcenter, since I got rid of jcenter then I must:

  1. Find another repository instead of jcenter that has the same resources needed to satisfy the ALL dependencies associated with the resource in question OR
  2. Gather all the .jar/.aar files that represent that resource (the one you want and all the ones it references), place them in the /libs directory (under the module you are building), make sure your have your fileTree statement correctly formed, and REMOVE references to all those same resources from your 'implementations' statements.

How does one identify all the dependencies you ask? Well you can do it the slow way (like I did at first) and keep finding/adding them until the build doesn't break anymore. Or you can be more clever about it and let Gradle tell you which it will do if you ask it (see the docs here).

Finally - don't forget that it is not enough to make sure the referenced .aar file is in libs. In other words, Gradle does not work like: "I will look first at the repositories to satisfy your implementation dependencies and any dependency they reference, and if they are not there then I will look through all the .jar and .aar files in the spot you told me to look in the fileTree statement". Instead, note that any dependency that is referenced by an item in an 'implementation' statement needs to ALSO be able to be found within the repositories. If it can't then your only choice is to use that dependency graph, determine ALL the dependencies, and put all the .aar files into /libs AND remove any from your 'implementation' statements.

Much easier if you can find another repository instead of messing with all the individual .aar files!

Source https://stackoverflow.com/questions/67472856

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install MaterialSearchView

You can download it from GitHub.
You can use MaterialSearchView like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the MaterialSearchView component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.