i'm trying to build a layer-list of 2 images and to see it in the Graphical layout in eclipse in order to see that it came correctly...
for some reason i get an error
this is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="50dp"
android:layout_height="50dp">
<item android:drawable="#drawable/picuser"
android:layout_width="50dp"
android:layout_height="50dp"/>
<item android:drawable="#drawable/ic_launcher"
android:layout_width="50dp"
android:layout_height="50dp"/>
</layer-list>
this is my error:
NOTE: This project contains Java compilation errors, which can cause rendering failures
for custom views. Fix compilation problems first.
com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- item (Fix Build Path, Edit XML)
- layer-list (Fix Build Path, Edit XML)
Related
I'm looking to simply added a splash screen to my Android app built in Flutter. I want a red screen with an image in the centre. I have the following in Android:
color.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name = "crimson">#D272638</color>
</resources>
launch_background.xml:
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/crimson" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/logo" />
</item>
</layer-list>
My file structure is as follows:
Every time I try run the app I get the following error:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
path-to-app/android/app/src/main/res/values/colors.xml:3:5-43: AAPT: error: invalid color.
path-to-app/build/app/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml: AAPT: error: file failed to compile.
Why would creating a color for a splash screen crash and app?
For the next soul that finds themselves stuck in this situation, the problem I experienced above was because I was using capital letters in my colors.xml file. Just make all the characters lower case and you are good to go.
Couldn't resolve resource #id/visible when using TextInputLayout on appcompat-v7:25.x.x
Tried these steps below, but the problem is still persist:
Rebuild Project
Clean and Rebuild Project
Clear Cache and
Restart Android Studio
Below is the code in the layout file.
<android.support.design.widget.TextInputLayout
android:id="#+id/tilFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/etFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/first_name"
android:inputType="textPersonName"/>
</android.support.design.widget.TextInputLayout>
Below is the message displayed in Android Studio
Rendering Problems.
Couldn't resolve resource #id/visible
Tip: Try to refresh the layout.
NOTE: #id/visible is not present in the code.
This nags one with the Rendering Problems window
How to fix: add these values to any values file (the filename doesn't appear to matter, I use ids.xml, you can use an existing one as well, such as colors.xml or strings.xml)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="visible" type="id"/>
<item name="masked" type="id"/>
</resources>
It most likely is a bug, and it has been filed in the Issue Tracker.
Meanwhile, you may try to switch the API version in the editor to 19 or below, though you may see some minor differences in the design output.
No Need To Change API
Couldn't resolve resource #string/faq_customer_service
or
Couldn't resolve resource #id/visible
or
Couldn't resolve resource #id/masked
The solution is if you implement TextInputLayout the above problems may arise ... so Simply add those id or strings to xml files as their property.
Add the value below tag in strings.xml file:
<item name="visible" type="id"/>
<item name="masked" type="id"/>
I am working on Android MDM and have the app_restrictions.xml file under /src/main/res/xml/ folder. The MDM I am using is not showing me the value of the restriction, not even the default value. All the steps mentioned in this link has been followed to set app restrictions: https://developer.android.com/training/enterprise/app-restrictions.html
but i am getting Bundle[EMPTY_PARCEL]. below is the code
app_restrictions.xml
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:key="MDMEmailKey"
android:title="Email"
android:restrictionType="string"
android:description="#string/email_address_mdm_description"
android:defaultValue="testtesttest#gmail.com" />
<restriction/>
</restrictions>
Also, the lint is showing me below errors, though I was able to suppress it in gradle through lint options, but just wondering if it is not the cause of the issue I am facing. Please let me know why I am getting these errors.
Executing task ':project_name:lintVitalRelease' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:key [ValidRestrictions]
<restriction/>
~~~~~~~~~~~~~~
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:restrictionType [ValidRestrictions]
<restriction/>
~~~~~~~~~~~~~~
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:title [ValidRestrictions]
<restriction/>
~~~~~~~~~~~~~~
Explanation for issues of type "ValidRestrictions":
Ensures that an applications restrictions XML file is properly formed
https://developer.android.com/reference/android/content/RestrictionsManager.html
3 errors, 0 warnings
RE: The lint errors
You have an empty restriction element at line 8 <restriction/>
Just remove it and the lint errors will go away.
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:key="MDMEmailKey"
android:title="Email"
android:restrictionType="string"
android:description="#string/email_address_mdm_description"
android:defaultValue="testtesttest#gmail.com" />
<restriction/> <!-- Error here -->
</restrictions>
I have an error in Android xml layout as follows :
Exception raised during rendering: <include /> can only be used inside of a ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- android.support.v7.internal.widget.ActionBarOverlayLayout (Fix Build Path, Edit XML, Create Class)
Now, When I am changing the AppTheme to Theme.Holo than its working fine.
I want to know that Why is it like this ?
I am trying to create my first Android app. I am using Eclipse. I create a project, and before I add any code myself, I run the default project, and I get the 'Hello, MyApp' in my emulator.
All good.
I then drag and drop a button onto my 'avtivity', under the text that was added when I create the project.
Suddenly, XML errors!
[2012-06-02 18:03:48 - FuelLogger] res\layout\main.xml:0: error: Resource entry main is already defined.
[2012-06-02 18:03:48 - FuelLogger] res\layout\main.out.xml:0: Originally defined here.
[2012-06-02 18:03:48 - FuelLogger] D:\Android\eclipse\Workspace\res\layout\main.out.xml:1: error: Error parsing XML: no element found
[2012-06-02 18:03:49 - FuelLogger] Error in an XML file: aborting build.
It has created a new files, main.out.xml
What's that? It's empty.
My main.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
If I look at the 'Graphical Layout' tab, it looks fine...
I am obviously missing something here. Hope someone can help.
I think you have selected your main.xml and is oped in code window;
then you r pressing RUN button of eclipse.
Which creates error.
First of All:
DELETE : main.out.xml
From your res\layout\ folder Then
To run project:
Make open "Project Explorer"
Rigth Click on Your Project,
Click Run AS
Click Android Application
Delete the main.xml.out file from your res/layout folder and the clean and build/run the application. If you are not able to delete the file from eclipse delete it from your workspace and the clean and build/run the application
Delete main.out.xml, and run as Android application after cleaning.
Here is detailed description
Similar problem answers: main-out-xml-parsing-error
also you might want to look here. Seems related to your question, that main.out.xml is what's causing the trouble...