【发布时间】:2018-01-06 07:34:47
【问题描述】:
所以我想将compile 'com.google.android.gms:play-services:10.0.1' 添加到我的gradle。应用级别gradle如下:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}
android {
compileSdkVersion 21
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 15
targetSdkVersion 21
versionCode 11
versionName "1.1"
dependencies {
// compile 'com.onesignal:OneSignal:[3.6.5, 3.99.99]'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
这也是我的项目级 gradle 文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
当我添加播放服务依赖时,它会导致这个错误:
Error:(4) Error retrieving parent for item: No resource found that matches the given name ' android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(34) Error retrieving parent for item: No resource found that matches
the given name 'android:Widget.Material.Button.Colored'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
我尝试了 10.0.1 之前的版本,但得到了相同的结果。我也不能使用低于 9.0.0 的版本,因为我收到了这个错误:
Error:(50, 0) Version: 8.4.0 is lower than the minimum version (9.0.0) required for google-services plugin.
我无法更改编译 SDK 版本。它必须是 21。这个问题也是一个更大问题的一部分:将 OneSignal 添加到我的项目中,以便我可以发送推送通知。我已经使用过 Firebase,但我必须改用 OneSignal,因为它具有特殊功能。 请注意,所有问题都是由于我的编译 SDK 版本降至 21。如果我将其更改为 23 或更高版本,我可以轻松地将 OneSignal 添加到我的项目中。
【问题讨论】:
-
您应该将 buildToolsVersion 更改为
buildToolsVersion "21.0.3"。 -
buildToolsVersion "21.0.3" 未在我的 SDK 管理器中列出。另外,当我在 gradle 中更改它时,它会显示
not all packages are available for download@Yuliwee -
确保 buildTooldVersion 和 compileSdkVersion 匹配。无论如何,我很困惑您必须使用 SDK 版本 21。OneSignal 也适用于较新的版本。而且您不需要添加 com.google.gms.... 依赖项。 OneSignal 文档告诉您需要做的一切:documentation.onesignal.com/docs/android-sdk-setup
-
听起来我必须打开另一个线程并发布我的主要问题,即使用编译 SDK 21 将 OneSignal 添加到我的项目中。这样就不会那么混乱了。@Yuliwee
-
为什么需要 compileSdkVersion 21?如果它更高,如果您不使用更新的功能,它仍然可以在旧系统上运行。
标签: android google-play-services onesignal