Google Cloud API APK 中复制的重复文件 com/google/cloud/project.properties

Google Cloud API Duplicate file copied in APK com/google/cloud/project.properties

这是我的 build.gradle(app) 文件,当我尝试同步此文件时,出现 8 个警告,当我尝试 运行 此应用程序时,几乎没有警告和错误提示有一个Duplicate file Exception

我正在尝试在我的 android 应用程序

中实施 Google 云数据存储
apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.appspot.myapp"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
    packagingOptions {

        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'

    }
}


dependencies {
    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.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'
    compile group: 'com.google.cloud', name: 'google-cloud-datastore', version: '+'
}

点击“立即同步”后,我收到以下警告:

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20160810 is ignored for release as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20160810 is ignored for release as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
Information:BUILD SUCCESSFUL
Information:Total time: 1.791 secs
Information:0 errors
Information:8 warnings
Information:See complete output in console

这是我尝试 运行 我的应用程序时看到的错误:

Information:Gradle tasks [:app:assembleDebug]
Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK com/google/cloud/project.properties
    File1: C:\Users\mbhar\.gradle\caches\modules-2\files-2.1\com.google.cloud\google-cloud-core.0.0-rc2\aadb514fb6e48585c5fb1b2bbca1a84db38bdd6f\google-cloud-core-1.0.0-rc2.jar
    File2: C:\Users\mbhar\.gradle\caches\modules-2\files-2.1\com.google.cloud\google-cloud-core-http.0.0-rc2\fe5de264bf8a3357d69f0643d31eca582cee119c\google-cloud-core-http-1.0.0-rc2.jar
Information:BUILD FAILED
Information:Total time: 1.487 secs
Information:1 error
Information:4 warnings
Information:See complete output in console

排除那些重复项应该可以消除该错误

compile('com.google.cloud:google-cloud-datastore:1.0.0-rc2') {
    exclude group: 'org.json'
    exclude group: 'org.apache.httpcomponents'
}

但是 Android 从 Android 6 开始弃用了 SDK 中的 Apache HTTP 组件。

所以,我真的认为你应该 setup Endpoints 因为

Google Cloud Endpoints [provides] automated Java object marshalling/unmarshalling to JSON, generation of strongly-typed client libraries that can be called from your Android app, built-in authentication support and so on.

我认为 link 部署了一个 Java 后端,但我已经将其与 Python App Engine 应用程序一起使用,只是不记得它是如何工作的。