Android studio failed resolution for AsyncTask - android

I have been working on this Android app that extracts content from an online article. I'm trying to fix this error for hours now, so I would really appreciate it if anyone can help.
I have seen some few similar questions but none of that is applicable for my app so I'm posting this.
I don't know how to fix this error with AsyncTask.
<Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Image; at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl>
These are the full error messages
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.example.chaudo.textsummarizingapp, PID: 4446
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Image;
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:381)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:63)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:128)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:84)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:162)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:92)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:444)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:292)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:139)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1138)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:162)
at java.lang.reflect.Method.invoke(Native Method)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:262)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:249)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:456)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:656)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599)
at com.aylien.textapi.TextAPIClient.extract(TextAPIClient.java:102)
at com.example.chaudo.textsummarizingapp.ArticleClass.articleExtract(ArticleClass.java:35)
at com.example.chaudo.textsummarizingapp.ArticleClass.doInBackground(ArticleClass.java:62)
at com.example.chaudo.textsummarizingapp.ArticleClass.doInBackground(ArticleClass.java:13)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:764) 
E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.Image" on path: DexPathList[[zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/base.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_resources_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/lib/x86, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 27 more Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.chaudo.textsummarizingapp-w8twusyP96c8nQsFdomFUA==/split_lib_resources_apk.apk at dalvik.system.DexFile.openDexFileNative(Native Method) at dalvik.system.DexFile.openDexFile(DexFile.java:354) at dalvik.system.DexFile.(DexFile.java:101) at dalvik.system.DexFile.(DexFile.java:75) at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394) at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354) at dalvik.system.DexPathList.(DexPathList.java:164) at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:74) at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:65) at dalvik.system.PathClassLoader.(PathClassLoader.java:64) at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73) at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88) at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74) at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40) at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727) at android.app.LoadedApk.getClassLoader(LoadedApk.java:810) at android.app.LoadedApk.getResources(LoadedApk.java:1032) at android.app.ContextImpl.createAppContext(ContextImpl.java:2345) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749) at android.app.ActivityThread.access$1100(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
This is my code. I tested the articleExtract() function to make sure it works properly in a normal Java class, but it shows error when I tried to call it through AsyncTask in the MainActivity in Android Studio.
#Override
protected Void doInBackground(Void... voids) {
try {
articleExtract();
System.out.println(article);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (TextAPIException e) {
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(Void s) {
//Show the result obtained from doInBackground
System.out.println(article);
}
In the Main Thread
new ArticleClass(url).execute();

Related

Unable to save file in internal directory

I a trying to create folder in internal storage in android and want to add files in that folder but app is crashing below is logcat:
11-29 19:40:02.241 23675-23675/com.app.papers E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.papers, PID: 23675
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Papers: open failed: EISDIR (Is a directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
at java.io.FileOutputStream.<init>(FileOutputStream.java:72)
at com.app.papers.PickImage$b.onClick(SourceFile:81)
at android.view.View.performClick(View.java:5716)
at android.widget.TextView.performClick(TextView.java:10926)
at android.view.View$PerformClick.run(View.java:22596)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: android.system.ErrnoException: open failed: EISDIR (Is a directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
Below is my code:
val document: PdfDocument = PdfDocument()
val pageInfo: PdfDocument.PageInfo? = bitmap?.width?.let { it1 ->
bitmap?.height?.let { it2 ->
PdfDocument.PageInfo.Builder(
it1,
it2, 1).create()
}
}
val page: PdfDocument.Page = document.startPage(pageInfo)
val canvas: Canvas = page.canvas
bitmap?.let { it1 -> canvas.drawBitmap(it1, 0f, 0f, null) }
document.finishPage(page)
val mediaStorageDir = File(Environment.getExternalStorageDirectory(), "Papers")
if (mediaStorageDir.exists()) {
document.writeTo( FileOutputStream(mediaStorageDir))
document.close()
}
What I am doing wrong?
I a trying to create folder in internal storage in android
FWIW, your code is set up for external storage.
Someone please let me know what I am doing wrong any help would be appreciated.
Papers/ appears to exist and is a directory. writeTo() takes a file, not a directory. Try something like:
val mediaStorageDir = File(Environment.getExternalStorageDirectory(), "Papers")
if (mediaStorageDir.exists()) {
val pdfFile = File(mediaStorageDir, "something.pdf")
document.writeTo( FileOutputStream(pdfFile))
document.close()
}

How to implement library calendar view

I am using this library to make calendar app similar to google calendar week view calendar. I read all documentation and added implementation 'com.jonaswanke.calendar:calendar:0.1.1' in build.gradle, but when I add calendar view to activity_mail.xml
<com.jonaswanke.calendar.CalendarView
android:id="#+id/calendar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:range="week" />
following exception crashed my app on app start.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 13101
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #9 in com.example.myapplication:layout/activity_main: Binary XML file line #9 in com.example.myapplication:layout/activity_main: Error inflating class com.jonaswanke.calendar.CalendarView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3895)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4074)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8347)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: android.view.InflateException: Binary XML file line #9 in com.example.myapplication:layout/activity_main: Binary XML file line #9 in com.example.myapplication:layout/activity_main: Error inflating class com.jonaswanke.calendar.CalendarView
Caused by: android.view.InflateException: Binary XML file line #9 in com.example.myapplication:layout/activity_main: Error inflating class com.jonaswanke.calendar.CalendarView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:864)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:971)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1133)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
at com.example.myapplication.MainActivity.onCreate(MainActivity.kt:27)
at android.app.Activity.performCreate(Activity.java:8085)
at android.app.Activity.performCreate(Activity.java:8073)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3868)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4074)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8347)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/experimental/CoroutineDispatcher;
at com.jonaswanke.calendar.CalendarView.<init>(CalendarView.kt:495)
E/AndroidRuntime: at com.jonaswanke.calendar.CalendarView.<init>(CalendarView.kt:32)
at com.jonaswanke.calendar.CalendarView.<init>(Unknown Source:6)
... 28 more
Caused by: java.lang.ClassNotFoundException: kotlinx.coroutines.experimental.CoroutineDispatcher
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 31 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/coroutines/experimental/AbstractCoroutineContextElement;
... 31 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.coroutines.experimental.AbstractCoroutineContextElement" on path: DexPathList[[zip file "/data/app/com.example.myapplication-_1QFEnFxaCJxdEfjNQvp0g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-_1QFEnFxaCJxdEfjNQvp0g==/lib/arm64, /system/lib64, /hw_product/lib64, /system/product/lib64, /prets/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:209)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 31 more
I/Process: Sending signal. PID: 13101 SIG: 9
In MainActivity.kt file I only added:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
calendar.eventRequestCallback = {
populate(it)
}
}
#Suppress("MagicNumber")
private fun populate(week: Week, force: Boolean = false) {
if (!force && calendar.cachedEvents.contains(week))
return
val events = mutableListOf<Event>()
for (i in 0..15) {
val id = nextId++.toString()
val start = week.start + abs(random.nextLong()) % DateUtils.WEEK_IN_MILLIS
events.add(BaseEvent(
id,
id,
(random.nextInt() or 0xFF000000.toInt()) and 0x00202020.inv(),
start,
start + abs(random.nextLong()) % (DateUtils.DAY_IN_MILLIS / 8)))
}
for (i in 0..3) {
val id = nextId++.toString()
val start = week.start + abs(random.nextLong()) % DateUtils.WEEK_IN_MILLIS
events.add(BaseEvent(
id,
id,
(random.nextInt() or 0xFF000000.toInt()) and 0x00202020.inv(),
start,
start + abs(random.nextLong()) % (DateUtils.DAY_IN_MILLIS * 7),
true))
}
calendar.setEventsForWeek(week, events)
}
But even without this code app still crashes.
This is an old library that was built using experimental Kotlin features. It hasn't been maintained for two years. I tried for 20 minutes to get it to compile. It's just not worth it. I suggest using one of the several other Android CalendarView libraries out there:
https://github.com/search?q=android+calendarview
This one looks particularly promising:
https://github.com/kizitonwose/CalendarView

