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()
}
Related
I'm using build tools 30.0.3 and API level 30, with multidex enabled and imported in gradle
I have an Activity which is declared in my manifest like so
<activity
android:name="com.weare8.android.ui.sponsorHub.watchAndRespond.AWatchAndRespondCongrats"
android:screenOrientation="portrait"
android:theme="#style/App8Theme.noActionBar"/>
And specify the same class at the top of the Activity's file:
package com.weare8.android.ui.sponsorHub.watchAndRespond
I then have a method called "initData" that is called in the Activity's onResume method. The app crashes when it is called with the following stack trace:
2021-03-09 13:35:30.362 25909-25909/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.eight.app.stg, PID: 25909
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/weare8/android/ui/sponsorHub/watchAndRespond/AWatchAndRespondCongrats$initData$1$1;
at com.weare8.android.ui.sponsorHub.watchAndRespond.AWatchAndRespondCongrats.initData(AWatchAndRespondCongrats.kt:71)
at com.weare8.android.ui.sponsorHub.watchAndRespond.AWatchAndRespondCongrats.onResume(AWatchAndRespondCongrats.kt:51)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456)
at android.app.Activity.performResume(Activity.java:8135)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4428)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4470)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7660)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.weare8.android.ui.sponsorHub.watchAndRespond.AWatchAndRespondCongrats$initData$1$1" on path: DexPathList[[zip file "/data/app/~~VZbIKt-wdKVMzrVi50UpkQ==/com.eight.app.stg-NFHvGS3I4QjJpJmMcbLfLw==/base.apk"],nativeLibraryDirectories=[/data/app/~~VZbIKt-wdKVMzrVi50UpkQ==/com.eight.app.stg-NFHvGS3I4QjJpJmMcbLfLw==/lib/arm64, /data/app/~~VZbIKt-wdKVMzrVi50UpkQ==/com.eight.app.stg-NFHvGS3I4QjJpJmMcbLfLw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.weare8.android.ui.sponsorHub.watchAndRespond.AWatchAndRespondCongrats.initData(AWatchAndRespondCongrats.kt:71)
at com.weare8.android.ui.sponsorHub.watchAndRespond.AWatchAndRespondCongrats.onResume(AWatchAndRespondCongrats.kt:51)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456)
at android.app.Activity.performResume(Activity.java:8135)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4428)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4470)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7660)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Invalidate cache/Restart does not work, deleting the .idea folder does not work, Clean/rebuild project does not work. I've seen this error before but not for a specific method. I have no idea why this stopped working, seemingly spontaneously. What else can I try?
Edit: crashing method:
private fun initData(offer: WatchAndRespondOffer) = with (offer) {
Interactors.preferences.removedCachedOffer(offer.campaignId!!)
if (!offer.linkToProductOrDiscountIncentive?.shortInstruction.isNullOrEmpty()) {
offerTv.visibility = View.VISIBLE
offerTv.text = offer.linkToProductOrDiscountIncentive?.shortInstruction
}
val imageToBeDisplayed = if (!offer.ctaImageUri.isNullOrEmpty()) {
offer.ctaImageUri
} else {
offer.coverTileUri
}
if (cashIncentive != null && charityDonationIncentive != null) {
title_description.setText(R.string.watch_and_respond_congrats_description)
title_first.show()
title_second.show()
} else if (charityDonationIncentive != null) {
title_second.hide()
title_first.setText(R.string.watch_and_respond_congrats_title_charity)
title_description.setText(R.string.watch_and_respond_congrats_donation_description)
} else if (cashIncentive != null) {
title_second.hide()
title_first.setText(R.string.watch_and_respond_congrats_title_cash)
title_description.setText(R.string.watch_and_respond_congrats_description)
}
val isUnite = offer.isUniteIncentive?: false
if (isUnite){
title_first.hide()
title_second.hide()
title_description.hide()
wellDoneTv.show()
} else{
wellDoneTv.hide()
}
setupLinkIncentive(offer)
Glide.with(applicationContext).asBitmap().load(imageToBeDisplayed).into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
val width = Resources.getSystem().displayMetrics.widthPixels - 40
val widthRatio = resource.width
val heightRatio = resource.height.toFloat()
val height = ((width.toFloat() / widthRatio.toFloat()) * heightRatio).toInt()
tileIv.layoutParams.height = height
Glide.with(applicationContext).load(imageToBeDisplayed).apply(RequestOptions().override(width, height).skipMemoryCache(true)).into(tileIv)
}
})
}
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
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();
I am downloading an mp3 file using service and saving it to sdcard/download directory. It is working fine but after downloading I cant open the file.
There is a toast that shows cannot open the file. I thought there was something wrong with the code but when I tried with jpg file it was fine .
This is my code
public int onStartCommand(Intent intent, int flags, int startId) {
urls=intent.getExtras().get("URL").toString();
DownloadManager.Request request=new DownloadManager.Request(Uri.parse(urls));
request.setTitle("Notification").setDescription("song");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalFilesDir(getApplicationContext(),directory,"downloadedSong.mp3");
FilePermission filePermission=new FilePermission(directory,"read");
PermissionCollection collection=filePermission.newPermissionCollection();
collection.add(filePermission);
FilePermission filePermission1=new FilePermission(directory,"write");
collection=filePermission1.newPermissionCollection();
collection.add(filePermission1);
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);
return START_STICKY;
Can anybody help me please?
-20 13:46:15.533 1435-1463/system_process E/KernelCpuSpeedReader: Failed to read cpu-freq
java.io.FileNotFoundException: /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at java.io.FileReader.<init>(FileReader.java:66)
at com.android.internal.os.KernelCpuSpeedReader.readDelta(KernelCpuSpeedReader.java:49)
at com.android.internal.os.BatteryStatsImpl.updateCpuTimeLocked(BatteryStatsImpl.java:8002)
at com.android.server.am.BatteryStatsService.updateExternalStats(BatteryStatsService.java:1366)
at com.android.server.am.BatteryStatsService$BatteryStatsHandler.handleMessage(BatteryStatsService.java:125)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at java.io.FileReader.<init>(FileReader.java:66)
at com.android.internal.os.KernelCpuSpeedReader.readDelta(KernelCpuSpeedReader.java:49)
at com.android.internal.os.BatteryStatsImpl.updateCpuTimeLocked(BatteryStatsImpl.java:8002)
at com.android.server.am.BatteryStatsService.updateExternalStats(BatteryStatsService.java:1366)
at com.android.server.am.BatteryStatsService$BatteryStatsHandler.handleMessage(BatteryStatsService.java:125)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
09-20 13:46:15.534 1435-1463/system_process E/KernelUidCpuTimeReader: Failed to read uid_cputime
java.io.FileNotFoundException: /proc/uid_cputime/show_uid_stat: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:452)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at java.io.FileReader.<init>(FileReader.java:66)
at com.android.internal.os.KernelUidCpuTimeReader.readDelta(KernelUidCpuTimeReader.java:71)
at com.android.internal.os.BatteryStatsImpl.updateCpuTimeLocked(BatteryStatsImpl.java:8031)
at com.android.server.am.BatteryStatsService.updateExternalStats(BatteryStatsService.java:1366)
at com.android.server.am.BatteryStatsService$BatteryStatsHandler.handleMessage(BatteryStatsService.java:125)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:438)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at java.io.FileReader.<init>(FileReader.java:66)
at com.android.internal.os.KernelUidCpuTimeReader.readDelta(KernelUidCpuTimeReader.java:71)
at com.android.internal.os.BatteryStatsImpl.updateCpuTimeLocked(BatteryStatsImpl.java:8031)
at com.android.server.am.BatteryStatsService.updateExternalStats(BatteryStatsService.java:1366)
at com.android.server.am.BatteryStatsService$BatteryStatsHandler.handleMessage(BatteryStatsService.java:125)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
09-20 13:46:15.534 1435-1463/system_process E/KernelWakelockReader: neither /proc/wakelocks nor /d/wakeup_sources exists
Try to add this: request.setMimeType("audio/MP3");
I've been trying to use Firebase's storage libraries to attempt to upload a file using Google's sample code in Android Studio:
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://<your-bucket-name>");
UUID imageID = UUID.randomUUID();
StorageReference pendingImageRef = storageRef.child("products/images/"+imageID);
UploadTask uploadTask = pendingImageRef.putBytes(imageData);
....
Which gave me this:
java.lang.NoClassDefFoundError:
Failed resolution of: Lcom/google/firebase/storage/FirebaseStorage;
at com.myprogram.CreateProductFragment$1.onClick(CreateProductFragment.java:304)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:702)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.storage.FirebaseStorage" on path: ....
My thinking was that this was an issue with dexing, so I rejiggered it and multidexed the application. This did not eliminate the issue.