从客户端调用云端点库
Calling cloud endpoint library from a client
我创建了 Google Cloud endpoint
库并按照 Calling Google Apis from Android
中的说明进行操作
但是我无法使用我的端点。我在 Android Studio 中创建了一个新项目
并复制 gradle.build
中的所有依赖项但是当我 运行 项目时,我看到以下错误。
Java 编译器:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\DELL\.gradle\caches\modules-2\files-2.1\com.google.guava\guava.064ef3803de51fb0530a8377ec6100b33b0d073\guava-22.0.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException
Android 问题:
Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values()
Message{kind=ERROR, text=Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values(), sources=[Unknown source file], tool name=Optional.of(D8)}
Default interface methods are only supported starting with Android N (--min-api 24): boolean com.google.common.base.Predicate.test(java.lang.Object)
Message{kind=ERROR, text=Default interface methods are only supported starting with Android N (--min-api 24): boolean com.google.common.base.Predicate.test(java.lang.Object), sources=[Unknown source file], tool name=Optional.of(D8)}
我的 MainActivity.java
现在是空的。
这是我的 gradle.build
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.azeem.endpointtest"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Add the Google API client library.
implementation(group: 'com.google.api-client', name: 'google-api-client', version: '1.21.0') {
// Exclude artifacts that the Android SDK/Runtime provides.
exclude(group: 'xpp3', module: 'xpp3')
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
exclude(group: 'junit', module: 'junit')
exclude(group: 'com.google.android', module: 'android')
}
// Add the Android extensions for the Google API client library.
// This will automatically include play services as long as you have download that library
// from the Android SDK manager.
// Add the Android extensions for the Google API client library.
implementation(group: 'com.google.api-client', name: 'google-api-client-android',
version: '1.21.0')
{
// Exclude play services, since we're not using this yet.
exclude(group: 'com.google.android.gms:play-services', module: 'google-play-services')
}
// END Google APIs
// The following client libraries make HTTP/JSON on Android easier.
// Android extensions for Google HTTP Client.
implementation(group: 'com.google.http-client', name: 'google-http-client-android',
version: '1.21.0') {
exclude(group: 'com.google.android', module: 'android')
}
// This is used by the Google HTTP client library.
implementation(group: 'com.google.guava', name: 'guava', version: '22.0')
implementation files('libs/endpointapi-v1-1.23.0-SNAPSHOT.jar')
}
在我的整个 Api 中,我不需要进行任何 身份验证的调用 所以,请告诉我不需要什么库,所以我删除了。我想 实现 必要的迷你库。请告诉我为什么会遇到此错误。
我自己找的,这个只需要两个依赖
一个是 google-api-client-android
另一个是 Your_endpoint_lib
implementation 'com.google.api-client:google-api-client-android:1.23.0';
implementation files('libs/endpointapi-v1-1.23.0-SNAPSHOT.jar')
我创建了 Google Cloud endpoint
库并按照 Calling Google Apis from Android
但是我无法使用我的端点。我在 Android Studio 中创建了一个新项目
并复制 gradle.build
中的所有依赖项但是当我 运行 项目时,我看到以下错误。
Java 编译器:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\DELL\.gradle\caches\modules-2\files-2.1\com.google.guava\guava.064ef3803de51fb0530a8377ec6100b33b0d073\guava-22.0.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException
Android 问题:
Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values()
Message{kind=ERROR, text=Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values(), sources=[Unknown source file], tool name=Optional.of(D8)}
Default interface methods are only supported starting with Android N (--min-api 24): boolean com.google.common.base.Predicate.test(java.lang.Object)
Message{kind=ERROR, text=Default interface methods are only supported starting with Android N (--min-api 24): boolean com.google.common.base.Predicate.test(java.lang.Object), sources=[Unknown source file], tool name=Optional.of(D8)}
我的 MainActivity.java
现在是空的。
这是我的 gradle.build
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.azeem.endpointtest"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Add the Google API client library.
implementation(group: 'com.google.api-client', name: 'google-api-client', version: '1.21.0') {
// Exclude artifacts that the Android SDK/Runtime provides.
exclude(group: 'xpp3', module: 'xpp3')
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
exclude(group: 'junit', module: 'junit')
exclude(group: 'com.google.android', module: 'android')
}
// Add the Android extensions for the Google API client library.
// This will automatically include play services as long as you have download that library
// from the Android SDK manager.
// Add the Android extensions for the Google API client library.
implementation(group: 'com.google.api-client', name: 'google-api-client-android',
version: '1.21.0')
{
// Exclude play services, since we're not using this yet.
exclude(group: 'com.google.android.gms:play-services', module: 'google-play-services')
}
// END Google APIs
// The following client libraries make HTTP/JSON on Android easier.
// Android extensions for Google HTTP Client.
implementation(group: 'com.google.http-client', name: 'google-http-client-android',
version: '1.21.0') {
exclude(group: 'com.google.android', module: 'android')
}
// This is used by the Google HTTP client library.
implementation(group: 'com.google.guava', name: 'guava', version: '22.0')
implementation files('libs/endpointapi-v1-1.23.0-SNAPSHOT.jar')
}
在我的整个 Api 中,我不需要进行任何 身份验证的调用 所以,请告诉我不需要什么库,所以我删除了。我想 实现 必要的迷你库。请告诉我为什么会遇到此错误。
我自己找的,这个只需要两个依赖
一个是 google-api-client-android
另一个是 Your_endpoint_lib
implementation 'com.google.api-client:google-api-client-android:1.23.0';
implementation files('libs/endpointapi-v1-1.23.0-SNAPSHOT.jar')