Posts tagged with android

I couldn't run instrumental(UI) tests after Google Ads dependency implementation. The runner crashed every time; I tried to implement it to the dummy project because initially, I thought that the problem was in my project but it seemed not I got the same result on the dummy project, So merely my instrumental tests didn't run. I have inspected the Google Ads dependency and spotted that the root cause was google ads-lite which is used by the google ads library. I tried a few variants such as change runner, run it on x86, x64platforms, change lib version, changeGradle` version, change AGP version. But I can't find a solution.

Steps to reproduce:

Create a dummy project(runner: "androidx.test.runner.AndroidJUnitRunner") Run an instrumental test to make sure that was passed successfully implement com.google.android.gms:play-services-ads: 20.5.0(or latest version) Run an instrumental test it should be stuck because of the runner crash

I have a problem implementing AdMob with my Android app, ads are not showing for my package name, I changed the name and everything works fine, I restored the prod name and everything stopped working with the error: no ad config, this is my first time using AdMob, which means the ads work for a while and then suddenly stop is not the case here, I don't suspect anything wrong with the code because I followed everything in the documentation and, as I said, everything works fine when I change the package name to a random string.

  1. Is app-ads.txt correct? yes, app-ads.txt file found and verified (100% of queries authorized)
  2. Policy center: no current issues, no disapproved apps
  3. App linked to admob? yes it is linked through google play and I noticed the icon is updated
  4. PIN verification: I still didn't reach the verification threshold
  5. Is Google Ads and Adsense linked to Admob? yes, and with the same email
  6. Admob status: Your account is approved
  7. App approval status: Ready (Ad serving enabled)
  8. App stores: Google Play
  9. Ad format: Rewarded
  10. Ads activity performance, Requests: 0 (ZERO)

Note 1: the email I am using on play console is diff from the email of admob / ads / adsense

Note 2: the prod app is already launched in google play store

Any help guys?

MainActivity.java:

package com.example.admob; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Toast; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.LoadAdError; import com.google.android.gms.ads.MobileAds; import com.google.android.gms.ads.OnUserEarnedRewardListener; import com.google.android.gms.ads.RequestConfiguration; import com.google.android.gms.ads.initialization.InitializationStatus; import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; import com.google.android.gms.ads.rewarded.RewardItem; import com.google.android.gms.ads.rewarded.RewardedAd; import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback; import java.util.Arrays; public class MainActivity extends AppCompatActivity {     private RewardedAd mRewardedAd;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         /**/         RequestConfiguration configuration = new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("PEO7WS709MHDMHS0KA74LQ4KDPL9V8DJ")).build();         /**/         MobileAds.setRequestConfiguration(configuration);         /**/         MobileAds.initialize(this, new OnInitializationCompleteListener() {             @Override             public void onInitializationComplete(InitializationStatus initializationStatus) {             }         });         AdRequest adRequest = new AdRequest.Builder().build();         RewardedAd.load(this, "ca-app-pub-2887021452579791/7518976046",                 adRequest, new RewardedAdLoadCallback() {                     @Override                     public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {                         // Handle the error.                         Log.d(TAG, loadAdError.getMessage());                         Toast.makeText(MainActivity.this, loadAdError.getMessage(), Toast.LENGTH_SHORT).show();                         mRewardedAd = null;                     }                     @Override                     public void onAdLoaded(@NonNull RewardedAd rewardedAd) {                         mRewardedAd = rewardedAd;                         Log.d(TAG, "Ad was loaded.");                         Toast.makeText(MainActivity.this, "Ad was loaded", Toast.LENGTH_SHORT).show();                     }                 });         findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View view) {                 if (mRewardedAd != null) {                     Activity activityContext = MainActivity.this;                     mRewardedAd.show(activityContext, new OnUserEarnedRewardListener() {                         @Override                         public void onUserEarnedReward(@NonNull RewardItem rewardItem) {                             // Handle the reward.                             Log.d(TAG, "The user earned the reward.");                             Toast.makeText(MainActivity.this, "onUserEarnedReward", Toast.LENGTH_SHORT).show();                         }                     });                 } else {                     Log.d(TAG, "The rewarded ad wasn't ready yet.");                     Toast.makeText(MainActivity.this, "Not ready!", Toast.LENGTH_SHORT).show();                 }             }         });     } } 

Manifest.xml:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.admob">     <application         android:allowBackup="true"         android:icon="@mipmap/ic_launcher"         android:label="@string/app_name"         android:roundIcon="@mipmap/ic_launcher_round"         android:supportsRtl="true"         android:theme="@style/Theme.AdMob">         <meta-data             android:name="com.google.android.gms.ads.APPLICATION_ID"             android:value="ca-app-pub-2887021452579791~7783129272"/>         <activity             android:name=".MainActivity"             android:exported="true">             <intent-filter>                 <action android:name="android.intent.action.MAIN" />                 <category android:name="android.intent.category.LAUNCHER" />             </intent-filter>         </activity>     </application> </manifest> 

I am following this guide but it seems depricated? Or please correct me if I'm wrong. There is no kotlin version. I am implementing this part, where we get keyword ideas from API call

https://developers.google.com/google-ads/api/docs/keyword-planning/generate-keyword-ideas

But after implementing it I am stuck on a piece of sending parameters. Could you please guide me on where can I get these parameters below

We're using google ads apps to download ads to promote apps. After the user opens the app by clicking on the advertisement installation, the install referrer information will be obtained through the play install referrer API and uploaded to our user log system. But there is no utm_campaign information in all the user's install referrer information uploaded now.

Here's information for some users' install referrers:

  1. Users who install apps from ads in YouTube: pcampaignid=inline|youtubeads|9416164 (only this one parameter) 2, from google play ads to install app users: gclid=CjwKCAiAg6yRBhBNEiwAeVyL0Bt1IRkH-LVH0n7FjV9ohyKeL9tEzwj9qWtL9pNExWSCHN94jBF0kBoC7kIQAvD_BwE (only this one parameter) 3, there are some users: utm_source = google-play & utm_medium = organic (only these two parameters) 4, there are some users: utm_source = (not_set) & utm_medium = (not_set) (only these two parameters)

Retrieved, none of the user's install referrer contains utm_campaign information. Have you ever encountered this problem?

I would like to know, why these errors and how to solve them, when I use flutter run, flutter returns these errors:

Launching lib\main.dart on BISON in debug mode... Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Formato de par�metros incorreto - Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider_android-2.0.9\android\src\main\java\io\flutter\plugins\pathprovider\PathProviderPlugin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. e: C:/Users/Arthur Alland/.gradle/caches/transforms-2/files-2.1/ae449724a6ca38888aadaf690b25af94/work-runtime-2.7.0-api.jar!/META-INF/work-runtime_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version  is 1.1.15. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 6m 1s Running Gradle task 'assembleDebug'...                            365,1s Exception: Gradle task assembleDebug failed with exit code 1 

Android Build Gradle

buildscript {     ext.kotlin_version = '1.3.50'     repositories {                                  google()                  jcenter()     }     dependencies {         classpath 'com.android.tools.build:gradle:4.1.0'         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"     } } allprojects {     repositories {         google()         jcenter()      } } rootProject.buildDir = '../build' subprojects {     project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects {     project.evaluationDependsOn(':app') } task clean(type: Delete) {     delete rootProject.buildDir } 

Gradle Wrapper Properties

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip 

Android Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.you_plan">     <!-- 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="you_plan"         android:icon="@mipmap/ic_launcher">         <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">             <!-- Specifies an Android theme to apply to this Activity as soon as                  the Android process has started. This theme is visible to the user                  while the Flutter UI initializes. After that, this theme continues                  to determine the Window background behind the Flutter UI. -->                           <meta-data               android:name="io.flutter.embedding.android.NormalTheme"               android:resource="@style/NormalTheme"               />             <!-- Displays an Android View that continues showing the launch screen                  Drawable until Flutter paints its first frame, then this splash                  screen fades out. A splash screen is useful to avoid any visual                  gap between the end of Android's launch screen and the painting of                  Flutter's first frame. -->             <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>         <!-- 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" />               <meta-data     android:name="com.google.android.gms.ads.APPLICATION_ID"     android:value="ca-app-pub-3940256099942544~3347511713"/>     </application> </manifest>

I googled it several times and the problem seems to be with these android files, but I don't have much experience with android