Sté*_*ani 103 android gradle cordova
当我运行时cordova build android --buildConfig xxxx --release,我收到以下错误:
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
Run Code Online (Sandbox Code Playgroud)
奇怪的是我使用两台macOS机器进行编译,我只在其中一台机器上获得相同代码的错误.
这是./gradlew cdvPrintProps我在两台机器上的输出:
:cdvPrintProps
cdvCompileSdkVersion=26
cdvBuildToolsVersion=27.0.3
cdvVersionCode=null
cdvMinSdkVersion=21
cdvBuildMultipleApks=true
cdvReleaseSigningPropertiesFile=release-signing.properties
cdvDebugSigningPropertiesFile=null
cdvBuildArch=null
computedVersionCode=152045989
computedArmv7VersionCode=1520459892
computedX86VersionCode=1520459894
Run Code Online (Sandbox Code Playgroud)
以下是使用的插件列表:
$ cordova plugins list
cordova-custom-config 5.0.2 "cordova-custom-config"
cordova-fabric-plugin 1.1.10 "cordova-fabric-plugin"
cordova-open-native-settings 1.5.0 "Native settings"
cordova-plugin-app-event 1.2.1 "Application Events"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-crosswalk-webview 2.4.0 "Crosswalk WebView Engine"
cordova-plugin-datepicker 0.9.2 "DatePicker"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-email 1.2.7 "EmailComposer"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-inappbrowser 1.7.2 "InAppBrowser"
cordova-plugin-network-information 1.3.4 "Network Information"
cordova-plugin-secure-storage 2.6.8 "SecureStorage"
cordova-plugin-splashscreen 4.1.0 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova.plugins.diagnostic 3.9.2 "Diagnostic"
de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification"
ionic-plugin-keyboard 2.2.1 "Keyboard"
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
小智 106
只需在build-extras.gradle中添加以下内容即可
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
Run Code Online (Sandbox Code Playgroud)
And*_*scu 83
谷歌发布了com.android.support:support-v4的新版本28.0.0-alpha1,它增加了2个新属性(android:fontVariationSettings和android:ttcIndex).一些插件使用最新的android支持库,导致不必要的兼容性.
选项1: 安装cordova-android-support-gradle-release插件.
记录良好的插件,"将其他插件指定的Android支持库的各种版本与特定版本对齐".测试时没有任何破坏性行为.
cordova plugin add cordova-android-support-gradle-release --fetch
Run Code Online (Sandbox Code Playgroud)
阅读文档以获取完整的选项:自述文件
选项2:在platforms/android下的build.gradle中添加下一个代码片段
/**
IMPORTANT - Manually added
Problem: 8 March 2018 - Google released version support-v4:28.0.0-alpha1
which breaks the project with following error: unable to find attribute
android:fontVariationSettings and android:ttcIndex
Effect: Force a specific version of the library
*/
configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:27.1.0'
}
Run Code Online (Sandbox Code Playgroud)
警告:如果删除/添加Android平台,build.gradle中的代码将被覆盖.如果您由于某种原因不想使用该插件或以某种方式不适合您,而是每次都创建一个钩子并覆盖该文件.检查第二评论在这里.
如果问题持续存在,您可以尝试:
cordova platform rm android
cordova platform add android
Run Code Online (Sandbox Code Playgroud)
要么
确保你没有安装该应用程序的前一版本在测试设备上,因为你会收到一个明确的错误当它试图降级现有的版本:"INSTALL_FAILED_VERSION_DOWNGRADE"和"UnhandledPromiseRejectionWarning:未处理的承诺拒绝"
avm*_*tte 31
同样的错误发生在我身上.显然,该com.android.support:support-v4库的新版本已经发布,我正在使用的插件定义com.android.support:support-v4:+为依赖plugin.xml.该+标志意味着它将获得最新的版本(28.0.0),这似乎似乎与其他插件不兼容.
我能够更改所有插件的依赖,以建立一个开发版本com.android.support:support-v4:+来com.android.support:support-v4:27.1.0.另外,我执行ionic cordova platform remove android和ionic cordova platform add android.希望它有所帮助,至少对于发展而言.
Ahm*_*med 28
我刚刚通过转到platform/android文件夹修改了这个问题并编辑了project.properties文件并替换com.android.support:support-v4:+为com.android.support:support-v4:27.1.0.
小智 21
如果您真的需要快速修复该问题以使您的构建运行,您可以尝试将以下行添加到您的platforms/android/build.gradle文件中:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
Run Code Online (Sandbox Code Playgroud)
无论如何,在这里设置版本不是一个可持续的修复.
小智 15
这很奇怪,但是当我使用相同版本添加以下行时它会起作用.
这是我在platforms/android/build.gradle文件中的相关行:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.android.support:support-v4:26.+"
compile "com.android.support:appcompat-v7:26.+"
// SUB-PROJECT DEPENDENCIES END
}
// ADDED THESE LINES
configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:26+'
}
Run Code Online (Sandbox Code Playgroud)
在我的项目中,问题是因为'cordova-plugin-crosswalk-webview'插件而发生的.
小智 8
我有相同的错误,但没有在cordova构建.一个新版本的com.android.support:appcompat-v7依赖项和依赖项.但是不兼容的版本在依赖于.Socom.android.support:appcompat-v7的第三个包中.我无法使用@avmatte的解决方案修复第三个包 .
使用@ Sai Teja的解决方案找到不兼容的包:
gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
Run Code Online (Sandbox Code Playgroud)
然后修复它:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-compat:{the_same_version}'
force 'com.android.support:appcompat-v7:{the_same_version}'
force 'com.android.support:support-core-utils:{the_same_version}'
force 'com.android.support:support-core-ui:{the_same_version}'
force 'com.android.support:support-fragment:{the_same_version}'
force 'com.android.support:support-annotations:{the_same_version}'
...
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码强制依赖版本.
小智 8
我遇到了同样的错误.在com.android.support:support-v4:+的plugin目录中进行了完整的研究,并将其替换为静态版本代码.
对我来说,com.android.support:support-v4:23.4.0工作正常.那时没有必要删除并重新添加android平台.
这是一个简单的方法来解决它,当平台目录重建时将持续存在,并且不需要通过所有插件来尝试找到罪魁祸首.创建build-extras.gradle包含以下内容的文件:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
Run Code Online (Sandbox Code Playgroud)
然后after_platform_add/010_copy_build_extras.js使用以下内容创建文件:
#!/usr/bin/env node
var fs = require('fs');
var rootdir = process.argv[2];
var android_dir = `${rootdir}/platforms/android`;
var gradle_filename = 'build-extras.gradle';
var gradle_file = `${rootdir}/${gradle_filename}`;
if (fs.existsSync(android_dir) && fs.existsSync(gradle_file)) {
fs.createReadStream(gradle_file)
.pipe(fs.createWriteStream(`${android_dir}/${gradle_filename}`));
}
Run Code Online (Sandbox Code Playgroud)
现在重新创建android平台,它将使用固定支持库.
您的某些图书馆应使用
com.android.support:support-v4:+
Run Code Online (Sandbox Code Playgroud)
找到哪一个是
gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
Run Code Online (Sandbox Code Playgroud)
如果该库未在其最新更新中使用特定版本,则将该库添加为模块(也请在该库中引起问题!;))
感谢@avmatte!
编辑:您也可以请求gradle强制使用库版本
ext {
supportVersion {latest_version_here}
} // In root project.gradle
configurations.all {
resolutionStrategy {
force "com.android.support:support-v4:$supportVersion"
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
将以下行添加到您的平台/android/build.gradle
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
Run Code Online (Sandbox Code Playgroud)
如果仍有问题,请尝试运行此命令:
cordova plugin add cordova-android-support-gradle-release --fetch
Run Code Online (Sandbox Code Playgroud)
我在Ionic论坛上找到了该解决方案,这是唯一对我有用的解决方案:
跑:
离子科尔多瓦平台rm android
跑:
离子Cordova平台添加android@8.0.0
跑:
离子Cordova插件添加cordova-plugin-androidx
跑:
离子Cordova插件添加cordova-plugin-androidx-adapter
确保您的gradle.properties具有:
cdvMinSdkVersion = 19
确保您的build.gradle具有:
project.ext { defaultBuildToolsVersion="28.0.3" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default }
Run Code Online (Sandbox Code Playgroud)
确保您的config.xml具有:
<preference name="android-minSdkVersion" value="19" />
Run Code Online (Sandbox Code Playgroud)
来自:https : //forum.ionicframework.com/t/firebase-app-unable-to-compile-on-android-with-aapt-error/166564/7
在stackoverflow答案中也可以处理:https : //stackoverflow.com/a/56656680/839691
| 归档时间: |
|
| 查看次数: |
59751 次 |
| 最近记录: |