云通信和android [英] cloud messaging and android

查看:363
本文介绍了云通信和android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现云谷歌信息和对我的Andr​​oid应用程序推送通知

我下面谷歌官方的教程中,我使用Android的工作室

https://developers.google.com/cloud-messaging/android/client

和我收到此错误

 错误:执行失败的任务:应用程序:transformClassesWithDexForDebug。
> com.android.build.transform.api.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:过程'命令'C:\\ Program Files文件\\的Java \\ jdk1.7.0_79 \\斌\\ java.exe的'非零退出值2结束

这是我的build.gradle

 应用插件:'com.android.application
 应用插件:'com.google.gms.google的服务。
安卓{
   packagingOptions {
    排除META-INF /相关内容
    排除META-INF /注意事项
    排除META-INF / LICENSE
    排除META-INF / LICENSE.TXT
    排除META-INF / NOTICE.txt
    排除META-INF / ASL2.0
    排除META-INF / notice.txt
}
compileSdkVersion 22
buildToolsVersion23.0.0 RC2defaultConfig {
    的applicationIDcom.myapp.example
    15的minSdkVersion
    targetSdkVersion 22
    版本code 1
    的versionName1.0
}
buildTypes {
    发布 {
        minifyEnabled假
        proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
    }
}
sourceSets.main {
    jniLibs.srcDir'库'
    jni.srcDirs = [] //禁用自动NDK的构建通话
 }}
依赖{
 编译文件树(导演:'库',包括:['的* .jar'])
 编译com.google.android.gms:播放服务:8.1.0
 编译com.android.support:appcompat-v7:22.2.0
 编译org.java-的WebSocket:Java的的WebSocket:1.3.0
 编译com.github.nkzawa:socket.io客户端:0.3.0
 编译rongi.rotate布局:旋转布局:1.0.1
 编译com.vdurmont:表情图案-java的:2.0.1
 编译公地郎咸平:公地郎咸平:2.5
 编译com.github.javadev:下划线:1.6
 编译com.astuetz:pagerslidingtabstrip:1.0.1
 编译org.florescu.android.rangeseekbar:rangeseekbar库:0.2.0
 编译com.beardedhen:androidbootstrap:1.1.1
 编译com.mcxiaoke.volley:库:1.0.18
 编译com.reginald.swiperefresh:库:1.1.1
 编译com.makeramen:roundedimageview:2.2.0
 编译com.google code.gson:GSON:2.3.1
 编译com.github.d-MAX:段位对话框:0.4@aar
 编译cn.pedant.sweetalert:库:1.3'
 编译com.jakewharton:奶油刀:6.1.0
 编译com.squareup.picasso:毕加索:2.5.2
 编译in.srain.cube:网格视图与 - 页眉页脚:1.0.12
 编译com.vstechlab.easyfonts:easyfonts:1.0.0}

也在这里是我的项目的build.gradle文件

  //顶级构建文件,您可以添加常用的配置选项,所有分项目/模块。 buildscript {
   库{
     jcenter()
   }
   依赖{
     类路径'com.android.tools.build:gradle:1.2.3
     类路径'com.google.gms:谷歌服务:1.4.0-β3
      //注意:不要在这里把你的应用程序依赖关系;他们属于
     //在单个模块的build.gradle文件
    }
}allprojects {
  库{
     jcenter()
 }
}


解决方案

在一些天,并做恶梦,最后我能打败这个问题,并认为它可能是帮助他人。

由于我巨大的codeD项目,测试和检查每个建议大约需要5分钟我的系统构建的。我检查几乎所有的SO社区建议,我想在这里他们得出结论:

这是的最有可能的与您在列出的依赖关系的问题,你的的build.gradle 文件为您的应用程序。

东西,我不建议:


  

除非你有绝对的需要来启用multiDex您
  的build.gradle 不这样做,这只是跨过了
  在您的应用程序根本问题,并没有得到到它的根。您
  也不必要地增加你的apk的大小,并有
  可能是意外崩溃时,有一个矛盾的方法你
  DEX文件。


事情看出来的:


  

检查所有的依赖在你的build.gradle文件,如果您有任何
  复制。你引用一种依赖,还包括
  依赖你已经包括在内?例如,如果您包括
  应用程序兼容性-V7,没有必要包括自第7版应用程序兼容性-V4
  包括来自v4的所有功能。


