I have defined a widget provider xml in my app as below :
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="40dp"
android:minHeight="40dp"
android:updatePeriodMillis="43200000"
android:initialLayout="#layout/widget"
android:previewImage="#drawable/ic_widget_on"
>
</appwidget-provider>
But Eclipse shows me a warning :
Attribute "previewImage" is only used in API level 11 and higher (current min is 8)
So, to remove this warning while supporting API 8, i define a custom namespace and use that for the previewImage attribute as below :
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myApp="http://schemas.android.com/apk/res-auto"
android:minWidth="40dp"
android:minHeight="40dp"
android:updatePeriodMillis="43200000"
android:initialLayout="#layout/widget"
myApp:previewImage="#drawable/ic_widget_on"
>
</appwidget-provider>
But now Eclipse shows me the error :
error: No resource identifier found for attribute 'previewImage' in package 'com.myDomain.myApp'
Usually this solution works for other newly introduced attributes when using the support library. But why is it not working for previewImage? Doesn't the support library support it?
But Eclipse shows me a warning
That warning should not affect anything of note. Preview images were not used by the platform at all prior to API Level 11.
Usually this solution for other newly introduced attributes when using the support library.
App widgets are not part of the support library.
Related
I am developing a NativeScript app for android and wish to implement managed configurations as described here: https://developer.android.com/work/managed-configurations.html.
I have tried adding app_restrictions.xml to the App_Resources/Android/values folder but I get the following build error:
Execution failed for task ':mergeF0F1DebugResources'.
Error: Unsupported type 'restriction'
This is the content of app_restrictions.xml:
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:key="downloadOnCellular"
android:restrictionType="bool"
android:defaultValue="true" />
</restrictions>
Does NativeScript support adding restrictions like this? If so, how do I add the restriction resource file. If not, is there some other way to implement managed configurations?
EDIT: Solved by pkanev in the comments. The restrictions file must be placed in App_Resources/Android/xml.
Per the official Android documentation - https://developer.android.com/work/managed-configurations.html
the restrictions configuration needs to be placed in res/xml dir, which corresponds to app/App_Resources/Android/xml in a NativeScript Android app.
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 am new in Android-Programming and I and my programmer team have to program a little app for our college. So we need the ExtendedCalendarView-Library and we already imported it in our AndroidStudio-project but we always get the same failure:
Can not find the following classes com.tyczj.extendedcalendarview.ExtendedCalendarView
try to fix Build Path
and so on.
Code in our test.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<com.tyczj.extendedcalendarview.ExtendedCalendarView
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.tyczj.extendedcalendarview.ExtendedCalendarView>
</RelativeLayout>
But we have imported another library at the same way and it works. We also get a suggestion from com.tyczj.extendedcalendarview.ExtendedCalendarView when we open the '<' in a .xml file but always the same failure.
Meanwhile time is pressing so we have not so much time anymore.
Could anyone help us?
Have you copied the provider tag in your android manifest if not then copy it in application tag of AndroidManifest:
<application>
...
<provider
android:name="com.tyczj.extendedcalendarview.CalendarProvider"
android:authorities="com.tyczj.extendedcalendarview.calendarprovider" />
</application>
I am updating project in AndroidStudio, used target API 20 instead of 19. During this process I encounter this error:
[PathToMyProject]\myproject\build\exploded-aar\com.google.android.gms\play-services\4.0.30\AndroidManifest.xml:
Error:(1) Could not find element /manifest/application. //showing
several times
This is the file AndroidManifest.xml where is the error:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gms"
android:versionCode="4030530"
android:versionName="4.0.30 (889083-30)" >
<uses-sdk android:minSdkVersion="8"/>
</manifest>
When I add <application/> tag and run Make or Rebuild, the manifest is for an unknown reason refreshed and does not contain added <application> tag and the error shows again...
I had the same problem.
You need to change the build.gradle to get the gms version for wearables.
So, add compile 'com.google.android.gms:play-services-wearable:+' to dependencies, and it should work.
I am doing a Google MAPS application in android. I have installed the 2 platforms 2.3.3 and 2.1 and corresponding the Google API also.I have got the Google Maps API key.I have Added the permissions in manifest file also.For this application I used Google API 2.1 for Build SDk and Android 2.1 for MinSDK version.But when I run the project it shows a warning in Console
Ignoring platform 'android-8': build.prop is missing .
Also an error on the API KEY I pasted on the main.xml file ( android:apikey = ) is
error: Error parsing XML: not well-formed (invalid token)
main.xml file code is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="#+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="<MYAPIKEY>" />
</LinearLayout>
I have no error in Main activity.How can I solve this problem ?
The API key shouldn't have the < and > characters in it.