gpt4 book ai didi

android - 云消息和安卓

转载 作者:太空狗 更新时间:2023-10-29 15:45:35 27 4
gpt4 key购买 nike

我正在尝试在我的 Android 应用程序上实现谷歌云消息传递和推送通知

我正在关注官方谷歌教程,我正在使用 android studio

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

我收到这个错误

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

这是我的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'

}

还有我的项目build.gradle文件

// 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()
}
}

最佳答案

经过几天和噩梦,我终于可以战胜这个问题,相信它可以帮助其他人。

由于我的大型编码项目,测试和检查每个建议需要大约 5 分钟的时间来构建我的系统。我检查了几乎所有的 SO 社区建议,我想在这里总结它们:

很可能是您在build.gradle 文件中为您的应用列出的依赖项的问题。

我不推荐的东西:

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.

注意事项:

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.

我的问题:GOOGLE PLAY SERVICES>> 导致我的应用超出我的 dex 文件中的方法限制。

如果您不需要所有 google play 服务库依赖项,请不要在您的 build.gradle compile 'com.google.android.gms:play-services:8.3.0' 中包含这一行而不是只使用你需要的东西!!还要检查您是否可以使用较低版本的依赖项正确构建。

Google 有一个完整的库列表,用于选择性编译 here

综上所述,您可能只需要在 gradle 中为您的 Google Analytics 添加这一行:

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

干得好!

关于android - 云消息和安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32804340/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com