2016-04-24 7 views
0

GCMプッシュ通知を実装しようとしています。アプリがあるときにGCM通知を実現できます実行中またはバックグラウンドで実行されます。以下は、私のマニフェストファイルが

java.lang.NoClassDefFoundError: android.support.v4.app.NotificationCompatKitKat$Builder 

です

:しかし、アプリは、私はGCMの通知を処理しているサービスクラスで例外の下に取得しています実行中のアプリのリストをアプリをスワイプして殺害されたときは、通知トレイに通知をトリガー

@Override 
     public void onMessageReceived(String from,Bundle data){ 
    Log.d(TAG, "In Receive Method of GCm Listener Service"); 



Intent intent = new Intent(this, MyActivity.class); 
     intent.putExtra("myKey","myValue"); 

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); 
Context context = getBaseContext(); 
     NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) 
       .setSmallIcon(R.drawable.ic_launcher).setContentTitle("This is Title") 
       .setContentText("Body of the message").setContentIntent(pendingIntent); 
     NotificationManager mNotificationManager = (NotificationManager) context 
       .getSystemService(Context.NOTIFICATION_SERVICE); 
     mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mBuilder.build()); 
      } 

上記COD:GCM以下

<receiver 
    android:name="com.google.android.gms.gcm.GcmReceiver" 
    android:permission="com.google.android.c2dm.permission.SEND"> 
    <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
      <category android:name="com.xxxxx.xxxxxx.xxxxx" /> 
    </intent-filter> 
</receiver> 

<service 
    android:name=".services.GCMNotificationListenerService" 
      android:exported="false"> 
    <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
    </intent-filter> 
</service> 

に関連して、サービスクラスGCMNotificationListenerServiceのonMessageRecieved方法であり、アプリが実行中またはバックグラウンドでは絶対にうまく動作しますが、アプリが強制終了されると例外java.lang.NoClassDefFoundError:android.support.v4.app.NotificationCompatKitKat $ Builderがスローされます。

何か不足していますか?親切に助けてください。

は、ここで私はいつも私のアンドロイド依存関係は同じ/最新バージョンを使用していることを確認してください私のbuild.gradle

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

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

    } 
} 
apply plugin: 'com.google.gms.google-services' 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
//apply plugin: 'com.google.gms.google-services' 
repositories { 
    maven { url 'https://maven.fabric.io/public' } 
} 


android { 
    compileSdkVersion 21 
    buildToolsVersion "21.1.2" 

    defaultConfig { 
     applicationId "com.chromosis.wishhapp.wishhapp" 
     minSdkVersion 15 
     targetSdkVersion 21 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    // workaround for "duplicate files during packaging of APK" issue 
    // see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ 
    packagingOptions { 
     exclude 'META-INF/ASL2.0' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/NOTICE' 
    } 
    dexOptions { 
     javaMaxHeapSize "2g" 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:21.0.3' 
    //compile 'com.couchbase.lite:couchbase-lite-android:1.0.3.1' 
    compile 'com.couchbase.lite:couchbase-lite-android:1.1.0' 
    compile 'com.android.support:recyclerview-v7:21.0.3' 
    compile 'com.android.support:cardview-v7:21.0.3' 
    compile 'com.squareup.picasso:picasso:2.5.0' 
    compile 'it.neokree:MaterialTabs:0.11' 
    compile project(':citruslibrary') 
    compile 'com.soundcloud.android:android-crop:[email protected]' 
    compile 'xyz.danoz:recyclerviewfastscroller:0.1.3' 
    compile 'com.pkmmte.view:circularimageview:1.1' 
    compile 'com.android.support:palette-v7:21.0.+' 
    compile 'com.mcxiaoke.volley:library-aar:1.0.1' 
    compile 'com.appboy:android-sdk-ui:1.7.3' 
    compile 'com.android.support:design:22.2.0' 
    compile 'me.villani.lorenzo.android:android-cropimage:1.1.0' 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    compile 'com.amazonaws:aws-android-sdk-core:2.2.9' 
    compile 'com.amazonaws:aws-android-sdk-cognito:2.2.9' 
    compile 'com.amazonaws:aws-android-sdk-s3:2.2.9' 
    compile 'com.amazonaws:aws-android-sdk-ddb:2.2.9' 
    compile 'com.android.support:multidex:1.0.0' 
    //compile 'com.google.android.gms:play-services-gcm:8.3.0' 
    compile 'com.google.android.gms:play-services-gcm:8.1.0' 


} 
+0

あなたのbuild.gradleファイルを投稿することができますか?ありがとう – AndroidEnthusiast

答えて

0

です。

は23

クリーン、例えば22同じバージョンを使用して、すべての「com.android.support」依存関係をアップグレードし、再構築し

問題が解決しない場合は、マルチデックスでこの問題が発生している可能性があります。

multidexを使用すると、いくつかのファイルがプロセスでメインのdexリストを作成するときに除外される可能性があります。

ここで正確な手順に従ってください、私はしばらく前に同じ問題を抱えていた、これは私のためにそれを解決:

Unable to execute dex: method ID not in [0, 0xffff]: 65536