2015-10-09 17 views
11

アプリがLollipopデバイスでうまく動作していますが、Lollipopのバージョンより前にクラッシュしています。 は、私は単純にバナーがAndroid - プレLollipopデバイスでアプリがクラッシュする

compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

マニフェスト

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

エラーを使用して、Googleのdocumention

// 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); 

を通じて次のコードで自分のアプリケーションに追加実装した

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) 

私のGradleファイルこの問題から抜け出すために私を助けてください

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' 
    } 

です。

+0

チェックグーグル '場合:Multidexの詳細については

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

は、これらのサイトを参照してください。遊びます 「サービス」は、プロジェクト内のライブラリとして「AdRequest」を使用する前に利用可能です – Tauqir

+0

はい、これは既に によってコンパイルされています。 'com.google.android.gms:play-services:8.1.0' コンパイルはLollipopで動作しますが、あなたのgradleファイルを投稿するKitkat – Nirmal

+0

をクラッシュする。 –

答えて

33

問題に1時間以上を展開した後、私はこのようMyApplicationクラスにいくつかの変更をしなければならないことが判明:私はattachbaseContextメソッドをオーバーライドしている

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); 
    } 
} 

とすべて今はうまくいく。

+0

素晴らしい、その完璧な作業... :) – Jayesh

+0

私たちのAndroid StudioプロジェクトのMyApplicationクラスはどこですか? –

+0

作成する必要があります。単純なJavaクラスを作成し、アプリケーションクラスから拡張しました。あなたは私の答えで見ることができ、attachBaseContextメソッドをオーバーライドできました。また、アプリケーションの依存関係をgradleファイルビルド 'com.android.support:multidex:1.0.1' 。そして、マニフェストアプリケーションタグには、このようなクラスが含まれています:android:name = "。あなたのクラス名" – Nirmal

0

あなたはこのうちAPI 21

確認され、あなたのAndroidManifest.xml ロリポップでAPIを下げる必要があります。API Levels 例:

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

私はすでにもう少し説明してくれますか? Nirmal

0

あなたはサポートを与えたいというバージョンにminSdkVersionがを減らします

あなたのプロジェクトのグラデルファイル

以下のように

minSdkVersionが10

+0

私はすでにこれを試しました以前は助けがありませんでした – Nirmal

4

+)65Kを超えるメソッドでアプリケーションをビルドするとこのエラーが発生します。

+)アプリケーションと、それは一定のサイズに達する参照するライブラリ(アプリケーションのDEXファイルは、Androidフレームワークの方法、ライブラリー法、および独自のコード内のメソッドを含む65,536点で最大方法の合計数を持つことができた場合)、アプリがAndroidアプリのビルドアーキテクチャの限界に達していることを示すビルドエラーが発生します。それを解決するには

+)、これに伴って、アプリケーションのクラスでattachBaseContext(コンテキストベース)メソッドをオーバーライドし、あなたのbuild.gradle写真の強調表示のようなMultidex設定が含まれますコンテンツの下に

public class YourParentApplication extends Application { 

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

あなたのAndroidManifest.xmlでこれを追加します。 http://developer.android.com/tools/building/multidex.html

How to enable multidexing with the new Android Multidex support library

enter image description here

関連する問題