Android Tutorial Adaptive Icons

Erel

Administrator
Staff member
Licensed User
Starting from Android 8 apps should include an adaptive icon. Without it the icon will appear as a small icon inside the larger template:



(B4A designer still uses an older targetSdkVersion so it is not affected.)

Adaptive icons are explained here: https://medium.com/google-design/designing-adaptive-icons-515af294c783

The steps required are:

1. Create a folder under Objects\res named mipmap. It should include three files:



The two adaptive icon layers and a file named ic_launcher.png with the old icon. The old icon will be used on Android 7- devices.

2. Make sure that all three files are read-only. Otherwise they will be deleted during compilation.

3. Add to the manifest editor:

B4X:
SetApplicationAttribute(android:icon, "@mipmap/ic_launcher")
CreateResource(mipmap-anydpi-v26, ic_launcher.xml,
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@mipmap/background"/>
    <foreground android:drawable="@mipmap/foreground"/>
</adaptive-icon>
)
4. Delete this line from the manifest editor:
B4X:
SetApplicationAttribute(android:icon, "@drawable/icon") 'delete
 

derez

Expert
Licensed User
Not working for me (b4a 7.3)
Logger connected to: Google Pixel
--------- beginning of main
--------- beginning of crash
java.lang.RuntimeException: Unable to start activity ComponentInfo{dudu.freecell/dudu.freecell.main}: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030000
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030000
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from drawable resource ID #0x7f030000
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.Context.getDrawable(Context.java:605)
at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:742)
at com.android.internal.policy.PhoneWindow.setDefaultIcon(PhoneWindow.java:1756)
at android.app.Activity.initWindowDecorActionBar(Activity.java:2655)
at android.app.Activity.setContentView(Activity.java:2690)
at dudu.freecell.main.onCreate(main.java:59)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from xml type drawable resource ID #0x7f030000
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1163)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:805)
... 23 more
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:546)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1148)
... 24 more
java.lang.RuntimeException: Unable to start activity ComponentInfo{dudu.freecell/dudu.freecell.main}: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030000
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030000
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from drawable resource ID #0x7f030000
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.Context.getDrawable(Context.java:605)
at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:742)
at com.android.internal.policy.PhoneWindow.setDefaultIcon(PhoneWindow.java:1756)
at android.app.Activity.initWindowDecorActionBar(Activity.java:2655)
at android.app.Activity.setContentView(Activity.java:2690)
at dudu.freecell.main.onCreate(main.java:59)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from xml type drawable resource ID #0x7f030000
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1163)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:805)
... 23 more
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:546)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1148)
... 24 more
java.lang.RuntimeException: Unable to start activity ComponentInfo{dudu.freecell/dudu.freecell.main}: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030000
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030000
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from drawable resource ID #0x7f030000
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.Context.getDrawable(Context.java:605)
at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:742)
at com.android.internal.policy.PhoneWindow.setDefaultIcon(PhoneWindow.java:1756)
at android.app.Activity.initWindowDecorActionBar(Activity.java:2655)
at android.app.Activity.setContentView(Activity.java:2690)
at dudu.freecell.main.onCreate(main.java:59)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from xml type drawable resource ID #0x7f030000
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1163)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:805)
... 23 more
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:546)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1148)
... 24 more
java.lang.RuntimeException: Unable to start activity ComponentInfo{dudu.freecell/dudu.freecell.main}: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030000
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030000
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from drawable resource ID #0x7f030000
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.Context.getDrawable(Context.java:605)
at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:742)
at com.android.internal.policy.PhoneWindow.setDefaultIcon(PhoneWindow.java:1756)
at android.app.Activity.initWindowDecorActionBar(Activity.java:2655)
at android.app.Activity.setContentView(Activity.java:2690)
at dudu.freecell.main.onCreate(main.java:59)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from xml type drawable resource ID #0x7f030000
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1163)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:805)
... 23 more
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:546)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1148)
... 24 more
java.lang.RuntimeException: Unable to start activity ComponentInfo{dudu.freecell/dudu.freecell.main}: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030002
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030002
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from drawable resource ID #0x7f030002
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.Context.getDrawable(Context.java:605)
at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:742)
at com.android.internal.policy.PhoneWindow.setDefaultIcon(PhoneWindow.java:1756)
at android.app.Activity.initWindowDecorActionBar(Activity.java:2655)
at android.app.Activity.setContentView(Activity.java:2690)
at dudu.freecell.main.onCreate(main.java:59)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from xml type drawable resource ID #0x7f030002
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1163)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:805)
... 23 more
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:546)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1148)
... 24 more
java.lang.RuntimeException: Unable to start activity ComponentInfo{dudu.freecell/dudu.freecell.main}: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030002
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030002
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from drawable resource ID #0x7f030002
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.Context.getDrawable(Context.java:605)
at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:742)
at com.android.internal.policy.PhoneWindow.setDefaultIcon(PhoneWindow.java:1756)
at android.app.Activity.initWindowDecorActionBar(Activity.java:2655)
at android.app.Activity.setContentView(Activity.java:2690)
at dudu.freecell.main.onCreate(main.java:59)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from xml type drawable resource ID #0x7f030002
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1163)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:805)
... 23 more
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:546)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1148)
... 24 more
java.lang.RuntimeException: Unable to start activity ComponentInfo{dudu.freecell/dudu.freecell.main}: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030002
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030002
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from drawable resource ID #0x7f030002
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
at android.content.res.Resources.getDrawable(Resources.java:819)
at android.content.Context.getDrawable(Context.java:605)
at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:742)
at com.android.internal.policy.PhoneWindow.setDefaultIcon(PhoneWindow.java:1756)
at android.app.Activity.initWindowDecorActionBar(Activity.java:2655)
at android.app.Activity.setContentView(Activity.java:2690)
at dudu.freecell.main.onCreate(main.java:59)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from xml type drawable resource ID #0x7f030002
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1163)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:805)
... 23 more
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:546)
at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1148)
... 24 more
 