App stopped responding on adding data to FireBase. Getting: Failed resolution of: Lcom/google/common/base/CharMatcher;

I'm new to FireStore, and when I was trying to insert a data using Hashmap it is showing error.
This is the line which I'm adding to my firestore:
Map map = new HashMap<>();
map.put("And","What");
map.put("So","What Bro");
firebaseFirestore.collection("mycollection").document("mydocument").set(map).addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
Toast.makeText(ContactActivity.this, "Success", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(ContactActivity.this, "Failure", Toast.LENGTH_SHORT).show();
}
});
And the error is:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.example.myapp, PID: 13076
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/base/CharMatcher;
at com.google.common.base.Splitter.on(Splitter.java:125)
at io.grpc.internal.GrpcUtil.(GrpcUtil.java:203)
at io.grpc.internal.AbstractManagedChannelImplBuilder.(AbstractManagedChannelImplBuilder.java:84)
at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:48)
at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:27)
at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:73)
at com.google.firebase.firestore.remote.GrpcCallProvider.initChannel(com.google.firebase:firebase-firestore##21.4.3:113)
at com.google.firebase.firestore.remote.GrpcCallProvider.lambda$initChannelTask$6(com.google.firebase:firebase-firestore##21.4.3:256)
at com.google.firebase.firestore.remote.GrpcCallProvider$$Lambda$5.call(com.google.firebase:firebase-firestore##21.4.3)
at com.google.android.gms.tasks.zzv.run(Unknown Source)
at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(com.google.firebase:firebase-firestore##21.4.3:54)
at com.google.firebase.firestore.util.ThrottledForwardingExecutor$$Lambda$1.run(com.google.firebase:firebase-firestore##21.4.3)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.base.CharMatcher" on path: DexPathList[[zip file "/data/app/com.example.myapp-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.google.common.base.Splitter.on(Splitter.java:125) 
at io.grpc.internal.GrpcUtil.(GrpcUtil.java:203) 
at io.grpc.internal.AbstractManagedChannelImplBuilder.(AbstractManagedChannelImplBuilder.java:84) 
at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:48) 
at io.grpc.okhttp.OkHttpChannelProvider.builderForTarget(OkHttpChannelProvider.java:27) 
at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:73) 
at com.google.firebase.firestore.remote.GrpcCallProvider.initChannel(com.google.firebase:firebase-firestore##21.4.3:113) 
at com.google.firebase.firestore.remote.GrpcCallProvider.lambda$initChannelTask$6(com.google.firebase:firebase-firestore##21.4.3:256) 
at com.google.firebase.firestore.remote.GrpcCallProvider$$Lambda$5.call(com.google.firebase:firebase-firestore##21.4.3) 
at com.google.android.gms.tasks.zzv.run(Unknown Source) 
at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(com.google.firebase:firebase-firestore##21.4.3:54) 
at com.google.firebase.firestore.util.ThrottledForwardingExecutor$$Lambda$1.run(com.google.firebase:firebase-firestore##21.4.3) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:818) 
Suppressed: java.lang.NoClassDefFoundError: com.google.common.base.CharMatcher
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 17 more
Suppressed: java.lang.ClassNotFoundException: com.google.common.base.CharMatcher
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I got the solution. After pasting this line of code in apps > Build.gradle file it worked fined.
Here is the code:
implementation group: 'com.google.guava', name: 'guava', version: '28.1-android'

getting error as FATAL EXCEPTION: AsyncTask #1 Process java.lang.RuntimeException: An error occurred while executing doInBackground()

Getting error as this how to fix it I uploaded the full error as you guys asked to please get me the solution for this as soon as possible FATAL EXCEPTION: AsyncTask
java.lang.RuntimeException: An error occurred while executing doInBackground()java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory;
at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:182)
at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:150)
at com.example.fedov1.MainActivity$uploadToServer.doInBackground(MainActivity.java:133)
at com.example.fedov1.MainActivity$uploadToServer.doInBackground(MainActivity.java:116)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.LogFactory" on path: DexPathList[[zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/base.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_resources_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:182)
at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:150)
at com.example.fedov1.MainActivity$uploadToServer.doInBackground(MainActivity.java:133)
at com.example.fedov1.MainActivity$uploadToServer.doInBackground(MainActivity.java:116)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.fedov1-ss7Jjv6bMfocdCHyFGUmHw==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2357)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5792)
at android.app.ActivityThread.access$1100(ActivityThread.java:202)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1665)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6729)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I added this line is because of this
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
or some other problems guide me
protected String doInBackground(Void... params) {
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("base64", ba1));
nameValuePairs.add(new BasicNameValuePair("ImageName", System.currentTimeMillis() + ".jpg"));
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(URL);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
String st = EntityUtils.toString(response.getEntity());
Log.v("log_tag", "In the try Loop" + st);
} catch (Exception e) {
Log.v("log_tag", "Error in http connection " + e.toString());
}
return "Success";
}
try adding these lines in AndroidManifest.xml like this
<uses-library android:name ="org.apache.http.legacy"
android:required ="false"/>

