Android Gradle Apache HttpClient 不存在?
Android Gradle Apache HttpClient does not exist?
我正在尝试将 IntelliJ 项目转换为 Android Studio 的 Gradle 系统,但我 运行 遇到 Apache HttpClient 的错误?我是不是遗漏了什么,我得到的错误如下:
Error:(10, 30) error: package org.apache.http.client does not exist
Error:(11, 30) error: package org.apache.http.client does not exist
Error:(12, 37) error: package org.apache.http.client.entity does not exist
Error:(13, 38) error: package org.apache.http.client.methods does not exist
Error:(14, 38) error: package org.apache.http.client.methods does not exist
Error:(15, 38) error: package org.apache.http.client.methods does not exist
Error:(16, 35) error: package org.apache.http.impl.client does not exist
Error:(134, 33) error: cannot find symbol class HttpUriRequest
Error:(164, 39) error: cannot find symbol class HttpUriRequest
Error:(106, 17) error: cannot find symbol class HttpGet
Error:(106, 39) error: cannot find symbol class HttpGet
Error:(117, 17) error: cannot find symbol class HttpPost
Error:(117, 40) error: cannot find symbol class HttpPost
Error:(125, 43) error: cannot find symbol class UrlEncodedFormEntity
Error:(135, 9) error: cannot find symbol class HttpClient
Error:(135, 33) error: cannot find symbol class DefaultHttpClient
Error:(155, 18) error: cannot find symbol class ClientProtocolException
Error:(165, 9) error: cannot find symbol class HttpClient
Error:(165, 33) error: cannot find symbol class DefaultHttpClient
Error:(185, 18) error: cannot find symbol class ClientProtocolException
我的 build.gradle 文件具有以下依赖项:
dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'org.apache.httpcomponents:httpclient:4.2.6'
compile 'org.apache.httpcomponents:httpmime:4.2.6'
compile files('libs/core.jar')
}
似乎很多人都遇到了类似的问题,但 SO 或 Google 都没有解决方案,所以我希望这个问题对未来的搜索者有所帮助。
我运行遇到了类似的问题,您也许可以使用类似的方法让它工作。
首先,尝试使用您当前的配置,从 httpmime
中排除 httpclient
:
dependencies {
compile 'com.google.android.gms:play-services:+'
compile ('org.apache.httpcomponents:httpmime:4.2.6'){
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient:4.2.6'
}
就我而言,我使用以下 jars 修复了它:
然后,在build.gradle中,从httpmime
中排除httpclient
:
dependencies {
compile 'com.google.android.gms:play-services:+'
compile('org.apache.httpcomponents:httpmime:4.3.5') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}
我遇到了这个问题,然后找到了这些页面:
在这里您可以看到 apache 库已被弃用,但它没有被删除,所以它应该可以工作。它没有。
See。
在这里您可以看到如何将 apache 库包含到您的项目中
See.
我按照第二 link 中的建议将以下内容添加到我的 build.gradle 文件中解决了问题。
android {
useLibrary 'org.apache.http.legacy'
}
然而,这仅在您使用 gradle 1.3.0-beta2 或更高版本时有效,因此如果您使用的是较低版本,则必须将其添加到构建脚本依赖项中:
classpath 'com.android.tools.build:gradle:1.3.0-beta2'
希望对您有所帮助。
如果您将目标 sdk 用作 23,请在 build.gradle
中添加以下代码
android{
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
}
并将您的构建脚本更改为
classpath 'com.android.tools.build:gradle:1.3.0'
如需更多信息,请关注此 link
我运行遇到了同样的问题。 Daniel Nugent 的回答有点帮助(在按照他的建议 HttpResponse
找到后 - 但 HttpClient
仍然丢失)。
所以这是为我修复它的方法:
- (如果还没有完成,推荐以前的导入语句)
- 访问http://hc.apache.org/downloads.cgi
- 从二进制部分得到
4.5.1.zip
- 解压并粘贴
httpcore-4.4.3
& httpclient-4.5.1.jar
到 project/libs
文件夹
- 右键单击 jar 并选择添加为库。
希望对您有所帮助。
这就是我所做的,对我有用。
第 1 步:将其添加到 build.grade(module: app)
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
第 2 步:同步项目并完成。
将 Android/Sdk/platforms/android-23/optional
文件夹中的 org.apache.http.legacy.jar
复制到 app/libs
并将此行添加到 app.gradle 文件
compile files('libs/org.apache.http.legacy.jar')
但是如果你使用的jar库比较多,可以这样使用
compile fileTree(dir: 'libs', include: ['*.jar'])
基本上你需要做的就是添加:
useLibrary 'org.apache.http.legacy'
到您的 build.gradle
文件。
现货供应的 Apache HTTP 客户端版本 Android 是 very very old。
Google Android 1.0 was released with a pre-BETA snapshot of Apache HttpClient. To coincide with the first Android release Apache HttpClient 4.0 APIs had to be frozen prematurely, while many of interfaces and internal structures were still not fully worked out. As Apache HttpClient 4.0 was maturing the project was expecting Google to incorporate the latest code improvements into their code tree. Unfortunately it did not happen.
虽然您可以通过useLibrary 'org.apache.http.legacy'
解决方法(由@Jinu 和其他人建议)继续使用旧的已弃用库,但您确实需要硬着头皮更新到别的东西,例如原生 Android HttpUrlConnection
, or if that doesn't meet your needs, you can use the OkHttp library, which is what HttpUrlConnection
is internally based upon 无论如何。
OkHttp 实际上有一个 compatibility layer 使用与 Apache 客户端相同的 API,尽管它们没有实现 all 相同的功能,所以你的里程可能会有所不同。
虽然 it is possible to import a newer version of the Apache client(如@MartinPfeffer 所建议),但很可能您之前使用的大多数 类 和方法已被弃用,并且存在相当大的更新风险在您的代码中引入错误(例如,我发现一些以前在代理后面工作的连接不再工作),所以这不是一个很好的解决方案。
Jinu 和 Daniel 的完美答案
添加到这个
如果您的 compileSdkVersion 是 19(在我的情况下)
,我通过使用这个解决了问题
compile ('org.apache.httpcomponents:httpmime:4.3'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile ('org.apache.httpcomponents:httpcore:4.4.1'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile 'commons-io:commons-io:1.3.2'
否则如果你的compileSdkVersion是23
然后使用
android {
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
在这个问题上花了几天时间,我终于解决了。不幸的是,如果我们想使用扩展文件,我们需要它。这里的一些人已经提供了解决方案,但对我来说,答案缺少一些小细节,这些细节可以为我节省很多时间。为我这样的新手节省宝贵的时间。
首先,我通过进入“文件”、“新建”、“导入模块”并导航到 "library" 文件夹,将 "library" 文件夹从 D:\Users\Imre\AppData\Local\Android\sdk1\extras\google\play_licensing 导入到项目中。如果您打开 SDK 管理器并单击弹出屏幕底部的 "Launch Standalone SDK Manager",您可以将指针悬停在底部的 "Extras" 文件夹上,黄色的小信息将告诉您您将在哪里找到您需要导入的包。
完成后,使用 "Project" 进入左窗格中的 "library" 部分,并在其中打开 "Android" 选项卡。打开库的 java 部分并打开 APKExpansionPolicy class。
如果您有错误并且导入 org.apache.http.NameValuePair 和导入 org.apache.http.client.utils.URLEncodedUtils 是浅灰色,请打开 build.gradle(Project:whatever) 并确保在 "buildscript" 下的 [=35] =] 你有 "classpath 'com.android.tools.build:gradle:1.5.0" 包括在内。 1.5.0 可能与您的情况不同。我想这取决于您的 Studio 版本。我的是 1.5.1。如果您的号码较新,系统会提醒您更新号码。
之后,转到 "build.gradle(Module:library) and include the "useLibrary 'org.apache.http.legacy' 进入 "android" 部分。应提供立即同步(R/H 顶角)。做吧。
如果您收到更多错误消息(我不知道,因为我是反过来做的),您的项目中可能缺少 Apache 文件,因为不再支持 apache。在 C/D:Users/Yourname/AppData/Local/Android/Sdk/platforms/android-23/optional 中找到它们,在 copy/paste 中找到它们到 yourproject/app/libs 文件夹中。你应该有一个 optional.json 和一个 org.apache.http.legacy.jar 文件。您最好去 apache 的网站下载最新版本:http://hc.apache.org/downloads.cgi 将其解压缩到您想要的任何位置,打开它,转到 "lib",复制 httpclient-4.5.1.jar 文件并用它替换 org.apache.http.legacy.jar 文件。
同步和 rebuild/clean 您的项目,应该可以开始了。
以防万一,打开您的终端(Android Studio 的L/H 底部)并输入 "gradlew clean"。它会安装一些东西。完成后,输入 "gradlew assemble"。这将需要几分钟才能完成,但如果您有任何错误,它会给您错误。
如果您无法在终端中输入任何内容,请启动命令提示符(Windows 按钮+R),输入 cmd,点击确定,右键单击黑色小弹出屏幕的标题(C:\WINDOWS\system32\cmd .exe), Properties, Options, 在底部的window检查"Use legacy console"是否加粗。重启 A.Studio.
祝你好运!
我不得不 post 因为 none 以上答案完全适合我。
我正在使用 Android Studio
classpath 'com.android.tools.build:gradle:1.5.0'
compileSdkVersion 23
buildToolsVersion "23.0.3"
第 1 步:下载最新的 jar 文件 (http://www-eu.apache.org/dist//httpcomponents/httpclient/binary/httpcomponents-client-4.5.2-bin.zip)
第 2 步:将 .jar 文件复制粘贴到模块(可以是应用程序或库)中的 libs 文件夹(如果不存在则创建)
第 3 步:右键单击罐子并 "Add as Library"。它会自动将 jar 文件添加为模块的 gradle 文件
中的依赖项
第 4 步:现在您的问题将自动得到解决,但如果您在应用程序中使用混淆器,它会向您发出有关重复 class 文件的警告,并且不会让您构建。这是一个已知错误,您需要将以下内容添加到您的 proguard-rules
-dontwarn org.apache.commons.**
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
祝你好运!
就我而言,我更新了 android 项目中的一个库。
我正在使用 Reservoir 作为我的缓存存储解决方案:https://github.com/anupcowkur/Reservoir
我来自:
compile 'com.anupcowkur:reservoir:2.1'
收件人:
compile 'com.anupcowkur:reservoir:3.1.0'
库作者一定是从 repo 中删除了 commons-io 库,所以我的应用程序不再有效。
我必须通过将其添加到 gradle:
来手动包含 commons-io
compile 'commons-io:commons-io:2.5'
https://mvnrepository.com/artifact/commons-io/commons-io/2.5
将此库添加到 build.gradle
android {
useLibrary 'org.apache.http.legacy'
}
我建议您将已弃用的 apache HttpClient 替换为新的 HttpURLConnection。
这是一个更干净的解决方案,它很容易迁移,而且通常坚持最新的 SDK 更改比尝试 hack/patch/workaround 更好:您通常稍后会后悔 :)
步骤 1
HttpGet httpGet = new HttpGet(url);
变成:
URL urlObj = new URL(url);
步骤 2
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpResponse response = httpClient.execute(httpGet, localContext);
InputStream is = response.getEntity().getContent();
变成:
HttpURLConnection urlConnection = (HttpURLConnection) urlObj.openConnection();
InputStream is = urlConnection.getInputStream();
步骤 2 之二
int status = response.getStatusLine().getStatusCode();
变成:
int status = urlConnection.getResponseCode();
我克隆了以下内容:https://github.com/google/play-licensing
然后我将其导入到我的项目中。
我正在尝试将 IntelliJ 项目转换为 Android Studio 的 Gradle 系统,但我 运行 遇到 Apache HttpClient 的错误?我是不是遗漏了什么,我得到的错误如下:
Error:(10, 30) error: package org.apache.http.client does not exist
Error:(11, 30) error: package org.apache.http.client does not exist
Error:(12, 37) error: package org.apache.http.client.entity does not exist
Error:(13, 38) error: package org.apache.http.client.methods does not exist
Error:(14, 38) error: package org.apache.http.client.methods does not exist
Error:(15, 38) error: package org.apache.http.client.methods does not exist
Error:(16, 35) error: package org.apache.http.impl.client does not exist
Error:(134, 33) error: cannot find symbol class HttpUriRequest
Error:(164, 39) error: cannot find symbol class HttpUriRequest
Error:(106, 17) error: cannot find symbol class HttpGet
Error:(106, 39) error: cannot find symbol class HttpGet
Error:(117, 17) error: cannot find symbol class HttpPost
Error:(117, 40) error: cannot find symbol class HttpPost
Error:(125, 43) error: cannot find symbol class UrlEncodedFormEntity
Error:(135, 9) error: cannot find symbol class HttpClient
Error:(135, 33) error: cannot find symbol class DefaultHttpClient
Error:(155, 18) error: cannot find symbol class ClientProtocolException
Error:(165, 9) error: cannot find symbol class HttpClient
Error:(165, 33) error: cannot find symbol class DefaultHttpClient
Error:(185, 18) error: cannot find symbol class ClientProtocolException
我的 build.gradle 文件具有以下依赖项:
dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'org.apache.httpcomponents:httpclient:4.2.6'
compile 'org.apache.httpcomponents:httpmime:4.2.6'
compile files('libs/core.jar')
}
似乎很多人都遇到了类似的问题,但 SO 或 Google 都没有解决方案,所以我希望这个问题对未来的搜索者有所帮助。
我运行遇到了类似的问题,您也许可以使用类似的方法让它工作。
首先,尝试使用您当前的配置,从 httpmime
中排除 httpclient
:
dependencies {
compile 'com.google.android.gms:play-services:+'
compile ('org.apache.httpcomponents:httpmime:4.2.6'){
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient:4.2.6'
}
就我而言,我使用以下 jars 修复了它:
然后,在build.gradle中,从httpmime
中排除httpclient
:
dependencies {
compile 'com.google.android.gms:play-services:+'
compile('org.apache.httpcomponents:httpmime:4.3.5') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}
我遇到了这个问题,然后找到了这些页面: 在这里您可以看到 apache 库已被弃用,但它没有被删除,所以它应该可以工作。它没有。
See。
在这里您可以看到如何将 apache 库包含到您的项目中
See.
我按照第二 link 中的建议将以下内容添加到我的 build.gradle 文件中解决了问题。
android {
useLibrary 'org.apache.http.legacy'
}
然而,这仅在您使用 gradle 1.3.0-beta2 或更高版本时有效,因此如果您使用的是较低版本,则必须将其添加到构建脚本依赖项中:
classpath 'com.android.tools.build:gradle:1.3.0-beta2'
希望对您有所帮助。
如果您将目标 sdk 用作 23,请在 build.gradle
中添加以下代码android{
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
}
并将您的构建脚本更改为
classpath 'com.android.tools.build:gradle:1.3.0'
如需更多信息,请关注此 link
我运行遇到了同样的问题。 Daniel Nugent 的回答有点帮助(在按照他的建议 HttpResponse
找到后 - 但 HttpClient
仍然丢失)。
所以这是为我修复它的方法:
- (如果还没有完成,推荐以前的导入语句)
- 访问http://hc.apache.org/downloads.cgi
- 从二进制部分得到
4.5.1.zip
- 解压并粘贴
httpcore-4.4.3
&httpclient-4.5.1.jar
到project/libs
文件夹 - 右键单击 jar 并选择添加为库。
希望对您有所帮助。
这就是我所做的,对我有用。
第 1 步:将其添加到 build.grade(module: app)
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
第 2 步:同步项目并完成。
将 Android/Sdk/platforms/android-23/optional
文件夹中的 org.apache.http.legacy.jar
复制到 app/libs
并将此行添加到 app.gradle 文件
compile files('libs/org.apache.http.legacy.jar')
但是如果你使用的jar库比较多,可以这样使用
compile fileTree(dir: 'libs', include: ['*.jar'])
基本上你需要做的就是添加:
useLibrary 'org.apache.http.legacy'
到您的 build.gradle
文件。
现货供应的 Apache HTTP 客户端版本 Android 是 very very old。
Google Android 1.0 was released with a pre-BETA snapshot of Apache HttpClient. To coincide with the first Android release Apache HttpClient 4.0 APIs had to be frozen prematurely, while many of interfaces and internal structures were still not fully worked out. As Apache HttpClient 4.0 was maturing the project was expecting Google to incorporate the latest code improvements into their code tree. Unfortunately it did not happen.
虽然您可以通过useLibrary 'org.apache.http.legacy'
解决方法(由@Jinu 和其他人建议)继续使用旧的已弃用库,但您确实需要硬着头皮更新到别的东西,例如原生 Android HttpUrlConnection
, or if that doesn't meet your needs, you can use the OkHttp library, which is what HttpUrlConnection
is internally based upon 无论如何。
OkHttp 实际上有一个 compatibility layer 使用与 Apache 客户端相同的 API,尽管它们没有实现 all 相同的功能,所以你的里程可能会有所不同。
虽然 it is possible to import a newer version of the Apache client(如@MartinPfeffer 所建议),但很可能您之前使用的大多数 类 和方法已被弃用,并且存在相当大的更新风险在您的代码中引入错误(例如,我发现一些以前在代理后面工作的连接不再工作),所以这不是一个很好的解决方案。
Jinu 和 Daniel 的完美答案
添加到这个 如果您的 compileSdkVersion 是 19(在我的情况下)
,我通过使用这个解决了问题compile ('org.apache.httpcomponents:httpmime:4.3'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile ('org.apache.httpcomponents:httpcore:4.4.1'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile 'commons-io:commons-io:1.3.2'
否则如果你的compileSdkVersion是23 然后使用
android {
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
在这个问题上花了几天时间,我终于解决了。不幸的是,如果我们想使用扩展文件,我们需要它。这里的一些人已经提供了解决方案,但对我来说,答案缺少一些小细节,这些细节可以为我节省很多时间。为我这样的新手节省宝贵的时间。
首先,我通过进入“文件”、“新建”、“导入模块”并导航到 "library" 文件夹,将 "library" 文件夹从 D:\Users\Imre\AppData\Local\Android\sdk1\extras\google\play_licensing 导入到项目中。如果您打开 SDK 管理器并单击弹出屏幕底部的 "Launch Standalone SDK Manager",您可以将指针悬停在底部的 "Extras" 文件夹上,黄色的小信息将告诉您您将在哪里找到您需要导入的包。
完成后,使用 "Project" 进入左窗格中的 "library" 部分,并在其中打开 "Android" 选项卡。打开库的 java 部分并打开 APKExpansionPolicy class。 如果您有错误并且导入 org.apache.http.NameValuePair 和导入 org.apache.http.client.utils.URLEncodedUtils 是浅灰色,请打开 build.gradle(Project:whatever) 并确保在 "buildscript" 下的 [=35] =] 你有 "classpath 'com.android.tools.build:gradle:1.5.0" 包括在内。 1.5.0 可能与您的情况不同。我想这取决于您的 Studio 版本。我的是 1.5.1。如果您的号码较新,系统会提醒您更新号码。
之后,转到 "build.gradle(Module:library) and include the "useLibrary 'org.apache.http.legacy' 进入 "android" 部分。应提供立即同步(R/H 顶角)。做吧。
如果您收到更多错误消息(我不知道,因为我是反过来做的),您的项目中可能缺少 Apache 文件,因为不再支持 apache。在 C/D:Users/Yourname/AppData/Local/Android/Sdk/platforms/android-23/optional 中找到它们,在 copy/paste 中找到它们到 yourproject/app/libs 文件夹中。你应该有一个 optional.json 和一个 org.apache.http.legacy.jar 文件。您最好去 apache 的网站下载最新版本:http://hc.apache.org/downloads.cgi 将其解压缩到您想要的任何位置,打开它,转到 "lib",复制 httpclient-4.5.1.jar 文件并用它替换 org.apache.http.legacy.jar 文件。
同步和 rebuild/clean 您的项目,应该可以开始了。
以防万一,打开您的终端(Android Studio 的L/H 底部)并输入 "gradlew clean"。它会安装一些东西。完成后,输入 "gradlew assemble"。这将需要几分钟才能完成,但如果您有任何错误,它会给您错误。 如果您无法在终端中输入任何内容,请启动命令提示符(Windows 按钮+R),输入 cmd,点击确定,右键单击黑色小弹出屏幕的标题(C:\WINDOWS\system32\cmd .exe), Properties, Options, 在底部的window检查"Use legacy console"是否加粗。重启 A.Studio.
祝你好运!
我不得不 post 因为 none 以上答案完全适合我。
我正在使用 Android Studio
classpath 'com.android.tools.build:gradle:1.5.0'
compileSdkVersion 23
buildToolsVersion "23.0.3"
第 1 步:下载最新的 jar 文件 (http://www-eu.apache.org/dist//httpcomponents/httpclient/binary/httpcomponents-client-4.5.2-bin.zip)
第 2 步:将 .jar 文件复制粘贴到模块(可以是应用程序或库)中的 libs 文件夹(如果不存在则创建)
第 3 步:右键单击罐子并 "Add as Library"。它会自动将 jar 文件添加为模块的 gradle 文件
中的依赖项第 4 步:现在您的问题将自动得到解决,但如果您在应用程序中使用混淆器,它会向您发出有关重复 class 文件的警告,并且不会让您构建。这是一个已知错误,您需要将以下内容添加到您的 proguard-rules
-dontwarn org.apache.commons.**
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
祝你好运!
就我而言,我更新了 android 项目中的一个库。
我正在使用 Reservoir 作为我的缓存存储解决方案:https://github.com/anupcowkur/Reservoir
我来自:
compile 'com.anupcowkur:reservoir:2.1'
收件人:
compile 'com.anupcowkur:reservoir:3.1.0'
库作者一定是从 repo 中删除了 commons-io 库,所以我的应用程序不再有效。
我必须通过将其添加到 gradle:
来手动包含 commons-iocompile 'commons-io:commons-io:2.5'
https://mvnrepository.com/artifact/commons-io/commons-io/2.5
将此库添加到 build.gradle
android {
useLibrary 'org.apache.http.legacy'
}
我建议您将已弃用的 apache HttpClient 替换为新的 HttpURLConnection。
这是一个更干净的解决方案,它很容易迁移,而且通常坚持最新的 SDK 更改比尝试 hack/patch/workaround 更好:您通常稍后会后悔 :)
步骤 1
HttpGet httpGet = new HttpGet(url);
变成:
URL urlObj = new URL(url);
步骤 2
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpResponse response = httpClient.execute(httpGet, localContext);
InputStream is = response.getEntity().getContent();
变成:
HttpURLConnection urlConnection = (HttpURLConnection) urlObj.openConnection();
InputStream is = urlConnection.getInputStream();
步骤 2 之二
int status = response.getStatusLine().getStatusCode();
变成:
int status = urlConnection.getResponseCode();
我克隆了以下内容:https://github.com/google/play-licensing
然后我将其导入到我的项目中。