Xamarin.Forms AdMob "Missing AdActivity" - c#

I have a problem implementing AdMob in my Xamarin.Forms project.
So when I run the android app this is shown in the output:
01-22 16:53:17.351 W/Ads (3529): Missing AdActivity with android:configChanges in AndroidManifest.xml.
You must have the following declaration within the <application> element:
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
But my Manifest got this line in it..:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
And when I open the page containing the ad this is showing:
What is wrong here ?

<activity> tag should be inside the <application> tag
<application>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>

Related

Open APK programmatically with Xamarin Forms - Android 8.1

I am trying to install an APK from my Xamarin.Forms application.
I've created a DependencyService in Android implementation using FileProvider with this piece of code:
Java.IO.File file = new Java.IO.File(updtFile);
var realUri = Android.Support.V4.Content.FileProvider.GetUriForFile(MainActivity.Instance, MainActivity.Instance.PackageName + ".provider", file);
Intent install = new Intent(Intent.ActionInstallPackage);
install.AddFlags(ActivityFlags.GrantReadUriPermission);
install.AddFlags(ActivityFlags.GrantWriteUriPermission);
install.AddFlags(ActivityFlags.GrantPersistableUriPermission);
install.SetDataAndType(realUri, "application/vnd.android.package-archive");
MainActivity.Instance.StartActivity(install);
It works flawlessly with Android 7, opening the package manager as expected.
It does absolutely nothing with Android 8.1, not even throwing an exception or so. I have all permission enabled for the app and if I try to open the APK with file explorer it works without any problem.
This is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0.1.0" package="..." android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="..." android:icon="#drawable/icon">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/provider_paths" />
</provider>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
</manifest>
And this is provider_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="." />
</paths>
Am I missing something?
Thanks.
Found it! I was missing this permission in Manifest:
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

I am trying to write a xamarin forms application to simply take a photo and save the image,

The error i am getting is as follows
System.ArgumentException: 'Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file.
I have gone through all the suggestions i can find regarding permissions for fileprovider to no avail
The code where it is failing is..
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "",
SaveToAlbum = true
});
(I have tried setting "Directory" to "images", "pictures" and just about anything else you can think of !
resources/file_paths.xml is...
<?xml version="1.0" encoding="utf-8" ?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-files-path name="my_images" path="Pictures" />
<external-files-path name="my_movies" path="Movies" />
</paths>
My AndroidManifest .xml is ...
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.app1" android:installLocation="auto">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="28" />
<application android:label="App1.Android" android:icon="#drawable/Woodstonelogo"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:label="App1.Android">
<provider android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths"></meta-data>
</provider>
</application>
</manifest>
Cause :
In your AndroidManifest.xml you define two application tags . So the first one will work in default . So the provider will never been set as it's in the second tag .
Solution:
Modify the code like following
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.app1" android:installLocation="auto">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="28" />
<application android:label="App1.Android" android:icon="#drawable/Woodstonelogo">
<provider android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths"></meta-data>
</provider>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>

xamarin android app crashes after multitasking

I have finished my first xamarin android mobile app. It all works fine. I have only one problem that I cannot solve and I could not find solution using google.
When I start my app it all works great but when I press home button, open and close few other apps and come back to app it crashes. Also when I open app and go turn off my screen and then I turn it back on and to back to app it creshes.
Besides that all works great and there is no crashes.
This crash is happening both on emulator and on physical device.
The error I get when this happens on emulator is this:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.name.appname/com.name.android.publish.OverlayActivity}; have you declared this activity in your AndroidManifest.xml?
How to solve this if possible?
Edit:
AndoirdManifest.xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.name.tournamentorganizer" android:installLocation="auto" android:versionName="1.1" android:versionCode="2">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:allowBackup="true" android:label="#string/app_name" android:icon="#drawable/icon11" android:name="android.app.Application" android:debuggable="true">
<activity android:label="Create new tournament" android:theme="#android:style/Theme.Material.Light" android:name="md57e31db4bba5ea713128b60ee6f3868c2.createNewTournament" />
<activity android:label="Tournament Organizer" android:theme="#android:style/Theme.Material.Light" android:name="md57e31db4bba5ea713128b60ee6f3868c2.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="Add new players" android:theme="#android:style/Theme.Material.Light" android:name="md5a2089f5b800658a06dd2a11fca5a1f83.addNewPlayers" />
<activity android:label="addGoalScorer" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.addGoalScorer" />
<activity android:label="All fixtures and results" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.allFixturesAndResults" />
<activity android:label="Players database" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.allPlayersActivity" />
<activity android:label="knockout4Players" android:name="md54d075dbf8b437fae408fa9e57e2203ba.knockout4Players" />
<activity android:label="League" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.leagueType" />
<activity android:label="My tournaments" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.myTournaments" />
<activity android:label="About" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.settings" />
<activity android:label="Player Info" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.stats" />
<activity android:label="table" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.table" />
<activity android:label="Top scorers" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.topScorerActivity" />
<activity android:label="Winners" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.winnersActivity" />
<activity android:label="winnersAllTimeActivity" android:theme="#android:style/Theme.Material.Light" android:name="md54d075dbf8b437fae408fa9e57e2203ba.winnersAllTimeActivity" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="com.name.tournamentorganizer.mono.MonoRuntimeProvider.__mono_init__" />
<!--suppress ExportedReceiver-->
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.com.name.tournamentorganizer" />
</intent-filter>
</receiver>
<meta-data android:name="android.support.VERSION" android:value="25.4.0" />
</application>
</manifest>
Edit2:
I have app version with and without ads. The one without ads does not have this issue. The one with ads does have issue so the ads are problem somehow. I am using startapp ads.
you don't probably use the [Activity] code adornment
[Activity]
internal class YourActivity: Activity {}
If all your activities have
[Activity(Theme = "theme", Label = "name", MainLauncher = true)]
the MainLauncher argument set to true you will run into trouble.
The Activity annotation is used by Xamarin to configure/generate the AndroidManifest.xml
Have you included a MainApplication class, also tagged with the [Application] attribute? Looking at your manifest I am surprised to see the line
<application android:allowBackup="true" android:label="#string/app_name" android:icon="#drawable/icon11" android:name="android.app.Application" android:debuggable="true">
with android:name="android.app.Application". I would expect to see something with an md5 hash (i.e. md5xxx.MainApplication - or whatever the name of your Application class is)
A Clean and Rebuild maybe necessary after changing your application class

