I am using groovy to generate a partial manifest that contains intent filter declarations for app links from my build config files. The merged manifest found in the apk looks as expected but with one issue: the attribute android:debuggable is getting dropped despite being set in build.gradle. If I remove the partial manifest and rebuild the apk, android:debuggable="true" will be set as expected.
my main manifest looks like:
<manifest package="com.app.myapp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">
<application
android:name="MyApp"
tools:replace="android:theme, android:label, android:allowBackup">
</application>
</manifest>
and my generate partial manifest looks like:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.app.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name="MyApp">
<activity android:name=".activity.MyActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
and in build.gradle file debuggable true is set.
The attribute android:debuggable is getting dropped from the merged manifest found in the apk, what can I do to ensure that it is set correctly without adding it in the partial manifest (I don't know it at gradle sync time when the script runs and don't want to hardcode it to true)?
After removing the android:name attribute from the application node of the partial manifest file, the merge occurs correctly.
The partial manifest that works:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.app.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name=".activity.MyActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
Related
I am having an issue with the naming of the application when the label string comes from an android library in a multi module project.
Here's some code
application/src/main/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.android">
<application
android:name=".MainApplication"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
<activity
android:name=".main.MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="mycompany"/>
</intent-filter>
</activity>
</application>
</manifest>
application/src/main/res/values/strings.xml
EMPTY. All application strings are coming from the library.
library/src/main/res/values/strings.xml
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="app_name">MyAppName</string>
...
</resources
Result:
The application is named Library instead of MyAppName in the application launcher once it's installed in any device.
Things I tried/did:
Added same label than the application to the activity with android.intent.action.MAIN intent filter
Moved #app_name string to application/src/main/res/values/string.xml. This does work, but is not ideal in my case as translations are managed entirely in a different module.
The rest of the strings in the application are correctly being picked up from the library
Searched for the string Library and I did not find it anywhere in all my code.
Suggested by #azizbekian: Added tools:replace="android:label" to both application and main activity manifest tags
Any clues? Thanks in advance.
My manifest file is as below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.myglassapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.demo.myglassapp.MainActivity"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/voice_trigger_start" />
</service>
</application>
</manifest>
voice trigger start file
<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="#string/its_demo" />
My strings.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">myglassapp</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="its_demo">Hello Sir</string>
</resources>
As per my knowledge I have added a code block
<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
in manifest file. I created a voice trigger file and set a variable in it.
Now i call that variable from strings.xml file.
So, basically it is all correct but i do not see "Hello Sir" added to my OK GLASS menu.
When I run my application from Eclipse IDE, i do not see my menu after OK GLASS menu option.
In stead, I see my app directly running like it runs in Android phone when we set it in debug mode.
Any idea why it is not working?
I agree with Nicole. Maybe if you move some stuff around it may work. But, it depends a lot on how you are building your app. In my case, for example, the voice trigger intent is define for my activity, not my service (Similar to Nicole's case). However, I have seen some examples where the trigger is on the service. You can check those examples by creating a sample Android project in Eclipse.
Now, the reason why your app is opening after you run it similarly to a mobile is because you have this on your manifest
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
You should remove that if you dont want that behavior
In your glass itself you say your application name it will show the list of app
Try this Hope this will help
I am new to glassware development.. but maybe try moving some things inside your application tag in manifest (instead of the service tag.. I do not have a service tag at all). Here's an example of my manifest file that works with voice recognition from the start menu...
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/voice_trigger_start" />
</activity>
</application>`
The problem I have is that if I have in the base Manifest file an Acitivity, say like so:
<activity
android:name=".activities.ActTutorial"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.NoActionBar"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
After I merge the manifest files, produce the apk file and open this apk file (using apktool) to look at the AndroidManifest.xml file I see this:
<activity
android:theme="#*android:style/Theme.Holo.NoActionBar"
android:label="#string/app_name"
android:name=".activities.ActTutorial"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
The android:theme value changed from:
"#android:style/Theme.Holo.NoActionBar"
to
"#*android:style/Theme.Holo.NoActionBar"
As you can see there is an asterisk (*) there and this basically result in showing me an activity with ActionBar when in fact I need one without.
Does some one knows why this happens? and this can be fixed?
In the end the asterisk was not my problem for this thing, but I had some problem with the application package names, what helped in this case was to use:
${applicationId}. place holder in the manifest file for different packages of the different flavor of the project.
You can use it like so:
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission
android:name="${applicationId}.permission.C2D_MESSAGE"/>
The following code works well, I often find some sample code to omit, so I change my code as
<service android:name=".MyInternetServer"></service>
but I get an error "The service can't be found".
I guess the package="com.example.enabledisablebroadcastreceiver" and
<service android:name="com.code4reference.enabledisablebroadcastreceiver.MyInternetServer"></service>,
maybe it should be use full name, right?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.enabledisablebroadcastreceiver"
android:versionCode="1"
android:versionName="1.0" >
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.code4reference.enabledisablebroadcastreceiver.EnableDisableBroadcastReceiver"
android:label="#string/title_activity_enable_disable_boradcast_receiver" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Broadcast receiver -->
<receiver android:name="com.code4reference.enabledisablebroadcastreceiver.AlarmManagerBroadcastReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<service android:name="com.code4reference.enabledisablebroadcastreceiver.MyInternetServer"></service>
</application>
</manifest>
The shorthand "dot" notation in the Manifest file works as described in the documentation:
However, as a shorthand, if the first character of the string is a
period, the string is appended to the application's package name (as
specified by the <manifest> element's package attribute).
So in your case, using:
.MyInternetServer
...is shorthand for:
com.example.enabledisablebroadcastreceiver.MyInternetServer
as that's what's in your <manifest>'s package attribute.
I'm guessing you probably want to update your manifest's package attribute to match the package you're actually using for your project.
Yes give your service a full path, where its actually located with full package name and then check, it will work.
I am currently working on an android project. And now i wish to complete a job: Parsing a xml file called AndroidManifest.xml and get some attribute from it. And set to some values in vim.
Here is the AndroidManifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.base.module.callhistory"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar"
android:icon="#drawable/call_history">
<activity android:name="HistoryMainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="HistoryListActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="DetailListActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
I want to parse package="com.base.module.callhistory" and HistoryListActivity in <activity android:name="HistoryMainActivity". Then i can use this two value to compose a command to launch my app automatically. I just set these values by hand. But i think if vim can parse this file and set these values automatically, it's must very cool.
Consider xmlstarlet, xmllint --xpath
Otherwise, you can use perl or python to achieve your goal if you have it compiled in (usually packaged versions do)
Regardless of that, you might still use nomarl search (/) patterns with c i t to replace the tag contents
I had a similar requirement as you, and I just wrote a custom python script for this task.