11

Meine App läuft auf Lollipop-Geräten gut, stürzt aber vor der Version Lollipop weiter ab. Ich habe einfach implementiert eine Fahne mit dem folgenden Code über Google Dokumention in meiner Anwendung hinzufügenAndroid - App stürzt auf Pre-Lollipop-Geräten ab

// Request for Ads 
      AdRequest adRequest = new AdRequest.Builder() 

        // Add a test device to show Test Ads 
       .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
       .build(); 

     // Load ads into Banner Ads 
     mAdView.loadAd(adRequest); 

mit

compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

manifest

<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" /> 

Fehler

E/AndroidRuntime: FATAL EXCEPTION: main 
E/AndroidRuntime: Process: com.app.aggro, PID: 13257 
E/AndroidRuntime: java.lang.VerifyError: 
    com/google/android/gms/measurement/internal/zzv 
E/AndroidRuntime: at 
com.google.android.gms.measurement.AppMeasurementContentProvider 
.onCreate(Unknown Source) 
E/AndroidRuntime:  at 
android.content.ContentProvider.attachInfo(ContentProvider.java:1656) 
E/AndroidRuntime:  at 
android.content.ContentProvider.attachInfo(ContentProvider.java:1627) 
E/AndroidRuntime:  at 
android.app.ActivityThread.installProvider(ActivityThread.java:5015) 
E/AndroidRuntime:  at 
android.app.ActivityThread.installContentProviders 
(ActivityThread.java:4589) 
E/AndroidRuntime:  at 
android.app.ActivityThread.handleBindApplication 
(ActivityThread.java:4522) 
E/AndroidRuntime:  at 
android.app.ActivityThread.access$1500(ActivityThread.java:151) 
E/AndroidRuntime:  at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381) 
E/AndroidRuntime:  at 
android.os.Handler.dispatchMessage(Handler.java:110) 
E/AndroidRuntime:  at android.os.Looper.loop(Looper.java:193) 
    E/AndroidRuntime:  at 
android.app.ActivityThread.main(ActivityThread.java:5299) 
E/AndroidRuntime:  at java.lang.reflect.Method.invokeNative(Native 
Method) 
E/AndroidRuntime:  at 
java.lang.reflect.Method.invoke(Method.java:515) 
E/AndroidRuntime:  at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run 
(ZygoteInit.java:825) 
E/AndroidRuntime:  at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641) 
E/AndroidRuntime:  at dalvik.system.NativeStart.main 
(Native Method) 

Meine Gradle Datei ist

apply plugin: 'com.android.application' 

buildscript { 
    repositories { 
     maven { url 'https://maven.fabric.io/public' } 
    } 

    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 
repositories { 
    mavenCentral() 
    maven { url 
"https://oss.sonatype.org/content/repositories/snapshots"} 
     maven { url 'https://maven.fabric.io/public' } 
     maven { url 
    "https://oss.sonatype.org/content/repositories/snapshots/" } 
    maven { url 'https://dl.bintray.com/drummer-aidan/maven' } 
} 
android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.app.aggro" 
     minSdkVersion 15 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard- 
android.txt'), 'proguard-rules.pro' 
     } 
    } 


    dexOptions{ 
     incremental true 
     javaMaxHeapSize "4g" 
    } 
    defaultConfig { 
     multiDexEnabled true 
    } 
    packagingOptions { 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
    } 
    } 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:23.0.1' 
    compile('com.mikepenz:materialdrawer:[email protected]') { 
     transitive = true 
    } 
    compile('com.github.florent37:materialviewpager:[email protected]') { 
     transitive = true 
    } 


    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    compile 'com.google.android.gms:play-services:8.1.0' 
    compile 'com.mcxiaoke.volley:library:1.0.+' 
    compile 'com.google.code.gson:gson:2.3.1' 
     compile 'com.marshalchen.ultimaterecyclerview:library:0.3.11' 
    compile 'com.android.support:recyclerview-v7:22.2.0' 
    compile 'com.android.support:cardview-v7:23.0.1' 
    compile 'com.jpardogo.googleprogressbar:library:1.2.0' 
     compile 'com.quinny898.library.persistentsearch:library:1.0.0- 
