离子构建在 "Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]" 处失败
Ionic build fails at "Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]"
所以建筑一直很好,直到它不是。没有添加任何新内容,没有删除任何内容,没有安装任何包,什么都没有。在构建问题发生之前,一切都运行良好。这是完整的错误报告
> Configure project :app
Error 'Plugin-Version' of 'unspecified' for 'com.android.build.gradle.AppPlugin@4aae70b2' is not a valid version number
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99].
Required by:
project :app > com.onesignal:OneSignal:3.16.0
> Failed to list versions for com.google.android.gms:play-services-ads-identifier.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Failed to list versions for com.google.android.gms:play-services-ads-identifier.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Could not resolve com.google.android.gms:play-services-basement:[15.0.1,16.0.0).
Required by:
project :app > com.google.android.gms:play-services-location:15.0.1
project :app > com.google.android.gms:play-services-places-placereport:15.0.1
> Failed to list versions for com.google.android.gms:play-services-basement.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Failed to list versions for com.google.android.gms:play-services-basement.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Could not resolve com.google.android.gms:play-services-tasks:[15.0.1,16.0.0).
Required by:
project :app > com.google.android.gms:play-services-location:15.0.1
> Failed to list versions for com.google.android.gms:play-services-tasks.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Failed to list versions for com.google.android.gms:play-services-tasks.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/'.
> org.apache.http.client.ClientProtocolException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
关于可能导致此问题的任何想法?我尝试了以下但没有解决问题:
- 卸载后重新安装 npm 包 + 重新初始化平台和插件
- 正在将 gradle 从 7.2 更新到 7.4.2
- 正在删除 OneSignal 插件
尝试替换
jcenter()
有了这个:
mavenCentral()
看到这个问题
经过 hours-long 次反复试验后,我设法解决了这个问题,简而言之,我是这样做的:
- (可选)降级到 npm 6 以避免不兼容的 package-lock。json 错误。
- 升级到最新的 Gradle 版本(7.4.2 撰写此答案时)。
- 安装AndroidSDK构建工具版本30.0.3.
- 删除Android 平台,删除已安装的软件包和旧版本
- 重新安装 npm 包,阅读 Android 平台,最后构建您的项目。
这里还有一个 in-depth step-by-step 以上:
首先,我的终端被无休止的 npm 解决问题所困扰
左右,我曾经运行npm install --force
来保证
一切都专心地过去了,但现在我从全球范围内降级了 npm
版本 8 到 6 因为生成了项目的 package-lock.json
使用旧版本的 npm,因此存在一些不兼容性
在 lockFileVersion
从 1 更改为 2 之间。
其次,我将我的 Gradle 版本从 7.1.1 更新到 7.4.2(撰写此答案时的最新版本),然后更新了指向 bin 文件夹的环境变量路径以指向正确的 Gradle 版本(7.4.2)。
第三,我安装了必要的Android构建工具版本,以前的版本30.0.2对这个项目来说工作得很好,但现在它无法完成构建而不抱怨版本过时, 所以我继续安装版本 30.0.3, 你可以很容易地从 this link, or you can browse the full catalog of available builds here.
最后,我 android 从可行的平台删除了所有以前生成的构建,旧的
package-lock.json 文件、已安装的包、插件和生成
平台目录。
ionic cordova platform rm android
npm rm -rf package-lock.json node_modules www plugins platforms
然后重新安装节点模块
npm install
Re-add android 平台
ionic cordova platform add android
最后构建项目
ionic cordova build android
这是可选的,但如果您的构建抱怨 whiltelist 插件,只需执行以下操作:
1.
ionic cordova plugin rm cordova-plugin-whitelist
cordova plugin add https://github.com/apache/cordova-plugin-file-transfer.git
- 然后re-build你的项目
只需删除你的平台android@旧版本并添加平台android@9,然后就可以了。
我刚刚在 package.json 中将 cordova-android 的版本更新为 9.0.0。
所以建筑一直很好,直到它不是。没有添加任何新内容,没有删除任何内容,没有安装任何包,什么都没有。在构建问题发生之前,一切都运行良好。这是完整的错误报告
> Configure project :app
Error 'Plugin-Version' of 'unspecified' for 'com.android.build.gradle.AppPlugin@4aae70b2' is not a valid version number
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99].
Required by:
project :app > com.onesignal:OneSignal:3.16.0
> Failed to list versions for com.google.android.gms:play-services-ads-identifier.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Failed to list versions for com.google.android.gms:play-services-ads-identifier.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Could not resolve com.google.android.gms:play-services-basement:[15.0.1,16.0.0).
Required by:
project :app > com.google.android.gms:play-services-location:15.0.1
project :app > com.google.android.gms:play-services-places-placereport:15.0.1
> Failed to list versions for com.google.android.gms:play-services-basement.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Failed to list versions for com.google.android.gms:play-services-basement.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Could not resolve com.google.android.gms:play-services-tasks:[15.0.1,16.0.0).
Required by:
project :app > com.google.android.gms:play-services-location:15.0.1
> Failed to list versions for com.google.android.gms:play-services-tasks.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/'.
> org.apache.http.client.ClientProtocolException (no error message)
> Failed to list versions for com.google.android.gms:play-services-tasks.
> Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/'.
> Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/'.
> org.apache.http.client.ClientProtocolException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
关于可能导致此问题的任何想法?我尝试了以下但没有解决问题:
- 卸载后重新安装 npm 包 + 重新初始化平台和插件
- 正在将 gradle 从 7.2 更新到 7.4.2
- 正在删除 OneSignal 插件
尝试替换
jcenter()
有了这个:
mavenCentral()
看到这个问题
经过 hours-long 次反复试验后,我设法解决了这个问题,简而言之,我是这样做的:
- (可选)降级到 npm 6 以避免不兼容的 package-lock。json 错误。
- 升级到最新的 Gradle 版本(7.4.2 撰写此答案时)。
- 安装AndroidSDK构建工具版本30.0.3.
- 删除Android 平台,删除已安装的软件包和旧版本
- 重新安装 npm 包,阅读 Android 平台,最后构建您的项目。
这里还有一个 in-depth step-by-step 以上:
首先,我的终端被无休止的 npm 解决问题所困扰 左右,我曾经运行
npm install --force
来保证 一切都专心地过去了,但现在我从全球范围内降级了 npm 版本 8 到 6 因为生成了项目的 package-lock.json 使用旧版本的 npm,因此存在一些不兼容性 在lockFileVersion
从 1 更改为 2 之间。其次,我将我的 Gradle 版本从 7.1.1 更新到 7.4.2(撰写此答案时的最新版本),然后更新了指向 bin 文件夹的环境变量路径以指向正确的 Gradle 版本(7.4.2)。
第三,我安装了必要的Android构建工具版本,以前的版本30.0.2对这个项目来说工作得很好,但现在它无法完成构建而不抱怨版本过时, 所以我继续安装版本 30.0.3, 你可以很容易地从 this link, or you can browse the full catalog of available builds here.
最后,我 android 从可行的平台删除了所有以前生成的构建,旧的 package-lock.json 文件、已安装的包、插件和生成 平台目录。
ionic cordova platform rm android npm rm -rf package-lock.json node_modules www plugins platforms
然后重新安装节点模块
npm install
Re-add android 平台
ionic cordova platform add android
最后构建项目
ionic cordova build android
这是可选的,但如果您的构建抱怨 whiltelist 插件,只需执行以下操作:
1.
ionic cordova plugin rm cordova-plugin-whitelist
cordova plugin add https://github.com/apache/cordova-plugin-file-transfer.git
- 然后re-build你的项目
只需删除你的平台android@旧版本并添加平台android@9,然后就可以了。
我刚刚在 package.json 中将 cordova-android 的版本更新为 9.0.0。