"android:exported needs to be explicitly specified" on Android 12 - java

I integrated OneSignal push notification into my app and everything worked perfectly well until I upgraded to Android 12 (31). When I upgraded, AndroidStudio reports this error to me, I really don't know what I need to do to avoid it:
Manifest merger failed : android:exported needs to be explicitly specified
for <service>. 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.
AndroidManifest:
<?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.my.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="oppo.permission.OPPO_COMPONENT_SAFE"/>
<uses-permission android:name="com.huawei.permission.external_app_settings.USE_COMPONENT"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name="com.my.app.MainApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:networkSecurityConfig="#xml/network_security_config"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/admob_app_ID" />
<activity
android:name="com.my.app.activity.StepActivity"
android:screenOrientation="portrait"
android:theme="#style/Splash">
</activity>
<activity android:name="com.my.app.activity.PrivacyPolicyActivity"
android:screenOrientation="portrait"/>
<activity android:name="com.my.app.activity.TermsToUseActivity"
android:screenOrientation="portrait"/>
<activity android:name="com.my.app.activity.SplashActivity"
android:screenOrientation="portrait"
android:exported="true"
tools:node="merge">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.my.app.activity.MainActivity"
android:screenOrientation="portrait"/>
<activity android:name="com.my.app.activity.PremiumActivity"
android:screenOrientation="portrait"/>
<activity android:name="com.my.app.activity.ChooseServerActivity"
android:screenOrientation="portrait"/>
<service
android:name="com.my.app.OneSignal.MyNotificationExtenderService"
android:exported="true"
tools:node="merge"
android:permission="android.permission.BIND_JOB_SERVICE">
<intent-filter>
<action android:name="com.onesignal.NotificationExtender" />
</intent-filter>
</service>
<service
android:name="com.my.app.service.BackgroundJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:enabled="true"
android:exported="true"
tools:node="merge"/>
<service
android:name="com.my.app.service.MyService"
android:exported="false"
tools:node="merge">
<intent-filter>
<action android:name="androidsrc.intent.action.PICK_PLUGIN" />
<category android:name="androidsrc.intent.category.ADD_PLUGIN" />
</intent-filter>
</service>
<receiver android:name="com.my.app.service.BootCompletedReceiver"
android:enabled="true"
android:exported="true"
tools:node="merge">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
</application>
build.gradle (app):
manifestPlaceholders = [onesignal_app_id : "xxxxx-xxxx-xxxx-xxx-xxxxxxxx",
onesignal_google_project_number: "REMOTE"]

Related

installation did not succeed for my application on android studio

<?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.video.maker1">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />
<application
android:name="com.video.maker1.MyApplication"
android:allowBackup="true"
android:extractNativeLibs="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:networkSecurityConfig="#xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/theme"
android:usesCleartextTraffic="true"
>
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-9731420309932281~3771749504" />
<!-- <activity-->
<!-- android:name="com.facebook.ads.AudienceNetworkActivity"-->
<!-- android:hardwareAccelerated="true" />-->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="true"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths" />
</provider>
<activity
android:name="com.video.maker1.activity.SplashActivity"
android:exported="true"
android:screenOrientation="nosensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.video.maker1.activity.MainActivity"
android:exported="true"
android:screenOrientation="portrait">
</activity>
<activity
android:name="com.video.maker1.activity.ImagePickerActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.SwapImageActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.SelectFrameActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.VideoPlayerActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.SongGalleryActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.VideoThemeActivity"
android:exported="true"
android:screenOrientation="portrait" />
<service android:name="com.video.maker1.theme.service.ServiceAnim" />
<activity
android:name="com.video.maker1.activity.MyVideo"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.VideoMakerActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.PrivacyActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:exported="true"
android:theme="#style/Base.Theme.AppCompat" />
<activity android:name="com.video.maker1.activity.VideoTrimActivity" />
<activity
android:name="com.video.maker1.activity.VideoEditorActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.LibraryActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.video.maker1.activity.SaveVideoFileActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity android:name="com.video.maker1.activity.VideoListActivity" />
<activity
android:name="com.infiapp.imagelibrary.editimage.EditImageActivity"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"></activity>
</application>
</manifest>
this is my manifest code when i try to install my app on the emulator it shows me this error
^^The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED^^
i'hv tryed evrything that i know but it still showing me the same error
as you see i have tried the ^^android exported true commnd on all my activity but it doesn't work.