Navigation Library inflator throws ClassNotFoundException for data class

In the Navigation Library version alpha09+ (using alpha11) I am experiencing a ClassNotFoundException for one of my data classes which I defined as an argType in my navigation graph.
app:argType="com.package.app.data.model.user.User.Full"
This class does exist. When downgrading back to alpha08, the issue does not appear to happen.
This is the full stacktrace:
2019-01-28 10:30:32.028 6970-6970/com.package.app.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.package.app.debug, PID: 6970
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.package.app.debug/com.package.app.ui.MainActivity}: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class fragment
Caused by: java.lang.RuntimeException: Exception inflating com.package.app.debug:navigation/navigation_main line 376
at androidx.navigation.NavInflater.inflate(NavInflater.java:89)
at androidx.navigation.NavController.setGraph(NavController.java:424)
at androidx.navigation.NavController.setGraph(NavController.java:406)
at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:226)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2414)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1418)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1684)
at androidx.fragment.app.FragmentManagerImpl.addFragment(FragmentManager.java:1930)
at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3745)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:120)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:405)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:387)
at co.lokalise.android.sdk.core.LokaliseLayoutInflater$PrivateWrapperFactory2.onCreateView(LokaliseLayoutInflater.java:362)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:186)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at co.lokalise.android.sdk.core.LokaliseLayoutInflater.inflate(LokaliseLayoutInflater.java:84)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.package.app.ui.MainActivity.onCreate(MainActivity.kt:75)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
2019-01-28 10:30:32.031 6970-6970/com.package.app.debug E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.package.app.data.model.user.User.Full
at androidx.navigation.NavType.fromArgType(NavType.java:180)
at androidx.navigation.NavInflater.inflateArgument(NavInflater.java:181)
at androidx.navigation.NavInflater.inflateArgumentForDestination(NavInflater.java:145)
at androidx.navigation.NavInflater.inflate(NavInflater.java:120)
at androidx.navigation.NavInflater.inflate(NavInflater.java:131)
at androidx.navigation.NavInflater.inflate(NavInflater.java:80)
... 41 more
Caused by: java.lang.ClassNotFoundException: com.package.app.data.model.user.User.Full
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at androidx.navigation.NavType.fromArgType(NavType.java:168)
... 46 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.package.app.data.model.user.User.Full" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/base.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_resources_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_5_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_6_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_7_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_8_apk.apk", zip file "/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 50 more
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.package.app.debug-7IobagfWCqi3XccTjnUgwg==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
2019-01-28 10:30:32.031 6970-6970/com.package.app.debug E/AndroidRuntime: at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
... 6 more
I have updated the Navigation Library component from alpha08 to alpha11. When they released alpha09, I also updated and had this same issue and thought it was a bug, so I waited. Now, the issue still persists and I can't seem to be able to figure out want went wrong.
I have already disabled ProGuard for debugging, as well as minify and have enabled Multidex to see if this would help.
debug {
minifyEnabled false
useProguard false
versionNameSuffix '-DEBUG'
applicationIdSuffix '.debug'
}
The class has also been added to the proguard-rules, to see if that would work.
-keep class com.package.app.data.model.** { *; }
As far as I'm concerned, this should work? Android Studio also generates the XML for me exactly like this.
Thanks in advance.
After all, it was a known bug in Android Studio.
Since the release of 1.0.0-alpha09, something changed in the way they handled inner classes.
If a parcelable is an inner class, it has to be written like:
com.domain.app.User$Full where Full is the parcelized object.
If you want to read more about this, check out this answer on Google's Issue Tracker: https://issuetracker.google.com/u/2/issues/123614632#comment4
Just faced problem similar to this issue and I got realized I didn't set up any proguard rules. Here's additional information that might be helpful.
The following codes are found in navigation component version 2.2.0-rc02.
// NavType.java
try {
String className;
if (type.startsWith(".") && packageName != null) {
className = packageName + type;
} else {
className = type;
}
if (type.endsWith("[]")) {
className = className.substring(0, className.length() - 2);
Class<?> clazz = Class.forName(className);
if (Parcelable.class.isAssignableFrom(clazz)) {
return new ParcelableArrayType(clazz);
} else if (Serializable.class.isAssignableFrom(clazz)) {
return new SerializableArrayType(clazz);
}
} else {
Class<?> clazz = Class.forName(className);
if (Parcelable.class.isAssignableFrom(clazz)) {
return new ParcelableType(clazz);
} else if (Enum.class.isAssignableFrom(clazz)) {
return new EnumType(clazz);
} else if (Serializable.class.isAssignableFrom(clazz)) {
return new SerializableType(clazz);
}
}
throw new IllegalArgumentException(className + " is not Serializable or "
+ "Parcelable.");
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
You can see it looks for classes using Class.forName(String) method. So keeping their names is enough.
# Instead of -keep
-keepnames class com.package.app.data.model.** { *; }
And if packageName is provided, you can omit package name from value of argType attribute, but sadly it won't work if you use some application id suffixes depending on build variants. (So do not omit package name from argType)
I had the same problem, my argType was the class that was the Subclass of the fragment. I moved that class out of the fragment and problem was fixed

Categories

Resources