I am trying to run an Application that I downloaded the source code from the internet and having problems.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item
type="holder"
name="id_name" />
<item
type="categorie"
name="id_name" />
</resources>
The error I get is
app\src\main\res\values\id2.xml: Error: Unsupported type 'holder'' and cannot resolve symbol 'holder'.
How do I get over this?
It is because you can use only below types in an item tag.
And types can contain a reference for above-listed values.
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.
The debug build works perfectly, but whenever I try to generate a signed APK from AndroidStudio it cannot find the R.id of my menu items.
Here is my menu.xml file
<item
android:id="#+id/actionsearch"
android:title="Search"
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView"/>
<item
android:id="#+id/actionlogin"
android:icon="#drawable/ic_lock_outline_black_24dp"
android:title="Login"
app:showAsAction="always"/>
<item
android:id="#+id/actionadddeal"
android:title="Add Deal"
android:icon="#drawable/ic_add_circle_black_24dp"
app:showAsAction="always" />
<item
android:id="#+id/actioneditvenue"
android:title="Edit Venue"
android:icon="#drawable/ic_edit_black_24dp"
app:showAsAction="always" />
And here is the output from gradle when doing a release build for one sample file:
path\to\VenueDetailPagerActivity.java
Error:(109, 53) error: cannot find symbol variable actionlogin
Error:(109, 84) error: cannot find symbol variable actioneditvenue
Error:(109, 106) error: cannot find symbol variable actionadddeal
Error:(109, 167) error: cannot find symbol variable actionlogin
Error:(263, 22) error: cannot find symbol variable actioneditvenue
Error:(272, 22) error: cannot find symbol variable actionadddeal
The strange thing is, all other resource IDs have no issues. It's only the IDs from my menu.xml and only when generating a signed APK. Does anyone know what the issue could be?
The error was caused by me forgetting to add this line to the top of the .xml file:
<?xml version="1.0" encoding="utf-8"?>
But now follow up question is, why does this not cause problems for a local debug build but causes issues when generating a signed APK?
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 want to add profil opportunity to my action bar,but if i runt it doesnt work,I change shiwsAsAction from always to never, but it also didnt work.. i get this message in grade build:
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
C:\Android\Celtkituzes_0_1\app\src\main\res\menu\menu.xml
Error:(7) No resource identifier found for attribute 'showsAsAction' in package 'sgtt.celtkituzes_0_1'
C:\Android\Celtkituzes_0_1\app\build\intermediates\res\merged\debug\menu\menu.xml
Error:(7) No resource identifier found for attribute 'showsAsAction' in package 'sgtt.celtkituzes_0_1'
Warning:The android.dexOptions.incremental property is deprecated and it has no effect on the build process.
menu xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:appname="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/item_profil"
android:icon="#drawable/ic_action_image_timer_auto.png"
android:title="Profil"
app:showsAsAction="never">
</item>
</menu>
it should be android: not app:
should be showAsAction not showsAsAction
You have letter s attached to show
EDIT
For your next problem: You have to put an image also into drawabe folder, not only in one of the xxxhdpi(or similar) folders.
The error described:
Error: No resource identifier found for attribute 'showsAsAction'
is caused because the property must be app:showAsAction (not showsAsAction)
And the extension for the image file is not neccesary just the name:
android:icon="#drawable/ic_action_image_timer_auto"
This must be your menu.xml file :
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:appname="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/item_profil"
android:icon="#drawable/ic_action_image_timer_auto"
android:title="Profil"
app:showAsAction="never">
</item>
</menu>
I am new to Ads and was able to successfully add my first ad in my android app using the code below in my layout.
mylayout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxx"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
Since I have multiple layouts in my app, I moved the common AdView attributes (e.g. adSize, adUnitId, etc,.) to styles.xml to reduce the code size. However, after this change, I am running into errors like
error: Error: No resource found that matches the given name: attr 'ads:adUnitId'.
error: Error: No resource found that matches the given name: attr 'ads:adSize'.
error: Error: No resource found that matches the given name: attr 'ads:loadAdOnCreate'.
styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" >
<style name="MyAdView">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="ads:adSize">BANNER</item>
<item name="ads:adUnitId">xxx</item>
<item name="ads:loadAdOnCreate">true</item>
</style>
</resources>
I don't have problems with the android:xxx tags, the problem seems to be only with ads:xxx. Is there anything else that I should be doing to use com.google.ads namespace.
Since everything works fine when I have the code in the layout, I think I have everything I needed to add ads in my app (AdMob SDK, admob lib in build path and order & export, etc,.).
Please suggest. Thanks in advance.
I think you can use the style resource only for style related attributes, if you want to factorize the id you should use a string resource like
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="admob_id">XXX</string>
</resources>