无法访问ActivityCompatApi23类 [英] Cannot access ActivityCompatApi23 class
问题描述
我的gradle文件遇到运行时问题。我将这个 compile'com.google.android:flexbox:0.3.1'
作为编译时间依赖项添加到我的Gradle文件中。我遇到了一个错误,并将其添加到我的项目级别的Gradle文件中。
maven {
urlhttps:// maven.google.com
在添加上面的
allprojects {
存储库{
jcenter()
maven {
url https://maven.google.com
}
}
在我的应用程序级别的Gradle文件中添加上面的内容后,我正在尝试运行我的应用程序时遇到了另一个错误。所以我按照SO的一些答案完成了以下内容。
- 尝试了一个Clean和Rebuild。
-
导航到
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文件看起来像这样,并带有错误,
错误:
错误:(28,8)错误:无法访问ActivityCompatApi23
class for android .support.v4.app.ActivityCompatApi23未找到
我的Gradle文件
apply plugin:'com.android.application
android {
compileSdkVersion 25
buildToolsVersion25.0.3
defaultConfig {
applicationIdcom.example.test
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName1.0
testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
依赖关系{
编译fileTree(包括:['* .jar'],dir:'libs')
编译'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'
编译'com.google.android:flexbox:0.3.1'
编译'uk.co.chrisjenx:书法:2.3.0'
testCompile'junit:junit:4.12'
解决方案> compileSdkVersion 等于25,而
0.3.1
版本的Flexbox布局使用支持库版本26.0.0
- 这是一个问题,compileSdkVersion
应该与支持库的主要版本匹配。
将项目升级到26或使用依赖于flexbox版本的版本在sdk 25上,它似乎是v0.2.7:
compile'com.google.android:flexbox:0.2.7'
I am having runtime problems with my gradle file. I added this
compile 'com.google.android:flexbox:0.3.1'
as a compile time dependency to my Gradle file. I encountered an error and added this in my project level Gradle file.maven { url "https://maven.google.com" }
Which finally looked liked this after adding the above
allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } }
After adding the above in my app level Gradle file I am now encountering a different error when I am trying to run my app. So I did the following as per some answers from SO.
- Tried a Clean and Rebuild.
Navigated to the path
projectName\.idea\libraries
and deleted the files that contained the support library version other than the current versions25.3.1
3.In order to solve the error I further removed this line from my app level Gradle file,androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' })
Now the final Gradle file looks like this with the error,
Error:
Error:(28, 8) error: cannot access ActivityCompatApi23 class file for android.support.v4.app.ActivityCompatApi23 not found
My Gradle file
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' }
解决方案You have declared
compileSdkVersion
equal to 25, whereas0.3.1
version of flexbox layout uses support libs version26.0.0
- that's a problem,compileSdkVersion
should match support libs major version.Either upgrade your project to 26 or use a version of flexbox layout that relies on sdk 25, which seems to be v0.2.7:
compile 'com.google.android:flexbox:0.2.7'
这篇关于无法访问ActivityCompatApi23类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!