Gee*_*oid 8 android gradle android-build android-gradle-plugin android-flexboxlayout
我的gradle文件存在运行时问题.我将此compile 'com.google.android:flexbox:0.3.1'作为编译时依赖项添加到我的Gradle文件中.我遇到了一个错误,并将其添加到我的项目级Gradle文件中.
maven {
url "https://maven.google.com"
}
Run Code Online (Sandbox Code Playgroud)
添加上述内容后,最终看起来很喜欢这个
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我的应用程序级别Gradle文件中添加上述内容后,当我尝试运行我的应用程序时,我现在遇到了不同的错误.所以我按照SO的一些答案做了以下几点.
导航到路径projectName\.idea\libraries并删除包含除当前版本25.3.1
3 之外的支持库版本的文件.为了解决错误,我从我的应用程序级Gradle文件中进一步删除了该行,
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{exclude group:'com.android.support',module:'support-annotations'})
现在,最终的Gradle文件看起来像这样,带有错误,
错误:
Error:(28, 8) error: cannot access ActivityCompatApi23
class file for android.support.v4.app.ActivityCompatApi23 not found
Run Code Online (Sandbox Code Playgroud)
我的Gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android:flexbox:0.3.1'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
就像我遇到的问题一样.
当我像这样使用Android Room:
compileSdkVersion 25编译"android.arch.persistence.room:runtime:1.0.0"
我犯了同样的错误.
因为compileSdkVersion应该匹配支持libs的主要版本.
更多详细信息,您可以看到: 在房间持久性后支持lib时出错
房间取决于26.1的支持库,这可能是它被破坏的原因,因为SupportLibrary不承诺版本之间的互操作.
此外,您可以使用此方法解决问题
compile ("android.arch.persistence.room:runtime:1.0.0") {
exclude group: 'com.android.support'
}Run Code Online (Sandbox Code Playgroud)
您已声明compileSdkVersion等于 25,而0.3.1Flexbox 布局的版本使用支持库版本26.0.0- 这是一个问题,compileSdkVersion应该与支持库主要版本匹配。
要么将你的项目升级到26,要么使用依赖sdk 25的flexbox布局版本,似乎是v0.2.7:
compile 'com.google.android:flexbox:0.2.7'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9681 次 |
| 最近记录: |