【发布时间】:2017-09-21 19:51:40
【问题描述】:
这是我的 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\1.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\1.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
【问题讨论】:
-
云端点是你想要的依赖,对吧?不是整个数据存储区 API?
-
实际上我想使用以下导入:
import java.util.ArrayList;并想要这3个依赖项:google-cloud-coregoogle-cloud-core-httpgoogle-cloud-datastore -
同样,端点是您应该与数据存储 API 交互的方式。我认为您的依赖项是 Java 服务器,而不是 Android 应用程序。
-
好的。那么,如何使用 Cloud 端点与我的 Android 应用程序进行交互。我想访问我的数据存储中已经存在的数据。我的 Datastore 中的数据来自 Web 应用程序。抱歉,我是 Android 新手。
标签: android android-gradle-plugin google-cloud-datastore google-cloud-platform google-cloud-endpoints