我的问题: Google Play服务 >>引起我的应用程序在我的DEX文件超过限制的方法。

如果你并不需要所有的谷歌Play服务库的依赖不包括在你的build.gradle此行编译com.google.android.gms:发挥服务:8.3.0,而是只使用你所需要的!还检查您能够以更低版本的依赖正确生成。

谷歌拥有的库,用于选择性地编制 这里一个COM prehensive列表

与所有的说,你可能只需要在gradle这个为你的谷歌分析这一行:

  {相关性
       编译com.google.android.gms:发挥服务加:8.3.0
  }

干得好!

I am trying to implement google cloud messaging and push notifications on my android app

I am following official google tutorial , I am using android studio

https://developers.google.com/cloud-messaging/android/client

and I am getting this error

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException:     com.android.ide.common.process.ProcessException:   org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2

here is my build.gradle

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


android {
   packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/notice.txt'
}
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"

defaultConfig {
    applicationId "com.myapp.example"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets.main {
    jniLibs.srcDir 'libs'
    jni.srcDirs = [] //disable automatic ndk-build call
 }

}


dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile 'com.google.android.gms:play-services:8.1.0'
 compile 'com.android.support:appcompat-v7:22.2.0'
 compile 'org.java-websocket:Java-WebSocket:1.3.0'
 compile 'com.github.nkzawa:socket.io-client:0.3.0'
 compile 'rongi.rotate-layout:rotate-layout:1.0.1'
 compile 'com.vdurmont:emoji-java:2.0.1'
 compile 'commons-lang:commons-lang:2.5'
 compile 'com.github.javadev:underscore:1.6'
 compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
 compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.2.0'
 compile 'com.beardedhen:androidbootstrap:1.1.1'
 compile 'com.mcxiaoke.volley:library:1.0.18'
 compile 'com.reginald.swiperefresh:library:1.1.1'
 compile 'com.makeramen:roundedimageview:2.2.0'
 compile 'com.google.code.gson:gson:2.3.1'
 compile 'com.github.d-max:spots-dialog:0.4@aar'
 compile 'cn.pedant.sweetalert:library:1.3'
 compile 'com.jakewharton:butterknife:6.1.0'
 compile 'com.squareup.picasso:picasso:2.5.2'
 compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
 compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'

}

also here is my project build.gradle file

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

 buildscript {
   repositories {
     jcenter()
   }
   dependencies {
     classpath 'com.android.tools.build:gradle:1.2.3'
     classpath 'com.google.gms:google-services:1.4.0-beta3'
      // NOTE: Do not place your application dependencies here; they belong
     // in the individual module build.gradle files
    }
}

allprojects {
  repositories {
     jcenter()
 }
}

解决方案

After some-days and nightmares, Finally I can defeat the problem and believe it could be of help to others.

Because of my massive coded project, test and checking each advice takes about 5 minutes of my system to build. I examined almost all of SO community suggestions and I wanna conclude them here:

This is most likely a problem with the dependencies you have listed in your build.gradle file for you app.

Things I do not recommend:

Unless you have an absolute need to enable multiDex in your build.gradle DO NOT DO IT, this is just stepping over the underlying problem in your app and not getting to the root of it. You are also unnecessarily increasing the size of your apk, and there could be unexpected crashes when there is a conflicting method in your dex file.

Things to look out for:

Check all your dependencies in your build.gradle file if you have any duplication. Are you referencing a dependency that also includes a dependency you have already included? For example, if your including appcompat-v7 there is no need to include appcompat-v4 since v7 includes all features from v4.

My Issue: GOOGLE PLAY SERVICES >> causing my app to exceed method limit in my dex file.

If you do not need all the google play services library dependencies DO NOT INCLUDE this line in your build.gradle compile 'com.google.android.gms:play-services:8.3.0' and instead just use what you need!! also check if your can build correctly with lower versions of the dependency.

Google has a comprehensive list of the libraries for selectively compiling here

With all that said you probably only need to include this one line in gradle for your Google Analytics:

  dependencies{
       compile 'com.google.android.gms:play-services-plus:8.3.0'
  }

Well Done!

这篇关于云通信和android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