Xamarin, Android: "Missing AdActivity with android:config..." C#!

I work on an android app in Visual Studio.
When I implement a simple banner, the banner in this app says:
"Missing AdActivity with android:configChanges in AndroidManifest.xml."
I looked this issue up and many people had this problem but it always was in Android Studio. Can you help me out? I think it might have something to do with my manifest - which looks like that:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.TalkAboutTv2.TalkAboutTv2" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Talk About Tv"></application>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="#android:style/Theme.Translucent" />
</manifest>
THanks :)
You should make some changes to your code:
1) <activity> must be a child of the <application>
2) Add this
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version"/>
to the <application> too.
This should result in the following code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.TalkAboutTv2.TalkAboutTv2" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Talk About Tv">
<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|uiMode|screenSize|smallestScreenSize" android:theme="#android:style/Theme.Translucent" />
</application>
</manifest>

App implementing Parse Unity Plugin crashes on android device but works fine in editor

I am trying to use Parse in my Unity game in order to implement high scores. My problem is that when I try to put the game on my android device to test it, the name of the app comes up different. It comes up as "ParseUnityPushSample" even though I have not changed anything besides adding the files that Parse gives me to use it. The build settings have not changed and it even shows that my package name is the same, yet testing it on a device has this result.
Testing it in Unity 5 works fine. The game loads as it should. This only happens when I try to put it on a device for testing.
Along with it changing the app name, it also crashes when opening. I get a prompt that says "ParseUnityPushSample" has failed anytime I try to open it on an android device.
EDIT:
Okay so I figured out a way to view some errors that occur when testing on a device. I get this error: "Unable to find unity activity in manifest. You need to make sure orientation attribute is set to sensorLandscape manually.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()" I have no idea what the issue is though since I have manually set the orientation for the activity to sensorLandscape in the Android Manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.laserdeflector.sab" android:versionName="1.0.1" android:versionCode="1" android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature" android:name="com.laserdeflector.sab.permission.C2D_MESSAGE" />
<uses-permission android:name="com.laserdeflector.sab.permission.C2D_MESSAGE" />
<uses-permission android:name="com.android.vending.BILLING" />
<application android:label="Laser Deflector" android:icon="#drawable/app_icon" android:screenOrientation="sensorLandscape" android:name="com.soomla.SoomlaApp" android:debuggable="false" android:isGame="true">
<activity android:name=".UnityPlayerActivity">
<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>
</activity>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.laserdeflector.sab" />
</intent-filter>
</receiver>
<service android:name="com.parse.ParsePushService" />
<activity android:name="com.soomla.store.billing.google.GooglePlayIabService$IabActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<meta-data android:name="billing.service" android:value="google.GooglePlayIabService" />
</application>
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<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>
8/10/15
I have come to learn that this may be an issue with Parse v1.5.2 although changing to v1.3.2 did not help with the issue I am facing either. I will update as soon as I learn anything more.
8/11/15
Updating to v1.5.4 did not fix the issue either. Still having problems with the android manifest with the same error message. If anyone has any idea please let me know!
In my case, just taking the Unity sdk was not the answer. In order to make it work I had to use what was in the Unity blank project and then I also deleted the android manifest that v1.5.2 included in the sdk. Doing both of these things allowed the app to work correctly on my android device.
Problem is in your manifest file, you have changed the following lines
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<service android:name="com.parse.ParsePushService" />
to this
<receiver android:name="com.laserdeflector.PushBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<service android:name="com.laserdeflector.ParsePushService" />
Here is the correct manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.laserdeflector.sab"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature" android:name="com.laserdeflector.sab.permission.C2D_MESSAGE" />
<uses-permission android:name="com.laserdeflector.sab.permission.C2D_MESSAGE" />
<application android:label="LaserDeflector" android:icon="#drawable/app_icon">
<activity android:name=".UnityPlayerActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.laserdeflector.sab" />
</intent-filter>
</receiver>
<service android:name="com.parse.ParsePushService" />
</application>
</manifest>

Categories

Resources