I'm developing an Android Wear watch face along with its mobile companion configuration activity.
As a start I followed the documentation (https://developer.android.com/training/wearables/watch-faces/configuration.html#CompanionActivity) and used the available examples from Google (https://developer.android.com/samples/WatchFace/index.html), specifically the FitDistanceService.
If I use the actual code from the example it all works. The small gear icon - used to open the companion (phone) configuration activity - shows up in the Android Wear app on the phone and I can open the companion phone config activity by tapping on it.
But if I rename the package name from the default "com.example.android.wearable.watchface" to anything else (even to com.example.android.wearable.mycompany) the gear icon disappears from the Android Wear app on the phone and it becomes impossible to open the configuration activity.
I tried changing the package name in any possible way. I've tried using the Move, Copy, Rename functionalities in Android Studio (v. 2.2.3). I've tried to manually change the package name and all its occurrencies in all of the project files using Sublime Text, also renaming the related folders and changing any occurrence of the package name in the manifest.xml of wear and mobile apps.
After the renaming (moving, copying etc.) it all works perfectly. Not a warning, nothing. The watch face behaves as expected, but the gear icon simply disappears.
This is the MOBILE manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.wearable.watchface" >
<uses-sdk android:minSdkVersion="18"
android:targetSdkVersion="23" />
<!-- Permissions required by the wearable app -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Location permission used by FitDistanceWatchFaceService -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- All intent-filters for config actions must include the categories
com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION and
android.intent.category.DEFAULT. -->
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<!-- This activity is needed to allow the user to authorize Google Fit for the Fit Distance
WatchFace (required to view distance). -->
<activity
android:name=".ConfigActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="com.example.android.wearable.watchface.CONFIG_FIT_DISTANCE" />
<category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
And this is the WEARABLE one:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.android.wearable.watchface"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="23"/>
<uses-feature android:name="android.hardware.type.watch"/>
<!-- Required to act as a custom watch face. -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Required for complications to receive complication data and open the provider chooser. -->
<uses-permission android:name="com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA"/>
<!-- Location permission used by FitDistanceWatchFaceService -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BODY_SENSORS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<uses-library
android:name="com.google.android.wearable"
android:required="false"/>
<activity android:name="android.support.wearable.complications.ComplicationHelperActivity"/>
<!--
All intent-filters for config actions must include the categories
com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION
and android.intent.category.DEFAULT.
-->
<service
android:name=".FitDistanceWatchFaceService"
android:label="#string/fit_distance_name"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/watch_face"/>
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="#drawable/preview_distance"/>
<meta-data
android:name="com.google.android.wearable.watchface.preview_circular"
android:resource="#drawable/preview_distance_circular"/>
<meta-data
android:name="com.google.android.wearable.watchface.companionConfigurationAction"
android:value="com.example.android.wearable.watchface.CONFIG_FIT_DISTANCE"/>
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService"/>
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE"/>
</intent-filter>
</service>
<activity
android:name=".FitDistanceWatchFacePermissionActivity"
android:label="#string/title_activity_fitdistance_watch_face_permission">
</activity>
<activity
android:name=".BodysensorsWatchFacePermissionActivity"
android:label="#string/title_activity_bodysensors_watch_face_permission">
</activity>
</application>
</manifest>
They both work perfectly, if you don't try to rename the package from "com.example.android.wearable.watchface" to something else.
Any clues? Of course I could go on with the "com.example.android.wearable.watchface" package name, but it seems implausible that it's not possible to change the package name.
Thank you!
Related
From an open source project I got this manifest file
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<service
android:name="org.gege.caldavsyncadapter.syncadapter.SyncService"
android:exported="true">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="#xml/syncadapter" />
</service>
<service
android:name="org.gege.caldavsyncadapter.authenticator.AuthenticationService"
android:exported="true">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="#xml/authenticator" />
</service>
<activity
android:name="org.gege.caldavsyncadapter.authenticator.AuthenticatorActivity"
android:label="#string/title_activity_authenticator"
android:windowSoftInputMode="adjustResize|stateVisible"/>
</application>
I am a bit puzzled about that manifest. It has two services and one activity. The activity is not marked as default activity. When I run the project on my phone it doesn't show any icon to start the app neither does the app start automatically.
Does a manifest like this make sense? What does the Android OS based on such a manifest?
Does a manifest like this make sense?
Yes, since it declares a sync adapter an an authenticator.
Generally, such manifests would also make sense in a library project. The app project that uses the library then provides the main launcher activity. The build process merges manifest files together so you get one manifest per APK.
What does the Android OS based on such a manifest?
As such, it has the entry points such as an activity and two services declared. Generally you invoke these entry points via an Intent. The services are declared as a sync adapter and an authenticator, so they can be invoked by the framework. The activity is probably invoked by the authenticator service for UI purposes.
Because there's no main launcher activity, no menu icon is visible.
I'm trying to enable Google Play Games in my Adobe Air game for Android. There are 2 apps a full and a demo one. But it looks like SignIn/SubmitScore/ReportAchievement codes are just being ignored, for both apps.
I'm using this ANE, but have also tried this and it's original fork. For all the result is the same. Code "ignored", nothing happens.
My project setup:
All the project was done, compiled and packaged in FlashDevelop. Platform is Air Mobile 14.0, SDK is Adobe Air 16.0. I use my own .p12 certificate for Android package, one for each App version.
I include the ANE on FlashDevelop the same way I included Game Center
ANE, for the same APP. The Game Center one is working, so I think
this one should also be fine.
I have added my com.google.android.gms.games.APP_ID to the xml, together with the additions required by the ANE.
In my code I do (and nothing happens, no callback is called, no signal is triggered, no sign in pop up screen, but my "trace" notification is shown, so the code is reached):
Games.initialize();
addListeners(); //Adding SignIn and SignOut callbacks
Games.promptUserToSignInOnStartup(true);
Games.start();
NotificationSystem.notifyLoading("Connecting to Google Play Games Service");
On Google's Developer Console:
Both apps are published for Alpha/Beta tests, there is no Production version yet.
I've set up Play Games Services, it is "Ready to test".
Both apps have been linked to it and authorized. I verified OAuth2.0 SHA1 fingerprint for both .p12 and they match.
This is my APK's AndroidManifest.xml, as I can't imagine the problem being on code side, or Google's console side.. I think it should be somewhere on ANE's config when packaging. So it might be here:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="air.mygame">
<application android:hardwareAccelerated="false" android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:label="#string/app_name" android:launchMode="singleTask" android:name=".AppEntry" android:screenOrientation="user" android:theme="#style/Theme.NoShadow" android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="namespaceVersion" android:value="14.0"/>
<meta-data android:name="aspectRatio" android:value="portrait"/>
<meta-data android:name="autoOrients" android:value="true"/>
<meta-data android:name="fullScreen" android:value="true"/>
<meta-data android:name="uniqueappversionid" android:value="251bf45a-b5b6-49ae-bb1a-4337f47f8f34"/>
<meta-data android:name="initialcontent" android:value="mygame.swf"/>
<meta-data android:name="containsVideo" android:value="false"/>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="MY_APP_ID_ON_GOOGLE_PLAY_GAMES"/>
<meta-data android:name="com.google.android.gms.version" android:value="4242000"/>
<activity android:name="com.google.api.games.SignInActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
<activity android:name="com.google.api.games.StubActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
</manifest>
Ok! I found the error and it was indeed in the AndroidManifest.xml.
For anyone else struggling with this, the problem is that when working with Adobe Air we don't edit AndroidManifest.xml file directly, we edit application.xml using the manifestAdditions tag. And the needed additions were going to the wrong place.
My application.xml was like:
<android>
<manifestAdditions>
<![CDATA[<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-sdk android:minSdkVersion="9" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<!-- GooglePlay Games Services -->
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ MY_GOOGLE_PLAY_GAMES_APP_ID" />
<meta-data android:name="com.google.android.gms.version" android:value="4242000" />
<activity android:name="com.google.api.games.SignInActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.google.api.games.StubActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
</manifest>]]>
</manifestAdditions>
</android>
Looking at Google's guide there could be no activity tag outside of the application tag on the final AndroidManifest.xml. Also, according to this, the meta-data tag should also be inside the application tag.
I just had to edit the application.xml so it looked like:
<android>
<manifestAdditions>
<![CDATA[<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-sdk android:minSdkVersion="9" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<!-- GooglePlay Games Services -->
<application> <!-- This will be merged with application tag in the final manifest file -->
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ MY_GOOGLE_PLAY_GAMES_APP_ID" />
<meta-data android:name="com.google.android.gms.version" android:value="4242000" />
<activity android:name="com.google.api.games.SignInActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.google.api.games.StubActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
</application>
</manifest>]]>
</manifestAdditions>
</android>
To open your final AndroidManifest.xml, file for checking, you can use apktool.
I have a Worklight hybrid app that works fine with most all devices except for the newer Galaxy S5 and Note 4.
The app displays fine in all devices, however it uses the Cordova camera plug-in to get an existing pictures. But, Samsung has a directory chooser "Get Pictures" before the file chooser. The dialog is so large that is un-usable.
I have tried setting anyDensity to false but this causes the app's content to be tiny although the dialog looked good. I also tried using targetSdkVersion=13, android:xlargeScreens, android:compatibleWidthLimitDp, android:largestWidthLimitDp,
android:requiresSmallestWidthDp and changing the #media query in the CSS with no luck.
Is there anything I can do to allow my app to look the same but adjust the system dialog so it handles itself correctly?
worklight 6.2
android 4.4.4
cordova 3.6
backbone, jQuery, less
<supports-screens android:anyDensity="false" android:normalScreens="true" android:resizeable="false" android:smallScreens="false"/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="5" android:versionName="1.0" package="com.EmployeeApp">
<uses-sdk android:minSdkVersion="8" />
<supports-screens android:anyDensity="false" android:normalScreens="true" android:resizeable="false" android:smallScreens="false"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- Push permissions -->
<permission android:name="com.EmployeeApp.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.EmployeeApp.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:configChanges="orientation|keyboardHidden|screenSize" android:label="#string/app_name" android:launchMode="singleTask" android:name=".EmployeeApp">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.EmployeeApp.EmployeeApp.NOTIFICATION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<!-- Preference Activity -->
<!-- Removed preferences activity per defect 20086 -->
<!--activity android:name="com.worklight.common.WLPreferences" android:label="Worklight Settings"/-->
<!-- Push service -->
<!-- In order to use the c2dm library, an application must declare a class with the name C2DMReceiver, in its own package, extending com.google.android.c2dm.C2DMBaseReceiver
It must also include this section in the manifest, replacing "com.google.android.apps.chrometophone" with its package name. -->
<service android:name=".GCMIntentService"/>
<service android:name=".ForegroundService"/>
<!-- Only google service can send data messages for the app. If permission is not set - any other app can generate it -->
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.EmployeeApp"/>
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.EmployeeApp"/>
</intent-filter>
</receiver>
</application>
</manifest>
Per my comment: try changing the targetSdkVersion to higher than the attempted "14", instead to 19 or 20.
Typically by using a higher API Level, this tells the system to use UI elements that better fit the OS used. The lower the API, the lower the compatibility is with newer OS versions, screen sizes, etc.
so i've been working on a project pretty fine until some days ago. My XML file suddenly showed some errors. The "http://schemas.android.com/apk/res/android" just went missing. Well... it wasn't delete but marked red. It says the URI is not registered and i tried to rewrite it with autocomplete (in case the namespace changed somehow) but it wasn't there. I looked in the settings if someone put it on ignore list or something like that but it was not. So here is my complete XML file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.test.android.tea.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />
<!-- Permission to save Robotium screenshots -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<!-- Permission to register as a camera app -->
<uses-feature android:name="android.hardware.camera" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="de.telekom.android.tea" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<uses-library android:name="android.test.runner" />
<!-- Camera mockup -->
<activity
android:name="de.telekom.android.tea.test.robotium.stub.CameraStub"
android:label="Emma Camera Stub" >
<intent-filter>
<action android:name="android.media.action.IMAGE_CAPTURE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Gallery mockup -->
<activity
android:name="de.telekom.android.tea.test.robotium.stub.GalleryStub"
android:label="Emma Gallery Stub" >
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/image" />
</intent-filter>
</activity>
</application>
</manifest>
Furthermore are android:versionCode, android:versionName, android:allowBackup, android:icon and data android:mimeType marked red too with the comment "Attribute not allowed here" (last one says Element not allowed here) and android.test.InstrumentationTestRunner, de.test.android.tea, de.test.android.tea.test.robotium.stub.CameraStub and de.test.android.tea.test.robotium.stub.GalleryStub marked with the comment "Cannot resolve symbol"
The XML file is used to give permissions to some stubs for automated testing and I'm using Android Studio 0.8.10 atm. I appreciate ever little hint.
Edit: I have a second AndroidManifest.xml in the Application Module which is working fine. It is just the one in the ApplicationTest module. I recently saw that some of my folders in the test module say "test resources root" and if i move it in one of those folders the namespace is available but then some of the targetpackages are not working.
I had my existing android project going unmanageable due to unnecessary research codes, so I decided to create a new project with only necessary code that's required for the app. I uploaded the same on play store's beta environment. As the app got updated on my phone, the already existing app icon on home screen got removed. Did I make any mistake in the code development?
Please help
EDIT: Added Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.abc"
android:installLocation="preferExternal"
android:versionCode="52"
android:versionName="5.0.004" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name="com.example.abc.Appname"
android:allowBackup="true"
android:icon="#drawable/launcher"
android:label="#string/app_name"
android:theme="#style/Theme.CustomTheme" >
<activity
android:name="com.example.abc.SplashScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/title_activity_app_name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</manifest>
Reverted back the application name to old file name (java class) and the same in manifest file. The launcher icon was created while installing via Google play store's beta environment.
Still unsure why the application name and java class names had an impact on the launcher icons. Any idea?