I have in the past successfully implement the Google AdMob, but this time with a new project, it's impossible!
I have error with Google AdMob integration in a blank Xamarin.Forms project.
In the standard project :
Have theres Nuget packages already installed :
NETStandard.Library 2.0.3
Xamarin.Essentials 1.3.1
Xamarin.Forms 4.4.0.991265
Create AdmobControl class
In the MainPage.xaml.cs add the AdmobControl with the banner ad id for Android TEST : "ca-app-pub-3940256099942544/6300978111"
In the Android project :
Have theres Nuget packages already installed :
Xamarin.Essentials 1.3.1
Xamarin.Forms 4.4.0.991265
Then install the Nuget package Xamarin.Firebase.Ads 71.1601.0
In the MainActivity, inititialize Ads before Xamarin.Forms.Init, with App id for Android TEST : "" -> empty string
Add ACCESS_NETWORK_STATE permission
Add INTERNET permission
Add the line in the AndroidManifest.xml between the tag
Create AdMobRenderer class
The problem :
The compilation is ok BUT, when I deploy on app on my device, I have 2 errors :
error: MediationRewardedVideoAdListenerImplementor is not abstract and does not override abstract method zzc(Bundle) in MediationRewardedVideoAdListener
public class MediationRewardedVideoAdListenerImplementor TestAdMob.Android C:\Users\TheFloods\source\repos\TestAdMob\TestAdMob\TestAdMob.Android\obj\Debug\90\android\src\mono\com\google\android\gms\ads\reward\mediation\MediationRewardedVideoAdListenerImplementor.java 4
JAVAC0000: error: MediationRewardedVideoAdListenerImplementor is not abstract and does not override abstract method zzc(Bundle) in MediationRewardedVideoAdListener
public class MediationRewardedVideoAdListenerImplementor 0
Source code available here : https://github.com/TheFloods/XamarinTestAdMob
I have try following theres tutorials :
https://www.codeproject.com/Tips/1275283/Xamarin-Forms-Integration-with-Google-Admob
https://montemagno.com/xamarinforms-google-admob-ads-in-android/
https://xamarinhelp.com/admob-xamarin-forms-display-google-ads-mobile-app/
Others informations :
Visual Studio Community 2019 16.5.4
Windows 10 PRO 1803
Thank you for your help.
Thank you for your help you two.
I have solved the problem like this :
Uninstall the Xamarin.Firebase.Ads
Install the Xamarin.Firebase.Ads.Lite
Add the app ip in the AndroidManifest.xml, after the activity tag
Install the Xamarin.GooglePlayServices.Ads.Lite, then it works!
Related
I'm using capacitor v3 beta and there are no problem working in web and iOS but can't run android app.
Build is done fine but when running the app appears this error:
E/Capacitor/Console: File: http://localhost/vendor-es2015.js - Line 41296 - Msg: ERROR Error: Uncaught (in promise): Error: "Storage" plugin is not implemented on android
Error: "Storage" plugin is not implemented on android
To solve this error I've removed the storage plugin and replaced with ionic/storage plugin. But when I use other plugin, for example the Keyboard, the error shows up saying that Keyboard plugin is not implemented on android.
So I suppose that there is some problem with Android builds or project configuration.
These are de node dependencies in my package.json
"#capacitor/android": "^3.0.0-beta.6",
"#capacitor/core": "^3.0.0-beta.1",
"#capacitor/storage": "^0.3.1",
And my capacitor.config.json file
{
"appId": "net.flowww.me",
"appName": "FLOWwwMe",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "www",
"cordova": {}
}
iOS version works well with this configuration.
Storage plugin not worked after Ionic v3 upgrades from v2.
It work after manually adding a plugin to MainActivity.java for me:
package com.ionic.app;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.capacitorjs.plugins.storage.StoragePlugin;
public class MainActivity extends BridgeActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(StoragePlugin.class);
}
}
I also faced the same problem when upgrading from capacitor 2 to 3
As it turned out, I forgot to execute:
npx cap sync android
This solved the problem
you must in mainActivity : add(StoragePlugin.class);
After creating new project and reviewing file differences saw that I have not installed
"#capacitor/cli": "^3.0.0-beta.6"
So I installed it and all compiles successfully.
In Capacitor's v2 doc, in the page dedicated to Storage Plugin (https://capacitorjs.com/docs/apis/storage) the import is done like:
import { Storage } from '#capacitor/storage';
Then in the Capacitor's v2 doc for Using Plugins (https://capacitorjs.com/docs/v2/apis) you'll find that:
Import the Plugins object. It represents the registry of all Capacitor plugins.
import { Plugins } from '#capacitor/core';
Get a plugin from the Plugin Registry (Plugins object).
const { Browser } = Plugins;
Use the plugin API:
async openBrowser() {
// On iOS, for example, open the URL in SFSafariViewController (the in-app browser)
await Browser.open({ url: "https://ionicframework.com" });
}
A common mistake is to import a plugin directly, then use the plugin API >immediately, resulting in the web implementation being used:
import { Browser } from '#capacitor/core';
async openBrowser() {
// On iOS, for example, this will open the URL in Safari instead of
// the SFSafariViewController (in-app browser)
await Browser.open({ url: "https://ionicframework.com" });
}
By using the plugins from the plugin registry (Plugins object), the native implementation of the plugin is used (if available), with fallback to the web version.
So if you're using Quasar with Capacitor v2 you probably gone crazy like me. Just replace Browser with Storage.
Maybe in v3 that problem is solved and that's why legomolina's answer works.
For Capacitor V3 plugins (tested on Android 11 & Ionic 5)
capacitor.plugins.json has the entry for Storage plugin,
MainActivity.java should not have the onCreate function, where CapV3 uses native API,
Try setting minifyEnabled=false in build.gradle.
If error disappears, create pro-guard rules in proguard-rules.pro as in https://github.com/ionic-team/capacitor/issues/739
I found the issue was solved by simply starting up Android Studio. It sync'd Gradle automatically and then I just restarted my Android dev environment - the error was gone and I was able to access Storage as per the capaitor plugin docs.
See https://capacitorjs.com/docs/android/troubleshooting#plugin-not-implemented
I'am following a tutorial from here https://github.com/google-pay/android-quickstart , i downloaded the code and try to run it but it complains about
package com.google.android.gms.samples.wallet.databinding does not exist
which is logically true , as the package does not exist , but i assume downloading from the official site i should not be facing such problem.
I have not changed anything from the link i just downloaded and ran it in my Android studio. how do i resolve this??
Please help.
Versions
Android Studio version : 4.01
Android Version : 7.1.2
google-play : 2020.10.22037
I contacted Google for the same issue, and was told
The class is generated from View binding. View binding is enabled from build.gradle (you can find it from github as well)
viewBinding {
enabled =
true
}
And given this link to the relevant documentation.
My app is under Ionic 4 for android and I have to open/run/launch external app (for exemple com.google.android.youtube or com.sygic.truck) -> for instance, any installed app.
I tested many options without any success :
InAppBrowserModule (using application://my.package.name).
Cordova plugin lampaa (I didn't find any ways to use it under angular/ts app type).
I tried also webIntent using package option and action option calling the main Activity.
For InAppBrowserModule, i'm stuck with the http:// protocole appended before my app url.
For Lampaa, i'm stuck with the undefined startApp (even after following other threads suggestions).
And for webIntent, I don't think that it's relevent for my issue.
Any suggestions ?
Thanks in advance !
[EDIT]
I finally make it works !
You can use one of those 2 lines :
this.iab.create('android-app://com.google.android.youtube',"_system");
window.open('android-app://com.google.android.youtube',"_system");
You can replace com.google.android.youtube by any application package name !
You can check if the user is on Android, have the app installed and later open it as follow:
constructor(
private platform: Platform, // from 'ionic-angular'
private appAvailability: AppAvailability, // from '#ionic-native/app-availability'
private iab: InAppBrowser, // from '#ionic-native/in-app-browser'
) {}
openYoutube() {
const package = "com.google.android.youtube"
if(this.platform.is('android')) {
this.appAvailability.check(package)
.then(()=> {
this.iab.create('android-app://'+package, '_system', 'location=yes')
})
.catch(()=> {
// not installed
)
} else {
// not on Android
}
}
For ionic 4 we can use
ionic cordova plugin add cordova-plugin-app-launcher
npm install #ionic-native/app-launcher
You can use the following cordova plugin to check if other apps are installed and launch them.
ionic cordova plugin add cordova-plugin-app-launcher
npm install #ionic-native/app-launcher
Simple Cordova plugin to see if other apps are installed and launch them.
To be clear on what i am asking i will provide a real world example. take look at this and notice the following section:
Hotline - Android SDK Integration Steps Modified on: Fri, 6 Oct, 2017 at 8:21 PM
Integrate Hotline SDK (Using Gradle) Pre Requisites :
Hotline SDK clients require devices running Android 2.3 or higher
Hotline App Id and App Key from here: Where to find App ID and App Key
Android Studio and Gradle
If you have any queries during the integration, please send it to us - Submit a Query
1. Add Hotline SDK to your app
Add the maven URL to the root build.gradle (project/build.gradle)
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
Add the following dependency to your app module's build.gradle file
(project/app/build.gradle):
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.github.freshdesk:hotline-android:1.2.+'
}
1.1 Android target version supported
Hotline SDK supports apps targeting Android version 5.0+. The SDK
itself is compatible all the way down to Gingerbread (API Level 10).
When app targets Android 7.0+
When FileProvider is not configured for Hotline SDK, the following
error code is displayed
"Missing/Bad FileProvider for Hotline. Camera capture will fail in devices running Nougat or later versions of OS (error code 354)"
To fix this, please include the provider in the
AndroidManifest.xml as below and specify the authority in strings.xml.
Assuming, com.example.demoapp is the package name of your app, the
declaration would be
AndroidManifest.xml
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.demoapp.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/hotline_file_provider_paths" />
</provider>
Strings.xml
<string name="hotline_file_provider_authority">com.example.demoapp.provider</string>
When app targets Android 8.0+
When the app's target is Android 8.0 or later, and by extension includes appcompat-v7 r26.0.0.+, you'll see the following errors
E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/freshdesk/hotline/activity/InterstitialActivity;
Hotline SDK's activities extends ActionBarActivity to keep the SDK
compatible with app's targeting older Android versions/appcompat-v7
revisions. It can be resolved by adding a proxy class
(ActionBarActivity was replaced by AppCompatActivity and was proxied
by lib itself since 24.2.0 of appcomapt-v7, until it was removed in
26.0.0) manually if you are building with support library 26.x.x.
Add the following class in the appropriate package
package android.support.v7.app;
public class ActionBarActivity extends AppCompatActivity {
}
my question has nothing to do with Hotline. But after i did what they asked my package structure looks like this:
now that you have some background let me tell you what i dont understand. Does this mean that i am overriding any calls in package android.support.v7.app.ActionBarActivity ? so does this mean that for any 3rd party build i have i can override its classes this way as long as i know the package and class name ?
Basically what does it mean to put package name of something i do not own into my package structure ? what does it do ?
UPDATE: look at this article here as another example . if you read solution 3 you see we can do the same thing with facebook.login. i personally implemented this and it works. my test package structure looks like this and it overrides facebooks loginCreator etc:
even though i implemented it, i still dont get whats happening. can someone explain ?
I create Xamarin.Forms app and use Acr.Biometrics plugin. In PCL I check available finger print for device.
private async void AvailableBiometric()
{
bool available = await Biometrics.Instance.IsAvailable();
lblStatus.Text = available ? "Yes" : "No";
}
When I launch my app on Windows 10 emulator (UWP project), I get result false ("NO") and it's correct. But when I launch app on Android 6.0 (Emulator or real device with finger authorization), I get Exception "".
I find source code this plugis on GitHub. My Exception generate this plugin's code:
I don't understand what do I wrong and why for Windows app this Exception did not generate. If who know, please, help me.
I don't understand what do I wrong and why for Windows app this Exception did not generate.
I tried to only install Acr.Biometrics Package to PCL, and debugged UWP project. It also threw the exception.
If you want to use lib of Acr.Biometrics in Android and UWP platform,
please make sure you have installed Acr.Biometrics nuget package to Android and UWP project.
You can right click your solution--> Manage NuGet Package for solution-->select the Installedbutton-->left click Acr.Biometrics NuGet Package.
Check the xxx.Droid project option.And then press the install button. The installation is done later.
For Android support, you need to add the following to your AndroidManifest.xml:
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
Usage
In your shared/PCL library, simply check if the sensor is available:
protected async override void OnAppearing()
{
base.OnAppearing();
if (await Biometrics.Instance.IsAvailable())
{
var success = await Biometrics.Instance.Evaluate("Your custom message");
if (success)
{
//do some stuff
}
}
}