1

EDIT AT THE END

I was trying to implement a SplashScreen following this guideline. So I'm setting a drawable with a layer-list and using an icon, but the icon is too big so I make a new file that's smaller. The result never showed up in my app: the first drawable I made is always showing up, never updating.

  • I renamed the picture file, the drawable
  • I renamed the style that's used in the manifest
  • I cleaned the project
  • I rebuilt the project
  • I synchroinized
  • I used the Invalidate cache/restart option
  • I updated Android Studio
  • I moved my project folder, created a new one and copy-pasted only the java and xml files because I thougt then the cache files would be deleted

Nada, the old drawable is always showing when I deploy the apk on my phone. What is this, whichcraft? What am I missing? Where do I find the cache? I looked for a bin folder, I read on some forums I should delete it but it's not in my workspace.

I'm posting my code below:

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="lu.intech.mcfc">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".activity.InitActivity"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".activity.LoginActivity" />
    </application>
</manifest>

styles.xml:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_screen</item>
    </style>
</resources>

splash_screen.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@color/colorPrimary"/>

    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/logo_wega_100x31"/>
    </item>
</layer-list>

EDIT I did try my app on another phone and it worked as intended straight away. So I'm guessing the problem lies on the phone. Even if I uninstalled the app everytime I tested again, the old drawable was shown. What more than uninstalling the app can I do to clean the cache on the phone?

Gaetan L.
  • 649
  • 6
  • 20

4 Answers4

2

I face the same problem but I guess it relates to Android Version. I tested in a Samsung phone (Android 4.4.4) and windowBackground is updated immediately, but in a Sony phone (Android 7.0) it's not working.
Seems like Android is trying to be "smarter" by saving some states of applications. I did try all solutions that you tried, plus: via Application Manager -> Clear Cache, Clear Data. And... it's still not working.
Only one thing make it work: restart the device and then rebuild.
Yep, I'm not sure if user can face that problem when update our apps via Play Store. It's not convenience but it's only working solution that I found.

Phong Nguyen
  • 6,897
  • 2
  • 26
  • 36
1

you need to clean out the system caches:

  1. On the main menu, choose File | Invalidate Caches/Restart. The Invalidate Caches message appears informing you that the caches will be invalidated and rebuilt on the next start. Use buttons in the dialog to invalidate caches, restart IntelliJ IDEA or both.
  2. Application uninstall on your phone
  3. Run project again.
Muhammad Waleed
  • 2,517
  • 4
  • 27
  • 75
0

First, try to clean you app then rebuild and relaunch it.

If not working, try to clean, uninstall on your phone, rebuild, then launch it again. Sometime when launching without cleaning some strange bugs appears.

Feuby
  • 708
  • 4
  • 7
0

Cf. another similar problem I had: Android status bar hide/change color in splash screen

It's not the first time I have a cache problem with that kind of screen, it must be the particular condition of having no layout and a drawable as a background. I tried invalidating the cache in Android Studio, I cleaned and rebuilt the project, I uninstalled the app on the phone but nothing works. So if you are in this cofiguration, just try to run your app on another phone if you can, just to check that your solution isn't already working, just not updating on your device.

Gaetan L.
  • 649
  • 6
  • 20