unity setup firebase FCM plus Facebook for android - facebook

I have tried the messaging app from quickstart-unity-master and it was working fine on it's own but when I have added the Facebook plugin the following happened:
The firebase FCM is initializing successfully but I am no longer receiving the OnMessageReceived and OnTokenReceived.
It has probably something to do with the com.google.firebase.MessagingUnityPlayerActivity activity not receiving the events, but I am not sure what is wrong since the Android manifest is still the same after adding facebook.
I am using facebook 7.10.1
Here is my 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="${applicationId}" android:versionCode="1" android:versionName="1.0">
<application android:label="#string/app_name" android:icon="#drawable/app_icon">
<!-- The MessagingUnityPlayerActivity is a class that extends
UnityPlayerActivity to work around a known issue when receiving
notification data payloads in the background. -->
<activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:label="#string/app_name" android:icon="#drawable/app_icon" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<service android:name="com.google.firebase.messaging.MessageForwardingService" android:exported="false" />
<activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
<activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
<activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
<activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
<activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
<activity android:name="com.facebook.unity.AppInviteDialogActivity" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb11111111111111" />
<provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider233093877143960" android:exported="true" />
</application>
</manifest>
appreciate your help

the issue was some missing dependencies, at first i only included what is needed by both SDK and tried them separately and they worked, but together didn't work for some reason;
the solution was to switch the build system from internal to gradle , then you don't have to worry about the max DEX methods and you can let the google play resolver download all the needed JAR and AAR;

Related

Uploaded an APK which has an activity, activity alias, service or broadcast receiver with intentfilter, but without 'android : exported' property set

