简体   繁体   中英

App is crashing when testing it on an emulator

I'm building an app and when I try to test it on an emulator its says unfortunately app has stopped so when I run it I get this errors from the logcat section,the app is static and contain contents without firebase or onesignal, and I run it on DroidX(Android 4.4.4,API 17)

Here is the error I get:

07-29 05:28:00.753 2648-2648/com.tools.med E/Trace: error opening trace 
file: No such file or directory (2)
07-29 05:28:01.709 2648-2648/com.tools.med E/dalvikvm: Could not find 
class 'android.app.AppOpsManager', referenced from method 
com.google.android.gms.common.wrappers.PackageManagerWrapper.zzb
07-29 05:28:01.809 2648-2648/com.tools.med E/AndroidRuntime: FATAL 
  EXCEPTION: main
 java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 

******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
* should follow the instructions here:                                       *
* https://googlemobileadssdk.page.link/admob-android-update-manifest         *
* to add a valid App ID inside the AndroidManifest.                          *
* Google Ad Manager publishers should follow instructions here:              *
* https://googlemobileadssdk.page.link/ad-manager-android-update-manifest.   *
******************************************************************************


    at android.app.ActivityThread.installProvider(ActivityThread.java:4850)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4460)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4400)
    at android.app.ActivityThread.access$1300(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5069)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.IllegalStateException: 

******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
* should follow the instructions here:                                       *
* https://googlemobileadssdk.page.link/admob-android-update-manifest         *
* to add a valid App ID inside the AndroidManifest.                          *
* Google Ad Manager publishers should follow instructions here:              *
* https://googlemobileadssdk.page.link/ad-manager-android-update-manifest.   *
******************************************************************************


    at com.google.android.gms.internal.ads.zzxb.attachInfo(com.google.android.gms:play-services-ads-lite@@18.1.1:27)
    at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(com.google.android.gms:play-services-ads-lite@@18.1.1:3)
    at android.app.ActivityThread.installProvider(ActivityThread.java:4847)
        ... 12 more

AndroidManifest

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name="com.tools.med.Splash">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.mkm.med.MainActivity"></activity>
    meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-"/>
</application>

   apply plugin: 'com.android.application'

android {
   compileSdkVersion 28
    defaultConfig {
    applicationId "com.tools.med"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.ads.consent:consent-library:1.0.7'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
implementation 'com.google.android.gms:play-services-ads:18.1.1'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'

}

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.4.2'
    classpath 'com.google.gms:google-services:4.2.0'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }

}

}

task clean(type: Delete) {
delete rootProject.buildDir

}

Taken from the Link you got in the error Message ( googlemobileadssdk.page.link/admob-android-update-manifest) :

Update your AndroidManifest.xml Add your AdMob App ID to your app's AndroidManifest.xml file by adding the tag shown below. You can find your App ID in the AdMob UI. For android:value insert your own AdMob App ID in quotes, as shown below.

<manifest>
    <application>
        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="YOUR_ADMOB_APP_ID"/>
    </application>
</manifest>

Important: This step is required as of Google Mobile Ads SDK version 17.0.0. Failure to add this tag results in a crash with the message: "The Google Mobile Ads SDK was initialized incorrectly."

You miss the "<" before your meta-data Tag so These meta-data aren't recognized by your application. I Guess you got an AdMob App ID but didn't post it, otherwise you Need an AdMob App ID.

From the same link:

Recommended: Create a Google AdMob account and register an app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM