Reputation: 1
I am trying to build a cognitive search client using Microsoft azure cognitive search to query my indexer which has already indexed my data on the azure portal. What could possibly be the problem? is there an error with the compatibility of the dependencies and the android API level?
build.gradle
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
namespace 'com.example.hiddeneye'
compileSdk 33
defaultConfig {
applicationId "com.example.hiddeneye"
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures{
viewBinding true
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
resources {
excludes += ['META-INF/INDEX.LIST', 'META-INF/NOTICE.md', 'META-INF/io.netty.versions.properties', 'META-INF/LICENSE.md']
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'androidx.recyclerview:recyclerview:1.3.0'
implementation 'androidx.cardview:cardview:1.0.0'
// Azure blob storage
implementation 'com.azure.android:azure-core:1.0.0-beta.12'
implementation 'com.microsoft.azure.android:azure-storage-android:2.0.0@aar'
// Azure Cogntive Search
implementation 'com.azure:azure-search-documents:11.5.5'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
}
the method that does my search. I am doing it in an async method as that was what worked for me to take the data from my azure blob storage. I have already successfully created an indexer and an index on the azure portal itself. Queries can also be made on the azure portal so I want to link it up with my android app.
public void searchVideos(String searchQuery) {
System.out.println("search method block");
Executor serialExecutor = Executors.newSingleThreadExecutor();
serialExecutor.execute(new Runnable() {
@Override
public void run() {
System.out.println("run method block");
try {
System.out.println("client builder block");
searchClient = new SearchClientBuilder()
.endpoint(endpoint)
.credential(adminKey)
.indexName(indexName)
.buildClient();
System.out.println("search options block");
SearchOptions options = new SearchOptions();
options.setIncludeTotalCount(true);
options.setFilter("");
options.setOrderBy("");
options.setSelect("videoPath", "age");
System.out.println("search results block");
SearchPagedIterable results = searchClient.search(searchQuery, options, Context.NONE);
System.out.println("search items block");
List<VideoAttribute> items = new ArrayList<>();
for (SearchResult result : results) {
VideoAttribute item = result.getDocument(VideoAttribute.class);
items.add(item);
}
System.out.println(items.get(1));
videoAttributesLiveData.postValue(items);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
the createView method that calls the search method
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
CognitiveSearchRepository searchRepository = new CognitiveSearchRepository();
searchRepository.searchVideos("*");
return inflater.inflate(R.layout.fragment_settings, container, false);
}
this is the runtime error I got when I try to run my application
E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1 java.lang.ExceptionInInitializerError at com.azure.core.implementation.ReflectionUtils.getLookupToUse(ReflectionUtils.java:119) at com.azure.core.util.ExpandableStringEnum.getDefaultConstructor(ExpandableStringEnum.java:88) at com.azure.core.util.ExpandableStringEnum.$r8$lambda$SMtq8BJfA6t_qJk1WfhslLPTCwc(Unknown Source:0) at com.azure.core.util.ExpandableStringEnum$$ExternalSyntheticLambda1.apply(Unknown Source:2) at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1710) at com.azure.core.util.ExpandableStringEnum.fromString(ExpandableStringEnum.java:68) at com.azure.core.http.HttpHeaderName.fromString(HttpHeaderName.java:60) at com.azure.core.http.HttpHeaderName.(HttpHeaderName.java:88) at com.azure.core.http.HttpHeaderName.fromString(HttpHeaderName.java:56) at com.azure.core.http.policy.RequestIdPolicy.(RequestIdPolicy.java:33) at com.azure.search.documents.implementation.util.Utility.buildHttpPipeline(Utility.java:130) at com.azure.search.documents.SearchClientBuilder.getHttpPipeline(SearchClientBuilder.java:203) at com.azure.search.documents.SearchClientBuilder.buildAsyncClient(SearchClientBuilder.java:175) at com.azure.search.documents.SearchClientBuilder.buildClient(SearchClientBuilder.java:153) at com.example.hiddeneye.Repository.CognitiveSearchRepository$1.run(CognitiveSearchRepository.java:51) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012) Caused by: java.lang.RuntimeException: Unable to use package-private MethodHandles.Lookup constructor. at com.azure.core.implementation.ReflectionUtils.(ReflectionUtils.java:84) at com.azure.core.implementation.ReflectionUtils.getLookupToUse(ReflectionUtils.java:119) at com.azure.core.util.ExpandableStringEnum.getDefaultConstructor(ExpandableStringEnum.java:88) at com.azure.core.util.ExpandableStringEnum.$r8$lambda$SMtq8BJfA6t_qJk1WfhslLPTCwc(Unknown Source:0) at com.azure.core.util.ExpandableStringEnum$$ExternalSyntheticLambda1.apply(Unknown Source:2) at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1710) at com.azure.core.util.ExpandableStringEnum.fromString(ExpandableStringEnum.java:68) at com.azure.core.http.HttpHeaderName.fromString(HttpHeaderName.java:60) at com.azure.core.http.HttpHeaderName.(HttpHeaderName.java:88) at com.azure.core.http.HttpHeaderName.fromString(HttpHeaderName.java:56) at com.azure.core.http.policy.RequestIdPolicy.(RequestIdPolicy.java:33) at com.azure.search.documents.implementation.util.Utility.buildHttpPipeline(Utility.java:130) at com.azure.search.documents.SearchClientBuilder.getHttpPipeline(SearchClientBuilder.java:203) at com.azure.search.documents.SearchClientBuilder.buildAsyncClient(SearchClientBuilder.java:175) at com.azure.search.documents.SearchClientBuilder.buildClient(SearchClientBuilder.java:153) at com.example.hiddeneye.Repository.CognitiveSearchRepository$1.run(CognitiveSearchRepository.java:51) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012) Caused by: java.lang.NoSuchMethodException: java.lang.invoke.MethodHandles$Lookup. [class java.lang.Class] at java.lang.Class.getConstructor0(Class.java:2363) at java.lang.Class.getDeclaredConstructor(Class.java:2201) at com.azure.core.implementation.ReflectionUtils.(ReflectionUtils.java:76) at com.azure.core.implementation.ReflectionUtils.getLookupToUse(ReflectionUtils.java:119) at com.azure.core.util.ExpandableStringEnum.getDefaultConstructor(ExpandableStringEnum.java:88) at com.azure.core.util.ExpandableStringEnum.$r8$lambda$SMtq8BJfA6t_qJk1WfhslLPTCwc(Unknown Source:0) at com.azure.core.util.ExpandableStringEnum$$ExternalSyntheticLambda1.apply(Unknown Source:2) at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1710) at com.azure.core.util.ExpandableStringEnum.fromString(ExpandableStringEnum.java:68) at com.azure.core.http.HttpHeaderName.fromString(HttpHeaderName.java:60) at com.azure.core.http.HttpHeaderName.(HttpHeaderName.java:88) at com.azure.core.http.HttpHeaderName.fromString(HttpHeaderName.java:56) at com.azure.core.http.policy.RequestIdPolicy.(RequestIdPolicy.java:33) at com.azure.search.documents.implementation.util.Utility.buildHttpPipeline(Utility.java:130) at com.azure.search.documents.SearchClientBuilder.getHttpPipeline(SearchClientBuilder.java:203) at com.azure.search.documents.SearchClientBuilder.buildAsyncClient(SearchClientBuilder.java:175) at com.azure.search.documents.SearchClientBuilder.buildClient(SearchClientBuilder.java:153) at com.example.hiddeneye.Repository.CognitiveSearchRepository$1.run(CognitiveSearchRepository.java:51)
Upvotes: 0
Views: 333