Android App closing unexpectedly and giving following error in log-cat.
01-22 00:33:58.470 8193-8193/? E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
01-22 00:34:00.010 1173-1173/? E/MyTag: updateClock : 12:34
01-22 00:34:00.015 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.051 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.080 1432-1432/? E/ActionIcon: time changed: time = 20170122T003400Asia/Calcutta(0,21,19800,0,1485025440)
01-22 00:34:00.086 8210-8210/? E/Zygote: Zygote: error closing descriptor
libcore.io.ErrnoException: close failed: EBADF (Bad file number)
at libcore.io.Posix.close(Native Method)
at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:221)
at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879)
at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242)
at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:713)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:649)
at dalvik.system.NativeStart.main(Native Method)
For me the problem was the color-selector drawable which I used for the tint value of an ImageView. The crashes occured on API 19 (I assume it's on all devices API < 21).
Problematic code
<ImageView
android:id="#+id/icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:src="#drawable/ic_music_note_white_24dp"
android:tint="#color/color_bottom_navigation_item" />
color_bottom_navigation_item.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#00CCF0" android:state_selected="true" />
<item android:color="#75848C" />
</selector>
Solution
Remove the android:tint attribute from the XML and set it programatically like so:
ImageView icon = findViewById(R.id.icon);
ColorStateList tint = getResources().getColorStateList(R.color.color_bottom_navigation_item);
Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_music_note_white_24dp);
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTintList(drawable, tint);
icon.setImageDrawable(drawable);
Related
The solution given in this documentation page doesn't seem to be valid for androidx users(I think this because there is mention of android.support.v7.appcompat which isn't used by androidx users, right?). I might have gotten something wrong, but adding the: vectorDrawables.useSupportLibrary = true also the
static{
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
with the xml's app:srcCopmat:
<ImageButton
android:id="#+id/imageButton4"
android:layout_width="26dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton5"
app:layout_constraintEnd_toStartOf="#+id/imageButton5"
app:layout_constraintTop_toTopOf="#+id/imageButton5"
app:srcCompat="#drawable/sync" />
doesn't help. It simply crashes the app. The logcat reads:
file: /sys/class/power_supply/battery/hw_switch_point open error
E/dalvikvm(11099): Could not find class 'com.crashlytics.android.ndk.CrashlyticsNdk', referenced from method com.crashlytics.android.CrashlyticsInitProvider.ˊ
E/dalvikvm(11099): Could not find class 'dalvik.system.InMemoryDexClassLoader', referenced from method com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory.createInMemoryClassLoader
E/dalvikvm(11099): Could not find class 'com.facebook.ads.internal.dynamicloading.DynamicLoaderImpl', referenced from method com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory.doMakeLoader
E/dalvikvm(11099): Could not find class 'androidx.work.impl.background.systemjob.SystemJobService', referenced from method androidx.appcompat.view.ʖ.createBestAvailableBackgroundScheduler
E/dalvikvm(11099): Could not find class 'androidx.appcompat.view.ΐ$ˊ', referenced from method androidx.appcompat.view.ΐ.<init>
E/dalvikvm(11099): Could not find class 'android.graphics.BlendModeColorFilter', referenced from method androidx.appcompat.view.y40$if.ˊ
E/dalvikvm(11099): Could not find class 'android.graphics.BlendModeColorFilter', referenced from method androidx.appcompat.view.y40$if.ˋ
E/dalvikvm(11099): Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method androidx.appcompat.view.t40.ˊ
E/dalvikvm(11099): Could not find class 'dalvik.system.DelegateLastClassLoader', referenced from method x.a
E/dalvikvm(11099): Could not find class 'dalvik.system.DelegateLastClassLoader', referenced from method nj.a
E/dalvikvm(11099): Could not find class 'com.evozi.network.service.QSTileService', referenced from method androidx.appcompat.view.ᚁ.ˋ
E/dalvikvm(11099): Could not find class 'com.evozi.network.service.QSTileService', referenced from method androidx.appcompat.view.ᚁ.ˋ
E/dalvikvm(11099): Could not find class 'com.evozi.network.service.QSTileService', referenced from method androidx.appcompat.view.ᚁ.ᐝ
E/dalvikvm(11099): Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method com.facebook.ads.redexgen.X.OY.A09
E/dalvikvm(11099): Could not find class 'android.app.ActivityManager$AppTask', referenced from method com.facebook.ads.redexgen.X.NN.A02
E/FBAudienceNetwork(11099): You are using custom Application class and don't call AudienceNetworkAds.isInAdsProcess(). Multi-process support will be disabled. Please call AudienceNetworkAds.isInAdsProcess() if you want to support multi-process mode.
E/memtrack(11189): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug(11189): failed to load memtrack module: -2
E/PackageManager( 617): parse pkg : /data/app/vmdl-410864310.tmp
E/PackageManager( 617): dexopt start
E/Finsky (10651): [1] aabj.b(2): Package name null is not an installed package
E/PackageManager( 617): dexopt end
E/SamsungIME( 907): mOCRHelper is null
E/SamsungIME( 907): mOCRHelper is null
E/memtrack(11247): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug(11247): failed to load memtrack module: -2
E/jdwp (11287): Failed sending reply to debugger: Broken pipe
E/dalvikvm(11287): Could not find class 'androidx.core.view.ViewCompat$2', referenced from method androidx.core.view.ViewCompat.addOnUnhandledKeyEventListener
E/dalvikvm(11287): Could not find class 'android.view.WindowInsets', referenced from method androidx.core.view.ViewCompat.dispatchApplyWindowInsets
E/dalvikvm(11287): Could not find class 'android.view.WindowInsets', referenced from method androidx.core.view.ViewCompat.onApplyWindowInsets
E/dalvikvm(11287): Could not find class 'android.view.View$OnUnhandledKeyEventListener', referenced from method androidx.core.view.ViewCompat.removeOnUnhandledKeyEventListener
E/dalvikvm(11287): Could not find class 'androidx.core.view.ViewCompat$1', referenced from method androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener
E/AndroidRuntime(11287): FATAL EXCEPTION: main
E/AndroidRuntime(11287): Process: com.makeit.www, PID: 11287
E/AndroidRuntime(11287): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.makeit.www/com.makeit.www.StartupSetup.LogoAnimation}: android.view.InflateException: Binary XML file line #13: Error inflating class ImageView
E/AndroidRuntime(11287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
E/AndroidRuntime(11287): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)
E/AndroidRuntime(11287): at android.app.ActivityThread.access$800(ActivityThread.java:155)
E/AndroidRuntime(11287): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
E/AndroidRuntime(11287): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(11287): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(11287): at android.app.ActivityThread.main(ActivityThread.java:5433)
E/AndroidRuntime(11287): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(11287): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(11287): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
E/AndroidRuntime(11287): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
E/AndroidRuntime(11287): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(11287): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class ImageView
E/AndroidRuntime(11287): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:720)
E/AndroidRuntime(11287): at android.view.LayoutInflater.rInflate(LayoutInflater.java:762)
E/AndroidRuntime(11287): at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
E/AndroidRuntime(11287): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
E/AndroidRuntime(11287): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
E/AndroidRuntime(11287): at com.makeit.www.StartupSetup.LogoAnimation.onCreate(LogoAnimation.java:22)
E/AndroidRuntime(11287): at android.app.Activity.performCreate(Activity.java:5301)
E/AndroidRuntime(11287): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
E/AndroidRuntime(11287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2291)
E/AndroidRuntime(11287): ... 11 more
E/AndroidRuntime(11287): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_launcher_background.xml from drawable resource ID #0x7f060064
E/AndroidRuntime(11287): at android.content.res.Resources.loadDrawable(Resources.java:3451)
E/AndroidRuntime(11287): at android.content.res.TypedArray.getDrawable(TypedArray.java:614)
E/AndroidRuntime(11287): at android.widget.ImageView.<init>(ImageView.java:134)
E/AndroidRuntime(11287): at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
E/AndroidRuntime(11287): at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:187)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)
E/AndroidRuntime(11287): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
E/AndroidRuntime(11287): ... 21 more
E/AndroidRuntime(11287): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag vector
E/AndroidRuntime(11287): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:969)
E/AndroidRuntime(11287): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:913)
E/AndroidRuntime(11287): at android.content.res.Resources.loadDrawable(Resources.java:3447)
E/AndroidRuntime(11287): ... 30 more
E/android.os.Debug( 617): !#Dumpstate > sdumpstate -k -t -z -d -m 11287 -o /data/log/dumpstate_app_error
E/dalvikvm(11371): Could not find class 'android.app.job.JobScheduler', referenced from method com.sec.android.app.samsungapps.SamsungApps.b
E/dalvikvm(11371): Could not find class 'android.app.NotificationChannel', referenced from method com.sec.android.app.samsungapps.vlibrary.concreteloader.Common.getGeneralNotificationChannel
E/dalvikvm(11371): Could not find class 'android.app.NotificationChannel', referenced from method com.sec.android.app.samsungapps.vlibrary.concreteloader.Common.getPromotionNotificationChannel
E/dalvikvm(11371): Could not find class 'android.app.NotificationChannel', referenced from method com.sec.android.app.samsungapps.vlibrary.concreteloader.Common.getRewardsNotificationChannel
E/dalvikvm(11371): Could not find class 'android.app.NotificationChannel', referenced from method com.sec.android.app.samsungapps.vlibrary.concreteloader.Common.getUpdateNotificationChannel
E/Watchdog( 617): !#Sync 380
E/ActivityThread(11371): Failed to find provider info for null
E/ActivityThread(11371): Failed to find provider info for com.sec.android.app.clockpackage.celebvoice
E/[SAUI] (11371): Firebase initialize is success
E/SPPClientService(11407): ShipBuild Binary : True
E/SPPClientService(11407): [PackageInfoChangeReceiver] android.intent.action.PACKAGE_REMOVED
E/SPPClientService(11407): [PackageInfoChangeReceiver] [handlePkgRemovedEvent] PackageName : com.makeit.www, true, false
E/SPPClientService(11407): [PackageInfoChangeReceiver] [handlePkgRemovedEvent] Ignore Replacing case
So a little run down on how to use the vectorDrawables(or simply vector images) for androidx users for versions under Lollipop would be a huge help.
EDIT: XML layout file is:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Main.MainScreenActivity">
<LinearLayout
android:id="#+id/Toolbar_holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
>
<androidx.appcompat.widget.Toolbar
android:id="#+id/app_toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/actionBarSize"
android:textSize="#dimen/actionBarTextSize"
android:background="#color/colorPrimary">
</androidx.appcompat.widget.Toolbar>
<View
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#drawable/shadow_top_to_down" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/C_makeControlMain"
android:layout_width="0dp"
android:layout_height="227dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/C_makeControlHeader"
android:layout_width="0dp"
android:layout_height="46dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/fileTitle"
android:layout_width="170dp"
android:layout_height="21dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:text="#string/fileTitle"
app:layout_constraintEnd_toStartOf="#+id/imageButton3"
app:layout_constraintStart_toEndOf="#+id/imageButton2"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="34dp"
android:layout_height="29dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/add_new_information" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="35dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton"
app:layout_constraintStart_toEndOf="#+id/imageButton"
app:layout_constraintTop_toTopOf="#+id/imageButton"
app:srcCompat="#drawable/save_information" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="#string/artist_name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/fileTitle"
app:layout_constraintHorizontal_bias="0.513"
app:layout_constraintStart_toStartOf="#+id/fileTitle"
app:layout_constraintTop_toBottomOf="#+id/fileTitle" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="28dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton4"
app:layout_constraintEnd_toStartOf="#+id/imageButton4"
app:layout_constraintTop_toTopOf="#+id/imageButton4"
app:srcCompat="#drawable/add_normal_browser" />
<ImageButton
android:id="#+id/imageButton4"
android:layout_width="26dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton5"
app:layout_constraintEnd_toStartOf="#+id/imageButton5"
app:layout_constraintTop_toTopOf="#+id/imageButton5"
app:srcCompat="#drawable/sync_browsers" />
<ImageButton
android:id="#+id/imageButton5"
android:layout_width="29dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageButton2"
app:srcCompat="#drawable/add_singalong_browser" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
The error is actually quite logical, and one who is much familiar with reading the logcat would've found it in 5 minute.
After you enable using the vector using the vectorDrawables.useSupportLibrary = true you have to henceforth reference all the vector images using app:srcCompat= #drawable/xyz, if any of your xml files use instead android:src="#drawable/vector then the app would crash as shown above.
Side note: The solution was as mentioned in the doc also for androidx users, just to be clear.
i am having trouble with the facebook sdk. I use Intellij Idea, and I managed to add the sdk to the project and at least getting it compiled.
So I start with a blank project with a single activity and i add a LoginButton so that my Layout.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, MainActivity"
/>
<com.facebook.widget.LoginButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
The first problem is, I get this message at the UI preview window:
android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F060006.
at android.content.res.BridgeResources.throwException(BridgeResources.java:693)
at android.content.res.BridgeResources.getColor(BridgeResources.java:185)
at com.facebook.widget.LoginButton.<init>(LoginButton.java:237)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:375)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:100)
at com.android.tools.idea.rendering.ProjectCallback.loadView(ProjectCallback.java:169)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:399)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:564)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:553)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:553)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:626)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:575)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:81)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:521)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:516)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
So it looks like there is trouble with the R file, but, anyways, it still compiles.
As soon as the app runs on the emulator, it crashes with this stack:
05-02 19:15:35.073 2023-2023/com.Jam D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
05-02 19:15:35.453 2023-2029/com.Jam D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
05-02 19:15:36.014 2023-2023/com.Jam D/﹕ HostConnection::get() New Host Connection established 0xb91d7290, tid 2023
05-02 19:15:36.514 2023-2023/com.Jam W/EGL_emulation﹕ eglSurfaceAttrib not implemented
05-02 19:15:36.564 2023-2023/com.Jam D/OpenGLRenderer﹕ Enabling debug mode 0
05-02 19:15:36.644 2023-2036/com.Jam W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0xb1d8cb20)
05-02 19:15:36.644 2023-2036/com.Jam E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.Jam, PID: 2023
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
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:841)
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:911)
at com.facebook.internal.Utility.queryAppSettings(Utility.java:372)
at com.facebook.widget.LoginButton$1.doInBackground(LoginButton.java:667)
at com.facebook.widget.LoginButton$1.doInBackground(LoginButton.java:664)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
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:841)
I am new to Android so I have no clue what to do. I mean, my code will throw all sorts of exceptions :p but I have no clue as I why facebook SDK code would throw a null exception.
I was also facing same problem:
I was putting my app id as this:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="MY_APP_ID"/>
but what it should have been:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
I never thought this could create such an error. They should put this as warning in their tutorial I guess!
Give it a try. If this is not the solution then it should be something related to App ID. You might not have added keyhash to your app. Follow each step in this tutorial and don't skip any.
If it still doesn't solve the problem compare facebook related with facebook samples packed with the SDK.
Good Luck!
I faced this same problem some time back and for me the problem had to do with wrong meta data name. Make sure you get it right.
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
instead of
<meta-data android:name="com.facebook.sdk.Application" android:value="#string/facebook_app_id"/>
on our app, with more than half a million downloads I've seeing from Google Play reports the following stack trace:
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/trans_button_bg.xml from drawable resource ID #0x7f02020b
at android.content.res.Resources.loadDrawable(Resources.java:1961)
at android.content.res.TypedArray.getDrawable(TypedArray.java:653)
at android.view.View.<init>(View.java:1961)
at android.widget.TextView.<init>(TextView.java:458)
at android.widget.Button.<init>(Button.java:108)
at android.widget.Button.<init>(Button.java:104)
... 38 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/transdark_active.9.png from drawable resource ID #0x7f02020c
at android.content.res.Resources.loadDrawable(Resources.java:2008)
at android.content.res.Resources.getDrawable(Resources.java:601)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
at android.content.res.Resources.loadDrawable(Resources.java:1936)
... 43 more
Caused by: java.io.FileNotFoundException: res/drawable-hdpi/transdark_active.9.png
at android.content.res.AssetManager.openNonAssetNative(Native Method)
at android.content.res.AssetManager.openNonAsset(AssetManager.java:409)
at android.content.res.Resources.loadDrawable(Resources.java:1970)
... 48 more
for me, it seems to say that it tried to load drawable/trans_button_bg.xml which is a simple selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="#drawable/transdark_active" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="#drawable/transdark_active" /> <!-- focused -->
<item android:drawable="#drawable/trans_button" /> <!-- default -->
</selector>
that calls the 9 patch transdark_active.9.png that is available on mdpi, hdpi and xhdpi:
that's just an example, stack, as I have other similar stacks for other assets failing to load.
The device breakdown for this error report is:
Galaxy S4 (jflte) 66.7%
Galaxy S2 (GT-I9100) 13.3%
Galaxy Note II (t03g) 6.7%
Galaxy S2 Plus (s2vep) 6.7%
Desire HD (ace)
so my question:
Is it Samsung screwing up as usual, or am I missing something on the code?
Ok, that's weird.
I've received this error for one of my activities, the weird thing is that the bitmap is used in every Activity! I don't even know how to reproduce the exception, it's working fine for me (and others I think).
This is the whole stacktrace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{it.enrichman.bolloauto/it.enrichman.bolloauto.activities.ArchivioActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1872)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4385)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.ListView
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
at android.app.Activity.setContentView(Activity.java:1742)
at it.enrichman.bolloauto.activities.ArchivioActivity.onCreate(ArchivioActivity.java:36)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.view.LayoutInflater.createView(LayoutInflater.java:505)
... 22 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/backrepeat.xml from color state list resource ID #0x7f020075
at android.content.res.Resources.loadColorStateList(Resources.java:1855)
at android.content.res.TypedArray.getColor(TypedArray.java:319)
at android.widget.AbsListView.<init>(AbsListView.java:632)
at android.widget.ListView.<init>(ListView.java:164)
at android.widget.ListView.<init>(ListView.java:160)
... 25 more
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag bitmap
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:146)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:129)
at android.content.res.Resources.loadColorStateList(Resources.java:1852)
... 29 more
The "missing" resource is this one (inside drawable folder):
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/bg"
android:tileMode="repeat" />
The "bg" drawable is inside drawable-hdpi (could be that a problem?), but as I said it's used in every activity as background!
The error is called during the setting of the layout:
setContentView(R.layout.archivio);
The xml layout is this one:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BLABLABLA"
android:id="#+id/archivioTextView" android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" android:textIsSelectable="false" android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" android:layout_marginRight="30dp" android:layout_marginLeft="30dp"/>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/listaVeicoli" android:layout_gravity="center" android:drawSelectorOnTop="false"/>
</LinearLayout>
(Some of the useless statements are put by the Designer of IntelliJ!)
I've looked for similar problems but I don't have "strange" id like #+id/list or other problems that other users encuntered..
Any help on this? What am I missing?
Thanks
In the end I've found FINALLY the solution.
I've tried with different emulator and I was having this crash only with API 10 (2.3.3) or less. Looking around the xmls and trying to do different stuff (also copying the bg drawable everywhere, or changing id to my list) I've found this weird stuff in my custom theme:
<item name="android:windowBackground">#drawable/backrepeat</item>
<item name="android:colorBackground">#drawable/backrepeat</item>
This seems to be not a problem for newer android version but for older one yes.
Just remove the colorBackground definition (that maybe should be only a color) and that's it!
I hope this will help someone else!
Create a drawable folder inside res folder.
Try keeping your bg inside "res/drawable/".
Hope this will help you.
Put your selector into the res/drawable folder and also give the Listview id as android:id="#+android:id/list".
I hope it will help you out.
Thanks.
I have a TabActivity that seems to be dieing on a small set of phones when I add the Drawable to it. From the reports, the same tab code ran successfully at one point, but suddenly stopped during one launch(usually via pending intent)
The code thats executing in onCreate is this
spec = theTtabHost.newTabSpec(STATS_TAG).setIndicator(getText(R.string.statsTab),
res.getDrawable(R.drawable.ic_tab_stats))
The stack trace I receive is here
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.Main}: android.content.res.Resources$NotFoundException: File res/drawable/ic_tab_stats.xml from drawable resource ID #0x7f020013
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2737)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2753)
at android.app.ActivityThread.access$2500(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2107)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_tab_stats.xml from drawable resource ID #0x7f020013
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.Resources.getDrawable(Resources.java:590)
at com.test.Main.onCreate(Main.java:162)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2701)
... 11 more
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 15 more
The ic_tab_stats.xml file is in drawable, and is here.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/stats"
android:state_selected="true" />
<item android:drawable="#drawable/stats_deselect" />
</selector>
The stats.png and stats_deselect.png are peers inside drawable. hdpi and ldpi do not have either file, and mdpi is empty. My app supports back to 1.5, so I used drawable instead of mdpi.
From the reports, it seems to be pretty random.
Turns out this is sort of normal behavior on Android upgrades.