我一直在尝试在我的Android应用中实现这种类型的SearchBar
。 search bar android 2我尝试了一个库列表,但没有得到预期的结果。
我发现最接近的图书馆之一就是这个图书馆。 custom search bar by mancj
但是,当我尝试导入依赖项时,(implementation 'com.github.mancj:MaterialSearchBar:0.7.6'
)给了我一个错误。
错误
Could not find com.github.mancj:MaterialSearchBar:0.7.6.
Searched in the following locations:
file:/C:/Users/bnotion/AppData/Local/Android/Sdk/extras/m2repository/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.pom
file:/C:/Users/bnotion/AppData/Local/Android/Sdk/extras/m2repository/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.jar
file:/C:/Users/bnotion/AppData/Local/Android/Sdk/extras/google/m2repository/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.pom
file:/C:/Users/bnotion/AppData/Local/Android/Sdk/extras/google/m2repository/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.jar
file:/C:/Users/bnotion/AppData/Local/Android/Sdk/extras/android/m2repository/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.pom
file:/C:/Users/bnotion/AppData/Local/Android/Sdk/extras/android/m2repository/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.jar
https://dl.google.com/dl/android/maven2/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.pom
https://dl.google.com/dl/android/maven2/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.jar
https://jcenter.bintray.com/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.pom
https://jcenter.bintray.com/com/github/mancj/MaterialSearchBar/0.7.6/MaterialSearchBar-0.7.6.jar
Required by:
project :app
GRADLE(应用级)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.app"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-database:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.github.mancj:MaterialSearchBar:0.7.6'
implementation 'com.shobhitpuri.custombuttons:google-signin:1.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.android.support:design:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
GRADLE(项目级别)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我认为库导入可能存在问题。有没有办法来解决这个问题? 我还希望单击它时激活搜索查询。任何有用的想法将不胜感激。
答案 0 :(得分:2)
在项目级别build.gradle
文件中,请确保其中有maven
,否则将无法使用该库。
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}