I'm having an issue when I'm uploading an app bundle to the play console that:
You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set. This file can't be installed on Android 12 or higher.
But my manifest file includes the property.
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="**********">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="*****"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_stat_artboard_1" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="Z*********"/>
<provider
android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
android:authorities="im.mingguang.mingguang_app.flutter_downloader.provider"
android:grantUriPermissions="true"
android:requestLegacyExternalStorage="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
<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:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Play Console Error
I solved it by writing
android:exported="true"
in activity below the android:name=".MainActivity".
On about the 11th of January 2022, the Play Store introduced a lint check when uploading APKs to verify exported attributes are set correctly in the manifest.
Tools like DexGuard that obfuscate attribute names will cause the Play Store linter to fail, since it will be unable to check for exported attributes.
To fix this, configure obfuscation tools to keep attribute names in the manifest.
Here is the rule we used for DexGuard:
-keepresourcexmlattributenames manifest/**
I added android:exported="true" to my main activity, but that didn't fix the issue for me.
However, I suspected this is a change that some packages have only recently implemented. I checked my pub outdated, and had a few older versions of key packages (in my case I was a major version behind on Firebase storage). Once I had updated to the latest possible versions in file pubspec.yaml the compiled file was accepted on upload to the Google Play.
In your manifest file, check all the activities, services, and receivers that uses intent-filter without the android:exported tag.
In your main manifest file, you can simply add the android:exported property to the activity tag, so add android:exported="" and set a Boolean value inside these quotation marks.
You might ask: When do I need to add android:exported="true" or android:exported="false" to the activities, services, or broadcast receivers that use intent filters? If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.
Note: also check individual third-party library manifest files if there is any activity, service or receiver using them. You have to override the same activity, service or receiver in your main manifest file with the android:exported property.
For more explanation, you can refer to my answer on same problem.
If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.
If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.
The following code snippet shows an example of a service that contains an intent filter whose android:exported attribute is set to false:
<service android:name="com.example.app.backgroundService"
android:exported="false">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</service>
<receiver android:name="com.example.app.serives.SilentPushReceiver"
android:exported="false">
<intent-filter>
<!-- Receive silent push notifications. -->
<action
android:name="uz.usoft.kidya.action.ymp.SILENT_PUSH_RECEIVE"/>
</intent-filter>
</receiver>
<activity android:name="com.example.app.SplashScreenActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.app.MainActivity"
android:exported="false"/>
About information: Safer component exporting
its_broke_again's answer works perfectly for me. I'm describing the steps to make things a little easier.
Enter the following commands in the terminal
flutter pub upgrade --major-versions
flutter clean
flutter build appbundle
Add android:exported="true" in file AndroidManifest.xml
<activity
android:name=".MainActivity"
android:exported="true"
<!-- ... -->
</activity>
I downgraded to targetSdkVersion 30 and compileSdkVersion 30 in file build.gradle.
It should work fine.
In my case geocoding was the package which caused the problem
So it wouldn't build with the 30 SdkVersion, so I had to deleted the exception which refers to Android S "API 31".
For Flutter:
If you changed AndroidManifest and you still face the same error, the problem is caused by a package. To identify the package, search for '<intent-filter' in the "build" folder, and then find if '<intent-filter' has a parent without android:exported="true/false".
Then you should upgrade the package.
If you are using the latest version, then you need to contact the package developer, or clone it and use your GitHub version.
For me, adding android:exported="true" to MainActivity was not enough.
But I also had to remove the Huawei agcp and hms for push notification to let it work.
It seems that it uses an activity, activity alias, service or broadcast without android:exported.
An Android manifest file highlights the error. Generally, wherever we have used intent filter, it requires us to set the attribute android:exported="true".
The default activity should be set as "true". The rest can be set either to "true" or "false", depending on whether we want other apps to fire our activity/service.
If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.
Warning: If an activity, service, or broadcast receiver uses intent filters and doesn't have an explicitly-declared value for android:exported, your app can't be installed on a device that runs Android 12 or higher.
If the app component includes the LAUNCHER category, set android:exported to true. In most other cases, set android:exported to false.
The following code snippet shows an example of a service that contains an intent filter whose android:exported attribute is set to false:
<service android:name="com.example.app.backgroundService"
android:exported="false">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</service>
I had the same error and for two days I was trying to fix it.
Firstly, android:exported="true" did not work for me, because I added to only one activity.
I updated the Unity version (it did not work at that time, and maybe had an effect)
I added android:exported="true" in every activity field, and then voilĂ , it worked.
My Unity game now looks like:
<?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.unity3d.player" android:installLocation="preferExternal" tools:ignore="MissingLeanbackSupport">
<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="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />
<uses-feature android:glEsVersion="0x00020000" />
<application android:name="androidx.multidex.MultiDexApplication" android:fullBackupContent="false" android:allowBackup="false" android:theme="#android:style/Theme.NoTitleBar" tools:ignore="GoogleAppIndexingWarning,MissingTvBanner" tools:replace="fullBackupContent,allowBackup">
<!-- UNITY -->
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="#string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:resizeableActivity="false" android:hardwareAccelerated="false" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="android.notch_support" android:value="true" />
</activity>
<!-- FULLSCREEN FIX -->
<meta-data android:name="android.max_aspect" android:value="2.16" />
<!-- 3rdParty MANIFEST -->
<activity android:name="com.facebook.unity.FBUnityLoginActivity" android:exported="true" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:exported="true" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.unity.FBUnityGamingServicesFriendFinderActivity" android:exported="true" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
<activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
<activity android:name="com.facebook.unity.FBUnityGameRequestActivity" android:exported="true"/>
<activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" android:exported="true"/>
<activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" android:exported="true"/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb901505887229125" />
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="true" />
<meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="true" />
<provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider901505887229125" android:exported="true" />
<meta-data android:name="unity.splash-mode" android:value="0" />
<meta-data android:name="unity.splash-enable" android:value="True" />
<meta-data android:name="unity.allow-resizable-window" android:value="False" />
<meta-data android:name="notch.config" android:value="portrait|landscape" />
<meta-data android:name="unity.build-id" android:value="31d4e179-c52c-49d7-a4f5-da548e453521" />
<receiver android:name="com.unity.androidnotifications.UnityNotificationManager" android:exported="true" />
<receiver android:name="com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver" android:exported="true" android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
<uses-feature android:name="android.hardware.vulkan.version" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>
You can see android:exported="true" added in every activity and receiver.
Reading the document Safer component exporting, it looks like if your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported property for these app components.
If your app is small, you might just need to add the android:exported property in the AndroidManifest.xml for every node using intent-filter.
But if you're using many external dependencies, modifying only the main manifest file might not be enough.
You might need to do it for every third-party library that you have in your project that contains an intent-filter node without the android:exported property.
You can find the list of all the activity, activity alias, service or broadcast into the merged manifest.
If you cannot find it using Android Studio:
Downgrade targetSdkVersion: 30 and compileSdkVersion: 30 in the build.gradle to be able to build.
Build the project on an android device
Then you can check the merged manifest into /project_name/build/app/intermediates/merged_manifests/debug/out/AndroidManifest.xml.
Now you can check every individual third-party library where the android:exported is missing. And declare them explicitly in the main manifest file.
Then you can change back to targetSdkVersion: 31 and compileSdkVersion: 31 and check if it is working.
In my Flutter app, I just had to change 1 line in <activity> in file android/app/src/main/AndroidMainfest.xml.
<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"> <!-- I added this line -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Also, I am using compileSdkversion 31 and targetSdkVersion 31.
After unit testing, we found the problem was from the package epub_viewer: ^0.2.5. The AndroidManifest.xml file of this package was empty:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jideguru.epub_viewer">
</manifest>
And also doesn't have any activity or service, but this solution works for me, by adding these lines of code to my AndroidManifest.xml file:
<activity
android:name="com.folioreader.ui.activity.SearchActivity"
android:exported="true"
tools:node="merge" />
Google Play accepted my AppBundle.
You need to change all the used libraries in file pubspec.yaml to an updated version whether they are using the 'exported' thingy in the manifest file.

After publishing my unity game to Google Play and installing from the store, there is no Open/Play button

The game is listed on Google Play, but when I install it there is only an uninstall button. Also, the game icon is not added to the device. I've tried with multiple devices.
In settings -> apps, I can find the game, but no option to launch it.
This is my first game and I'm very excited, so will appreciate any help !!
The game:
https://play.google.com/store/apps/details?id=com.ijgames.morf
You need to add the UnityPlayerActivity to your manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="schemas.android.com/apk/res/android"
package="com.google.unity.ads" android:versionName="1.0"
android:versionCode="1">
<uses-sdk android:minSdkVersion="5" />
<application>
<uses-library android:required="false" android:name="org.apache.http.legacy" />
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-6148490449331637~7579554346" />
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="#string/app_name" android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
</application>
</manifest>
Actually the main reason was that I haven't built apk for last version and was building aab, which was not showing errors. So I fixed the errors for apk build and all good.

flutter audio_service not working, errors in AndroidManifest.xml

I am attempting to recreate the audio_service tutorial on GitHub and it is not working, no sound is playing when you click the play button. I have observed an error in the AndroidManifest.xml which seems to be related - the documentation of course requires you add lines to the AndriodManifest.xml file.
However I am getting errors on the lines and which I suspect could be causing the problem. The errors are "Class referenced in the manifest, _______ , was not found in the project or the libraries / Unresolved package '___' " for both.
I did include these dependencies in my pubspec.yaml:
audio_service: ^0.15.1
just_audio: ^0.5.2
Note that I am having the same problem on both my Windows 10 development environment and on my MacBookPro running Catalina. Does anyone know how I can resolve this? What am I missing?
Here is my complete AndroidManifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tv.realhelp.new_audio_service_test">
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="new_audio_service_test"
android:icon="#mipmap/ic_launcher"
android:usesCleartextTraffic="true">
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<service android:name="com.ryanheise.audioservice.AudioService">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
</application>
</manifest>

Starting an Android service from a different package

I can't seem to start my android service when the service code is in another package that is not the same package as the MainActivity of the main app.
I have tried many many ways, even the AIDL method, and I can't get it to work at all.
MainActivity code
ServiceIntent.setComponent(new ComponentName("com.service.luna","com.service.luna.VService" ));
bindService(ServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
MainActivty Manifest
<?xml version="1.0" encoding="utf-8"?>
<!-- <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" /> This is set from Gradle -->
<!-- Needed for camera passthrough -->
<!--<uses-permission android:name="android.permission.CAMERA" />-->
<!-- Needed to write thumbs -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Needed to for volume -->
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- Needed for Google Play Services GPS -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.usb.host" />
<!-- Needed for uploading crash reports -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
<application android:allowBackup="true" android:icon="#drawable/ic_launcher" android:label="#string/app_name"
android:hardwareAccelerated="true" android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
<!-- singleTask launchMode because we never want multiple copies of the app running, -->
<!-- but we might want to internally spawn other activities -->
<!-- Theme.DeviceDefault.NoActionBar.Fullscreen gives solid black instead of a (bad stereoscopic) gradient on app transition -->
<activity android:name="com.main.luna.MainActivity"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="screenSize|orientation|keyboardHidden|keyboard"
>
<!-- this filter lets the apk show up as a launchable icon -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.service.luna.VService" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.service.luna.VService" android:process=":VServiceRemote" android:exported="true" android:enabled="true">
<intent-filter>
<action android:name="com.service.luna.VService"/>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<receiver android:name="com.main.luna.ConnectivityChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
</application>
Service Code
public class VService extends Service implements Serializable{
....
Service Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.service.luna">
<application
android:allowBackup="true"
android:label="#string/app_name"
android:supportsRtl="true">
</application>
When My code finally runs, I receive a
bindService callerProcessName:com.main.luna, calleePkgName: com.service.luna, action: null
Unable to start service Intent { pkg=com.service.luna cmp=com.service.luna/.VService } U=0: not found
The name of the main package is com.main.luna and the service is in package com.service.luna
If someone has solved this before, please let me know.
Try to enable the exported option in your manifest while adding your service ( android:exported="true")
<service android:enabled=["true" | "false"]
android:exported=["true" | "false"]
android:icon="drawable resource"
android:isolatedProcess=["true" | "false"]
android:label="string resource"
android:name="string"
android:permission="string"
android:process="string" >
. . .
</service>
and make sure you are using the Correct name of your Package name
Also check this post having similar situation
How do I start a service which is defined in a different package?

Mobile game restarts when using Application.Quit

Okay, so I upgrade my old 4.6 Unity project into Unity 5.0. Overall, the process was relatively painless, but now my Quit button doesn't work when I build for Android.
And I get a very odd message via logcat:
E/Unity (23691): RenderTexture warning: Destroying active render texture. Switching to main context.
E/Unity (23691):
E/Unity (23691): (Filename: Line: 295)
E/Unity (23691):
My quit code in my GameController script is pretty simple:
public void Quit () {
Application.Quit();
}
void OnApplicationQuit () {
if (showAds) { //just in case
adController.DestroyAll();
}
}
What should I be looking for? Is it a texture issue? I do have a custom shader, but the game worked fine with Unity 4.6 before.
So, it all went back to Unity5 and how it integrates older plugins like Admob. Apparently, there is no ProxyActivity needed anymore for Android builds. So I completely removed the following out of the AndroidManifest.xml file:
<activity android:name="com.unity3d.player.UnityPlayerProxyActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And then moved the <intent-filter> into the UnityPlayerActivity:
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Now Application.Quit() works no problem!
Complete AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.example.admobtest" android:versionName="1.0" android:versionCode="1">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<!-- Mobile Ads Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="false">
<!-- meta-data tag for Google Play services -->
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version"/>
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<meta-data android:name="android.app.lib_name" android:value="unity" />
</activity>
<activity android:name="com.unity3d.player.VideoPlayer" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" >
</activity>
<!-- Google Mobile Ads Activity -->
<activity android:name="com.google.android.gms.ads.AdActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
</activity>
<!-- PurpleBrain AdBuddiz Activity -->
<activity android:name="com.purplebrain.adbuddiz.sdk.AdBuddizActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent">
</activity>
</application>
<uses-feature android:glEsVersion="0x00020000" />
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
</manifest>
#theprisoner6 aswer doesn't work for me but for reference the another option is to hide an application (move it to back). This has added value that if the Android decide it is worth to keep the app in memory you will avoid loading an application which should improve user experience. This could be handled as a plugin but hey, there is no need for that! Very simple C# code:
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
var movedToBack = jo.Call<bool>("moveTaskToBack", true);
Swap that code with Application.Quit() and you are done.