Android manifest.xml - android

I'm working on the Tabs example from Google Android Developers site (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html) but I'm stuck in step 2.
At the very end of step 2 says "Duplicate this for each of the three activities, and add the corresponding tags to the Android Manifest file"
What exactly do I have to add to the AndroidManifest.xml?
Thanks

This is how your Manifest file should be:
<activity android:name=".ArtistsActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".SongsActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".AlbumsActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
</application>
This will work for sure!!

just add every activity AndroidManifest.xml
main activity use:
<activity android:name=".Tabs">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
another activity use:
<activity android:name=".Tab1">
<intent-filter>
<action android:name="android.intent.action.EDIT"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

Basically you have register each activities in AndroidManifest.xml like this
<activity android:name=".YourActivityName"/>

You have to add the corresponding <activity> tags for each one of the three activities. The AndroidManifest.xml file describes the components of the application (amongst other things like permissions and API level support).
In this example you have to add three definitions:
<activity android:name=".ArtistsActivity"/>
<activity android:name=".AlbumsActivity"/>
<activity android:name=".SongsActivity"/>

Related

Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`

Please help me with this error getting in my project while trying to run at mobile via android studio.
Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
Add this to your manifest to the activity tag in the error message:
android:exported="true"
This happens when your activity can be started by another application. For example image viewer can be started by file manager when clicking an image. The image viewer app is "exported".
It's also always required if you are using the following code necessary for dynamic links:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
Example:
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
I found this solution!!.
So you have to add the android:exported="true" into the activity tag in the manifest (not in the application).
<application
android:fullBackupContent="#xml/my_backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
<activity android:name=".yourActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".otherActivity" android:exported="true"/>
</application>
To see more information about the exported property, see App manifest file activity
:)
if you are using flutter ,may some deprecated lib in your ap is causing this ..
for me: upgrading flutter_local_notifications to the latest version (now is 9.3.2) solved this error..
If you have any activity, service, receiver, or provider that does not have exported set in your manifest file then add whenever it needed like,
android:exported="false or true"
You had to figure out the component missing the Android exported tag.
You should downgrade your SDK version and check the final merged manifest file for the components missing the exported tag but has IntentFilter.
The step-by-step instructions is provided in this link.
This is for the projects using Bootsplash.
My project used Bootsplash and I solved it by adding android:exported="true" also to the activity of Bootsplash in the AndroidManifest file.
<application
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustPan"
android:exported="true" // <----ADD THIS
android:screenOrientation="portrait">
</activity>
<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="#style/BootTheme"
android:exported="true" // <----ADD THIS
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Add android:exported="true" into the Manifest file inside of the application activity
<application
<activity
android:exported="true"
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.NoteKeeper.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

Android studio installing APK on phone but can't find the app

I am new to Android Studio and I am trying to deploy an APK to my mobile device in order to test the app. I build the APK successfully but when I install the apk of the app in my device I couldn't see it or cannot be open. But I can see the apps in the app manager showing that I installed it.
here is the code in my manifest file.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="Pasig NutriCare"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Looking for help.
Thanks in advance.
Did you checked Sort / Alphabetical / Custom ?
Also Check AndroidManifest.xml
Main Activity Should Contains :
Like :
<activity android:name=".SplashActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
So change .SplashActivity to that you want And Remember to place dot . before it as i did
if you use sub Package Name place it , For Example :
your package is : com.example.myapplication
you create sub package as : activities
so in AndroidManifest.xml you have :
<activity android:name=".activities.SplashActivity"
...
</activity>
Make sure you specify the launcher activity for the app in your AndroidManifest.xml file:
<activity android:name=".YOURACTIVITY" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Did you specify the launcher activity for the app (in the AndroidManifest.xml)? If all else fails, you can also install the app manually using ADB (android debug bridge)
To install manually, Run this command from terminal/command prompt
adb install path_to_apk

Android name in manifest file shows error

In my Android manifest file "android:name" in both the activities which I have mentioned below shows error when I tried to run the program. How can I fix this?
<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>
<activity
android:name=".ContentView"
android:label="#string/title_activity_content_view" >
<activity>
CLean Project
if it doesnt work,
remove tags and add activity again to manifest

Can't open installed app on android

I have finished my application in Android Studio but when I copy and paste app-debug.apk on my android phone it can't be opened after installation. Can anybody tell me what is wrong a what I need to do to make that app run. Btw when I was writting the code I was running it on my phone through USB cable without using AVD. Here is my AndrodiManifest:
<application
android:debuggable="true"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".SplashActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.category.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.category.MAINACTIVITY"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".InfoActivity"
android:label="#string/app_name">
</activity>
</application>
The problem is likely that your <intent-filter> elements are not correct.
Assuming SplashActivity is the first Activity the user should see when launching your app, your <intent-filter> should have an <action android:name="android.intent.action.MAIN"/> element. Note that your <action> element has the name android.intent.category.MAIN, which doesn't exist.
Your MainActivity's <intent-filter> also looks odd- android.intent.category.MAINACTIVITY doesn't exist, and you probably don't need to set the <category> (or an <intent-filter>) at all. See the documentation for CATEGORY_DEFAULT and determine whether you actually need it.

I am currently learning about Android services,all the coding part is good,but the manifest gives me the following error

Here is my manifest file
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.android.developers.service.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>
<activity android:name=".MyService" >
</activity>
<service
android:name=“MyService"
android:enabled="true”>
</service>
</application>
It gives me the following error:Open quote is expected for attribute "{1}" associated with an element type "android:name".
Take a look at where the syntax highlighting screws up on this site, and you'll see it
The marks here are not (XML) quotation marks:
android:name=“MyService"
¯
android:enabled="true”>
¯
in the service the android name should be like this
<service
android:name=".NameOfService">
</service>
It is better to write ful package name and then name of service.
<service
android:name="packaganame.NameOfService">
</service>
The error is because of the first open quote which is right after android:name=. switch input method to English and replace the open quote of "MyService" :)
Please look at your manifest file, here you have written two times MyService. The modified code is:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.android.developers.service.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>
<!--<activity android:name=".MyService" >-->
</activity>
<service
android:name=".MyService"
android:enabled="true"
android:exported="true" >
</service>
</application>
This should fix any problems you're having.

Categories

Resources