Android flavor and resource files

I have a problem installing android gradle. In short, I created 2 flavors:

productFlavors{ abcDemoFree{ } abcDemo{ } } 

The Eeach flute has its own actions (Settings.java) and layout (settings_layout.xml) for this action. Both files were deleted from the main one, therefore Settings.java and settings_layout.xml exist only in aromas.

 abcDemoFree - java - Settings.java - res - settings_layout.xml abcDemo - java - Settings.java - res - settings_layout.xml 

Android Studio has created 4 build options:

 abcDemoFreeDebug abcDemoFreeRelease abcDemoDebug abcDemoRelease 

Everything works well, I can create an apk with the behavior that I expect from every fragrance. The problem is that when I switch to one buildVariant, for example, to abcDemoDebug, the android studio reports errors from the resource file in a different color, in my example from abcDemoFreeDegub / res / settings_layout.xml

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical" </LinearLayout> 

These lines

 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" 

generate errors: URI not registered.

How to get rid of these errors? Or maybe this is normal behavior?

+8
android gradle android-productflavors
source share
2 answers

Unfortunately, AndroidStudio uses resources due to the wrong taste when switching. You have to do a clean one and then build after switching the option to remove these errors.

0
source share

Errors occur if you do not actually change the build option. If you just look at the file, it will show errors, but if you really switch the assembly configuration and recreate, everything will be fine. Also confirm that you have not performed a specific implementation or compilation for flavors such as:

myFlavorImplementation android.libraries.forexample

since then the necessary libraries will be missing to clear the warning.

enter image description here

Use the build option to switch to other debug builds, and it should automatically recover, but if not, just rebuild yourself. Also make sure that you look at the actual files and not at the generated files, as sometimes if you use annotation tools or data binding to layout shells and you had the android tag in the layout and the first tag for posterity, this can lead to red as well as creating the final layout file to be packaged.

0
source share

All Articles