It seems that GCP's Endpoints are not compatible with anything below Honeycomb, is there a way to make them backward compatible?
似乎GCP的端点与Honeycomb以下的任何东西不兼容,有没有办法让它们向后兼容?
Regarding the error I receive in the logcat:
关于我在logcat中收到的错误:
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ java.lang.IllegalArgumentException: running on Android SDK level 10 but requires minimum 11
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:119)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:69)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at com.google.api.client.extensions.android.AndroidUtils.checkMinimumSdkLevel(AndroidUtils.java:48)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at com.google.api.client.extensions.android.json.AndroidJsonFactory.<init>(AndroidJsonFactory.java:75)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at {package}.fragment.StartFragment$RegistrationLoader.loadInBackground(StartFragment.java:144)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at {package}.fragment.StartFragment$RegistrationLoader.loadInBackground(StartFragment.java:120)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:242)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:138)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
10-06 15:21:33.950 2330-2358/{package} W/System.err﹕ at java.lang.Thread.run(Thread.java:1019)
2 个解决方案
#1
5
I get the exact same error on my android app. So I looked at the class AndroidJsonFactory and here it is:
我在我的Android应用程序上得到完全相同的错误。所以我看了AndroidJsonFactory类,这里是:
@TargetApi(11)
@Beta
public class AndroidJsonFactory extends JsonFactory {
public AndroidJsonFactory() {
AndroidUtils.checkMinimumSdkLevel(11);
}
This comes from:
这来自:
compile('com.google.http-client:google-http-client-android:1.18.0-rc') {
exclude(group: 'com.google.android', module: 'android')
}
in your gradle build file.
在您的gradle构建文件中。
Here is something that seem to work for me.
这似乎对我有用。
add
加
compile 'com.google.http-client:google-http-client-gson:1.19.0' exclude module: 'httpclient'
to your gradle build file and the following in to your code:
您的gradle构建文件以及以下代码:
/**
* Class instance of the JSON factory.
*/
public static final JsonFactory getJsonFactory() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// only for honeycomb and newer versions
return new AndroidJsonFactory();
} else {
return new GsonFactory();
}
}
Then use the getJsonFactory() - method wherever you build your backend service handler. I'll do a little more testing but I think this should work.
然后在构建后端服务处理程序的任何地方使用getJsonFactory()方法。我会做一些测试,但我认为这应该有效。
#2
0
According to GCP Java tutorial, you can create endpoints using API 9: Android 2.3 (Gingerbread) for the Minimum required SDK. Which means it should support at least gingerbread devices. It might be a problem generating the clients or an inconsistency in the GCP Java Documentation. I've generated clients using Maven Plugin for Eclipse. I'll try to generate clients with Android Studio to see if it makes any difference.
根据GCP Java教程,您可以使用API 9创建端点:Android 2.3(Gingerbread),用于最低要求的SDK。这意味着它应该至少支持姜饼设备。这可能是生成客户端的问题或GCP Java文档中的不一致。我使用Maven Plugin for Eclipse生成了客户端。我将尝试使用Android Studio生成客户端,看看它是否有任何区别。
#1
5
I get the exact same error on my android app. So I looked at the class AndroidJsonFactory and here it is:
我在我的Android应用程序上得到完全相同的错误。所以我看了AndroidJsonFactory类,这里是:
@TargetApi(11)
@Beta
public class AndroidJsonFactory extends JsonFactory {
public AndroidJsonFactory() {
AndroidUtils.checkMinimumSdkLevel(11);
}
This comes from:
这来自:
compile('com.google.http-client:google-http-client-android:1.18.0-rc') {
exclude(group: 'com.google.android', module: 'android')
}
in your gradle build file.
在您的gradle构建文件中。
Here is something that seem to work for me.
这似乎对我有用。
add
加
compile 'com.google.http-client:google-http-client-gson:1.19.0' exclude module: 'httpclient'
to your gradle build file and the following in to your code:
您的gradle构建文件以及以下代码:
/**
* Class instance of the JSON factory.
*/
public static final JsonFactory getJsonFactory() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// only for honeycomb and newer versions
return new AndroidJsonFactory();
} else {
return new GsonFactory();
}
}
Then use the getJsonFactory() - method wherever you build your backend service handler. I'll do a little more testing but I think this should work.
然后在构建后端服务处理程序的任何地方使用getJsonFactory()方法。我会做一些测试,但我认为这应该有效。
#2
0
According to GCP Java tutorial, you can create endpoints using API 9: Android 2.3 (Gingerbread) for the Minimum required SDK. Which means it should support at least gingerbread devices. It might be a problem generating the clients or an inconsistency in the GCP Java Documentation. I've generated clients using Maven Plugin for Eclipse. I'll try to generate clients with Android Studio to see if it makes any difference.
根据GCP Java教程,您可以使用API 9创建端点:Android 2.3(Gingerbread),用于最低要求的SDK。这意味着它应该至少支持姜饼设备。这可能是生成客户端的问题或GCP Java文档中的不一致。我使用Maven Plugin for Eclipse生成了客户端。我将尝试使用Android Studio生成客户端,看看它是否有任何区别。