Android Native Mobile First 依赖太多库?

标签 android dependencies ibm-cloud ibm-mobilefirst ibm-mobile-services

我目前正在研究 Bluemix 和 Mobile First Platform,研究它作为我正在开发的 Android 应用程序的后端是否适合我的需求。

从一个空的 Android 项目开始,我只成功地实现了 IBM Push Notification。我关注了这个官方sample .

我的下一步是实现库 Couchbase Lite for Android (到目前为止,我将使用的数据都放在我自己的 CouchDB 服务中)。为此,我将依赖项添加到 Gradle,因此文件看起来像这样

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "es.woozycoder.android.bluemixpayaround"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'

    compile group: 'com.ibm.mobilefirstplatform.clientsdk.android',
            name:'core',
            version: '1.+',
            ext:'aar',
            transitive: true

    compile group: 'com.ibm.mobilefirstplatform.clientsdk.android',
            name: 'push',
            version: '1.+',
            ext: 'aar',
            transitive: true

    compile 'com.couchbase.lite:couchbase-lite-android:1.1.0'
}

当我编译并看到以下错误时,我感到很惊讶,我认为它与 too many dependencies 密切相关.

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

上面链接的答案表明 Google Play Services 依赖性将是问题所在,我同意 lib Push 依赖于整个 google-services lib 而不仅仅是特定的(我猜那些会是 gcm (com.google.android.gms:play-services-gcm) 和 base (com.google.android.gms:play-services-base)。

有没有人知道这个问题的解决方案是什么?

更新

  1. 这是使用 Android Studio 创建的基于 Gradle 的原生 Android 应用程序。
  2. 问题出现在我添加 couchbase-lite-android 依赖项的那一刻。
  3. 我看到库 googleauthentication 也依赖于整个库 com.google.android.gms:play-services 而不是仅依赖于特定的库。<

更新 2

Here是Github项目。拉它并编译。您会看到它编译并成功运行。但是,现在取消注释模块的 gradle.build 中的 couchbase-lite 依赖项。 .现在,构建项目。它会失败。

最佳答案

您的问题并不清楚您实际上是在开发混合 Android 应用程序还是原生应用程序...

如果您正在开发原生应用并向其添加 MFP SDK,那么您应该在 Android Studio 中创建一个基于 Gradle 的 Android 项目。

如果您在 MobileFirst Studio 中开发混合 Android 应用程序,那么您有两个选择:

  1. 如果使用 MPF 7.0/7.1,请尝试添加 ProGuard 支持,这将有助于减少文件数量并可能解决此问题
  2. 将生成的 Android 项目导入 Android Studio 并将其转换为基于 Gradle 的项目,然后添加 Google Play 服务。当然,下次您在 MFP Studio 中构建应用程序时,它不会基于 Gradle,因此您将不得不重复此步骤。

您可能已经猜到,MFP 目前不支持基于 Gradle 的项目。

关于Android Native Mobile First 依赖太多库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34932111/

相关文章:

ibm-cloud - 视觉识别错误 400 : Cannot execute learning task no classifier name given

android - 糟糕 : something went wrong trying to "Ping Bluemix" from helloAuthentication Android sample app

Android appWidgetProvider onEnabled 从未在平板电脑上调用过

php - 如何让php添加utf8字符

android - 三星 android 应用程序内代码不起作用

java - 谁能帮我设置开发生态环境的代理服务器?

java - 使用依赖注入(inject)解决循环依赖时如何解决maven问题?

java - 如何在 android studio 中编辑依赖项/外部库?

spring-boot - 使用 Gradle 5.1 "implementation platform"代替 Spring 依赖管理插件

c# - 将现有 .NET 项目部署到 Bluemix