Getting error after updating android studio to 3.2

We are facing an error of default activity is not found after update android studio to version "3.2". On another PC, which is running lower version 3.1.4 of android studio, this same application is working. If anyone has a solution then please suggest us.
I have attached manifest file of screen shot of android studio for that error.
<?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.exmple.com">
<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.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
android:screenOrientation="portrait" >
</activity>
<activity android:name=".Category_item"
android:screenOrientation="portrait"/>
<activity android:name=".ImageDatail"
android:screenOrientation="portrait"/>
<activity android:name=".SplashScreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
</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="your-own-uri" />
</intent-filter>
</activity>
<service android:name=".FireBase.MyFirebaseMessagingService"
android:exported="true"
android:stopWithTask="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".FireBase.MyFirebaseInstanceIDService"
android:exported="true"
android:stopWithTask="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<receiver
android:name=".Util.ConnectivityReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.qualifiedapps.inspirationalquotes.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths" />
</provider>
</application>
</manifest>

Android icon missing when uploading to playstore

When I install my application it's working fine, the icon is displayed and have no issues, however when installing the application on the device from the apk it does not show the application name, it shows the package with no icon, when uploading to playstore it gives me an error stating I should add an icon to the application.
This use to work until recently.
ic_launcher icon file does exist.
my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.package">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name="android.support.multidex.MultiDexApplication">
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="com.my.package.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="com.my.package.LoginActivity"
android:label="#string/title_activity_login"
android:theme="#style/Theme.CustomTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.my.package.NotificationsActivity"
android:label="#string/title_activity_login"
android:theme="#style/AppThemeNoti"></activity>
<service android:name="com.my.package.FirebaseService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.my.package.FirebaseToken">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="keyhere" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
I found the problem:
<application
android:name="android.support.multidex.MultiDexApplication">
I removed the > after MultiDexApplication. Figured the android:icon was greyed out and hence not working.
Thanks.

How to open a new instance of the same application?

I'd like to open a new instance of the same application, much like chrome used to by default when opening a new tab (See this)
here's what I've tried so far:
PackageManager pm = getContext().getPackageManager();
Intent launcher = pm.getLaunchIntentForPackage("my.package.name");
launcher.setAction(Intent.ACTION_VIEW);
launcher.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
launcher.setData(Uri.parse(result.getExtra()));
getContext().startActivity(launcher);
it does start a new activity and also loads the correct data, but it doesn't open a new screen.
how would I achieve this?
HERE'S MY MANIFEST FILE
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.depa.browsing.stack">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:fullBackupContent="true"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true">
<activity android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="stateAlwaysHidden"
android:targetActivity=".MainActivity"
android:icon="#mipmap/ic_launcher">
<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="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".About"/>
<activity android:name=".Donate"/>
<activity android:name=".Settings"/>
<activity android:name=".GPL"/>
<activity android:name=".History"/>
<!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>

Android app don't run on the device or emulator?

This is my manifest file that my issue is with. Apk installed on the device but I don't see it in the apps and it doesn't launch as it supposed to. I bought this project for 79 dollars but the supplier is now unreachable.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.electricpunch.wallpaper"
android:versionCode="1"
android:versionName="1"
android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<service
android:name="com.electricpunch.wallpaper.PlanetWallpaper"
android:label="#string/app_name"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/wallpaper" />
</service>
<activity
android:label="#string/settings"
android:name="com.electricpunch.wallpaper.PlanetSettings"
android:exported="true"
>
</activity>
<!-- Ads Using Google Play Services SDK -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|u iMode|screenSize|smallestScreenSize" />
</application>
</manifest>
It's difficult to answer without knowing which Activity was meant to be the launcher activity in the first place.
But you could try modifying this portion of your manifest,
<activity
android:label="#string/settings"
android:name="com.electricpunch.wallpaper.PlanetSettings"
android:exported="true"
>
</activity>
to,
<activity
android:label="#string/settings"
android:name="com.electricpunch.wallpaper.PlanetSettings"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Though your best bet is to contact the person you got the app from.
Your app does not launch because no activtity is decalred to be launch in your manifest.
I don't know which activity you want to use but to be launch from laucher your app should have an activty declared like this :
<activity android:name="your.package.YourActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories

Resources