SNAPSHOT' 
    compile project(':storage') 
    compile 'com.getbase:floatingactionbutton:1.10.0' 
    compile 'com.parse.bolts:bolts-android:1.+' 
     compile files('libs/activeandroid-3.1-beta.jar') 
     compile 'com.android.support:design:23.0.1' 
     compile 'it.neokree:MaterialTabs:0.11' 
     compile 'com.miguelcatalan:materialsearchview:1.2.0' 
    } 

Bitte helfen Sie mir dieses Problem raus.

+0

überprüfen, ob 'Google Abspielen Services ist als Bibliothek im Projekt vor der Verwendung von 'AdRequest' verfügbar – Tauqir

+0

Ja, ich habe bereits enthalten, dass von kompilieren 'com.google.android.gms: play-services: 8.1.0' und es funktioniert in Lollipop, aber es bleibt Crashing auf Kitkat – Nirmal

+0

post Ihre Gradle-Datei. –

Antwort

33

Nach mehr als einer Stunde auf Problem erweitern, fand ich, dass ich einige Änderungen in MyApplication Klasse wie dies zu tun haben:

public class MyApplication extends Application { 

    @Override 
    public void onCreate() { 
     super.onCreate(); 
     // register with Active Android 
     ActiveAndroid.initialize(this); 
    } 

    @Override 
    protected void attachBaseContext(Context base) { 
     super.attachBaseContext(base); 
     MultiDex.install(this); 
    } 
} 

ich die attachbaseContext Methode außer Kraft gesetzt haben und Alles funktioniert jetzt gut.

+0

toll, es funktioniert perfekt ... :) – Jayesh

+0

wo ist MyApplication-Klasse in unserem Android Studio-Projekt? –

+0

Sie müssen einen erstellen. Erstellen Sie einfach eine einfache Java-Klasse und erweitern Sie sie aus der Application-Klasse, wie Sie in meiner Antwort sehen konnten und überschreiben Sie die attachBaseContext-Methode.Ebenfalls Abhängigkeit in Ihrer App build gradle Datei compile 'com.android.support:multidex:1.0.1' .Und in Manifest Anwendung Tag enthalten die Klasse wie diese android: name = ". Ihr Klassenname" – Nirmal

0

Sie sollten die API in AndroidManifest.xml Lollipop senken ist API 21.

Check this out: API Levels Beispiel:

defaultConfig { 
     applicationId "com.package.name" 
     minSdkVersion 11 
     targetSdkVersion 21 
     versionCode 1 
     versionName "1.0" 
    } 
+0

können Sie etwas mehr erklären, weil ich bereits die senken Nirmal

0

reduzieren Sie Ihre minSdkversion zu dieser Version Unterstützung geben möchten

in gradle Datei Ihres Projekts

Wie unten

minSdkVersion 10

+0

Ich habe dies bereits versucht vor, aber keine Hilfe – Nirmal

4

+) Erstellen von Apps mit über 65K-Methode wird diesen Fehler verursachen.

+) Wenn Ihre Anwendung und die Bibliotheken es eine bestimmte Größe verweist erreichen (DEX-Datei Ihre Anwendung können bis zu 65.536 einschließlich Android Framework Methoden, Bibliothek Methoden und Verfahren in Ihrem eigenen Code Gesamtzahl der Methoden), treten Buildfehler auf, die darauf hinweisen, dass Ihre App die Buildarchitektur für Android-Apps erreicht hat.

+) es zu beheben, schließen Multidex Konfiguration in Ihrem build.gradle wie die markierte einen in Bild, zusammen mit diesem überschreibt die attachBaseContext (Context Base) Methode in Ihrer Anwendungsklasse mit der unter dem Inhalt.

public class YourParentApplication extends Application { 

@Override 
protected void attachBaseContext(Context base) { 
    super.attachBaseContext(base); 
    MultiDex.install(this); 
} 
} 

Fügen Sie diese in Ihnen AndroidManifest.xml:

<application 
    android:name=".YourParentApplication" 
    android:allowBackup="true" 
    android:icon="@drawable/radiius_logo" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:theme="@style/MyMaterialTheme"> 

Weitere Informationen über Multidex diese Website beziehen: http://developer.android.com/tools/building/multidex.html

How to enable multidexing with the new Android Multidex support library

enter image description here