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.
Related
I'm facing the following error:
Error while executing: am start -n
"com.package/com.package.SplashActivity" -a android.intent.action.MAIN
-c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.package/.SplashActivity
} Error type 3 Error: Activity class
{com.package/com.package.SplashActivity} does not exist. Error
while Launching activity
So what can I do to resolve this issue
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.company.xyz">
<application
android:name="GoogleAnalyticsApp"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:theme="#style/MyMaterialTheme">
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait">
<!-- For Pushwoosh we have to set following code: -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name=".MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
</application>
</manifest>
I have added Manifest file also in that you can see what I need to change and I am using push for notification.
Thanks for the help in advance.
Edited : com.company.xyz packagename which is same in other build.gradle and manifest
I have checked both files are having same package name and the application is running in all device but when i try to run it on OREO it not launching activity.
OP, Have you found a solution for this?
I had the same issue using a splash screen in android o. It was caused by the custom theme I was using before O. Are you using a custom theme for that activity?
If so, this solution might help you.
The custom theme had this code
<item name="android:windowBackground">#drawable/background_splash</item>
but android O seems to crash with it so try this solution that I used to solve my issue
Create a new value-v26/styles.xml then add the code below in that xml
<style name="Splashscreen" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowSplashscreenContent">#drawable/splashscreen</item>
Replace the background drawable with your own.
The full detail of the solution is from this post by Omkar Amberkar
make sure in android manifest file in your SplashActivity is call first like below code..
<activity
android:name=".activity.SplashActivity"><!--activity is package name. hear pass your first activity to load app start-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Activity class {com.package/com.package.SplashActivity} does not exist.
I think the activity class package name or the manifest declaration along with the fully specified package name is missing in your case.
I have been looking into building a app to replace the homescreen on android, I need to know how to add the option to add app shortcut to my app.
In your app's manifest file (AndroidManifest.xml), find an activity whose intent filters are set to the android.intent.action.MAIN action and the android.intent.category.LAUNCHER category.
Add a <meta-data> element to this activity that references the resource file where the app's shortcuts are defined:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application ... >
<activity android:name="Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="#xml/shortcuts" />
</activity>
</application>
</manifest>
You can find the rest here - https://developer.android.com/guide/topics/ui/shortcuts.html
Hope this helps!
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>
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"/>
I'm developing an application for the Android platform targeted for api level 4 (Android 1.6) but I can't get it to show up on my phone and I can't figure out why. Here's my AndroidManifest.xml is there a problem in here? Or is there something else I should be looking at?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sbe.app.hellocogen"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".activity.ListPlants"
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=".activity.AddPlant"
android:label="Add Plant">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".activity.UnitActivity"
android:label="IP HERE, PLANT NAME">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4"/>
</manifest>
When I started this application it didn't show up but I fixed it by setting the minimum api level to 4 instead of 7 then it started showing up but now it stopped showing up again and I don't know why.
I was having the exact same problem as you. It was working for one activity but not another. Eventually I realised that I had named the tag "activty" instead of "activity". This doesn't throw an error of any kind, just does not recognise the existence of the Activity!
Also, you don't need the ".activity." before the class name. Is your "ListPlants" a ListActivity? If so, this might explain your problem.