DonManfred

Expert
Licensed User
Not working for me
You are running it on which android Version (Device)?
1. Create a folder under Objects\res named mipmap. It should include three files:



The two adaptive icon layers and a file named ic_launcher.png with the old icon. The old icon will be used on Android 7- devices.

2. Make sure that all three files are read-only. Otherwise they will be deleted during compilation.
Are the files set to readonly? Means; check if they are still there (if not set to readonly they are removed at compilation).
 

wimpie3

Well-Known Member
Licensed User
Any idea on the recommended sizes in pixels for those three files? The YouTube clip talks about DP, not pixels.
 

derez

Expert
Licensed User
You are running it on which android Version (Device)?
Are the files set to readonly? Means; check if they are still there (if not set to readonly they are removed at compilation).
Device is Pixel (8) and the files are read-only.
You should also make sure that the referenced android.jar (Tools - Configure Paths) is from platform v27+.
It was on android 25. I'll check with 27.
 

derez

Expert
Licensed User
Still not working, it looks for the standard drawable:
java.lang.RuntimeException: Unable to start activity ComponentInfo{dudu.freecell/dudu.freecell.main}: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030002
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: Drawable dudu.freecell:mipmap/ic_launcher with resource ID #0x7f030002
Caused by: android.content.res.Resources$NotFoundException: File res/mipmap-anydpi-v26/ic_launcher.xml from drawable resource ID #0x7f030002
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
...
If I put back the deleted line from the manifest - it works but with the previous icon.
 

eps

Well-Known Member
Licensed User
I couldn't get this working initially, but have now finally been able to set up an Adaptive icon. It was painful!

I had to remove lots of old android sdk installations which I wasn't referencing but somehow were playing havoc with this part of creating Android Apps. Everything else was working as expected and I had no other problems - just thought I'd share this info. with others just in case they were feeling it wasn't working but should. I used the example app to work out that it should perform as expected but wasn't doing so. Cheers :)
 

RichardN

Active Member
Licensed User
My lead Android development device a Samsung S9+ has just updated to the latest Oreo version. There was previously a dialogue accessible from Home Screen > Home Screen Settings > Change Icon Shape. It now appears to have been removed completely. I agree with others in saying this is a retrograde step.

Previously:
 
Last edited:
Top