1

アプリでマルチディックスとGoogleアナリティクスを適用しました。アプリはロリポップ前の端末でクラッシュしています。私もmultidexのバージョンを変更しようとしましたが、何も機能しませんでした。アプリ自体が起動するとアプリがクラッシュします。 これは私のGradleです:マルチプレックスとGoogleアナリティクスを使用している間にアプリケーションのクラッシュを解決するにはどうすればよいですか?

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

    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 

apply plugin: 'com.android.application' 
//apply plugin: 'io.fabric' 

buildscript { 
    repositories { 
     mavenCentral() 
     jcenter() 
     maven { url 'https://github.com/yongjhih/android-gradle-plugin.m2/raw/master/' } 

    } 
    dependencies { 
     classpath 'com.infstory.tools.build:gradle:0.14.+' 
    } 
} 

dependencies { 
    compile 'com.google.android:multidex:0.1' 
} 

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

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId "com.package" 
     minSdkVersion 15 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    packagingOptions { 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/LICENSE-FIREBASE.txt' 
     exclude 'META-INF/NOTICE.txt' 
    } 

    dexOptions { 
     javaMaxHeapSize "4g" 
     preDexLibraries = false 
    } 
} 


dependencies { 
    compile 'com.google.android:multidex:0.1' 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile('com.twitter.sdk.android:twitter:[email protected]') { 
     transitive = true; 
    } 
    compile files('libs/http-core-4.1.jar') 
    compile files('libs/httpclient-4.5.jar') 
    compile files('libs/volley.jar') 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    compile 'com.android.support:design:25.3.1' 
    compile 'com.android.support:recyclerview-v7:25.3.1' 
    compile 'com.android.support:cardview-v7:25.3.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' 
    compile 'com.google.android.gms:play-services-ads:10.2.4' 
    compile 'com.google.android.gms:play-services-maps:10.2.4' 
    compile 'com.google.android.gms:play-services-location:10.2.4' 
    compile 'com.google.android.gms:play-services-places:10.2.4' 
    compile 'com.adcolony:sdk:3.1.2' 
    compile 'com.facebook.android:facebook-android-sdk:[4,5)' 
    compile 'com.google.android.gms:play-services-auth:10.2.4' 
    compile 'cn.fanrunqi:waveprogress:1.0.1' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.sun.mail:android-mail:1.5.5' 
    compile 'com.sun.mail:android-activation:1.5.5' 
    compile 'com.android.support:support-v4:25.3.1' 
    compile 'com.google.android.gms:play-services-analytics:10.2.4' 
    compile 'com.google.firebase:firebase-messaging:10.2.1' 
    //compile 'com.android.support:multidex:1.0.1' 
    testCompile 'junit:junit:4.12' 
} 

afterEvaluate { 
    tasks.matching { 
     it.name.startsWith('dex') 
    }.each { dx -> 
     if (dx.additionalParameters == null) { 
      dx.additionalParameters = [] 
     } 
     dx.additionalParameters += '--multi-dex' // enable multidex 

     // optional 
     dx.additionalParameters += "--main-dex-list=$projectDir/multidex.keep".toString() // enable the main-dex-list 
     dx.additionalParameters += '--minimal-main-dex' 
    } 
} 

apply plugin: 'com.google.gms.google-services' 

これは私のApplicationクラスである:

package com.package; 

import android.app.Application; 
import android.content.Context; 
import android.support.multidex.MultiDex; 
import android.support.multidex.MultiDexApplication; 


import com.google.android.gms.analytics.GoogleAnalytics; 
import com.google.android.gms.analytics.Tracker; 


public class AnalyticsApplication extends android.support.multidex.MultiDexApplication { 

    private static GoogleAnalytics sAnalytics; 
    private static Tracker sTracker; 

    @Override 
    public void onCreate() { 
     super.onCreate(); 

     sAnalytics = GoogleAnalytics.getInstance(this); 

    } 

    /*@Override 
    protected void attachBaseContext(Context newBase) { 
     super.attachBaseContext(newBase); 
     MultiDex.install(this); 
    }*/ 
    /** 
    * Gets the default {@link Tracker} for this {@link Application}. 
    * @return tracker 
    */ 
    synchronized public Tracker getDefaultTracker() { 
     // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG 
     if (sTracker == null) { 
      sTracker = sAnalytics.newTracker(R.xml.global_tracker); 
     } 

     return sTracker; 
    } 
} 

として、私はマニフェストでアプリケーションを使用している:あなたのアプリを超えたときにこれは通常起こり

<application 
     android:name=".AnalyticsApplication" 
     android:allowBackup="true" 
     android:icon="@drawable/app_logo" 
     android:label="@string/app_name" 
     android:roundIcon="@drawable/app_logo" 
     android:supportsRtl="true" 
     android:largeHeap="true" 
     android:hardwareAccelerated="false" 
     android:theme="@style/AppTheme"> 
+0

どこログがですか? –

+0

エラーログを共有できる場合は助けになります –

+0

@ ShinilMSデバイスは私と一緒ではないので、ログを取得できません。私はmarshmallowを使用しています。それはkitkatやjelly beanではなく、うまく動作しています。 – shruity

答えて

0

デックスリミット..

以下

compile 'com.android.support:multidex:1.0.2' 
アプリケーションクラスの最後に

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

であなたの依存関係で、その後

multiDexEnabled true 

あなたがmultidexを使用したくない場合は、不要な依存関係を使用するのを回避する必要があります。

除外するモジュールの使用は、例えば、DEXサイズ を削減するために必要とされる:

compile ('com.andkulikov:transitionseverywhere:1.7.2'){ 
    exclude group: 'com.android.support', module: 'support-v4' 
} 
+0

私はこれをしました。しかし、まだ問題は、ロリポップ前のデバイスに来ています。 – shruity

+0

このコンパイルを削除する 'com.google.android:multidex:0.1' – ZeroOne

+0

私はその時にこれを使わずにアプリケーションをコンパイルしていて、アプリもクラッシュしていました。私はこの行を追加しようとしましたが、無駄です。 – shruity

関連する問題