1

In my Android Studio project I got two almost identical xml layout. They are respectively in layout folder and layout-xlarge folder. The first as a TextView with Text "BBB" and the second is "AAA".

I deploy this on a xlarge device and the layout loaded is, correctly, the one with "AAA".

The problem comes here: I don't need the xlarge anymore, now they has to be the same layout. So I delete the one in the xlarge folder. I deploy the project on th xlarge and ... there is still "AAA", even if the layout does not exists anymore!

The deploy is successful, cause other modifications work. The XML is deleted, cause in the entire project the string "AAA" doesn't even exist.

I know it could be a device cache problem, but I would like to not delete App Data from the device, cause I have informations there and I would lose time if I restore them. Is there any other solution? And why it does this?

I tried:

  • Restarting Android Studio
  • Restarting PC
  • Restarting Device
  • Sync Project
  • Rebuild Project

[Sorry I cannot post code, but I don't see how it could be helpful: I deleted it from the project, so I don't think the problem could be there]

Simone Chelo
  • 706
  • 8
  • 25
  • Delete de app on your phone and then rebuild the project. – Reptar Oct 20 '14 at 14:53
  • That is exactly what I want to avoid – Simone Chelo Oct 20 '14 at 14:57
  • Oke, so you have deleted the xlarge file, and not replaced the xlarge.xml with the "normal" xml? – Reptar Oct 20 '14 at 15:00
  • Exactly. I think it should work, cause if there is not the layout in the right folder (layout-xlarge for xlarge devices, layout for normal devices ...) the application should use the more similar folder, in this case "layout". I already did this in my app in other circumstances. – Simone Chelo Oct 20 '14 at 15:04

2 Answers2

0

First of all: Be sure your XML's are valid. Even Strings and translations. It happens that AndroidStudio doesn't check XML before launch.

Use for example your terminal window with ./gradlew clean build command. Then resole every conflict if build Fails.

Then relaunch your application using the quick start button.

Other possible solution:

turn off the instant run and use the above solution.

as seen here in comments it could solve your problem too.

EDIT If above solution doesn't work. This one should ! But may take much more time. Use adb to install application.

  1. In Android Studio : Use ./gradlew clean build
  2. Open Terminal
  3. use adb to install newly created apk. ./adb install -r <path-to-apk>
  4. launch your app manually.
Community
  • 1
  • 1
Co.
  • 1
  • 3
0

I had the exact same problem check for a folder just below layout named layout-v21 or similar - this will be deployed and can be out of sync with the latest version of your XML,

I had isolated that the only part of my code not being deployed correctly was the XML, so if you are experiencing the same issue, then this might work - simple but problems like this are usually caused by things this dumb in places we don't realise are important.