我是android studio的新手,由于错误无缘无故地正面临着大多数问题。我试图创建一个空的Drawer活动,但是没有显示任何组件,但是Designer上显示了布局名称。
我遇到渲染错误,而且即使我没有更改单个单词也无法启动类错误。
我尝试了一些关于堆栈溢出的解决方案,但没有一个起作用。
错误
The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show
Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (Open Class, Show Exception,
Clear Cache)
- android.support.design.widget.FloatingActionButton (Open Class, Show
Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample
data when shown in the IDE. If this is an unexpected error you can also try
to build the project, then manually refresh the layout. Exception Details
java.lang.ClassNotFoundException:
android.view.View$OnUnhandledKeyEventListener Copy stack to clipboard
答案 0 :(得分:0)
在Google搜索大约三到四天后,终于找到了解决方法。
我将SDK版本从28更改为26,并在build.gradle文件中将28替换为26,并且可以正常工作。最后。
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.itnoa.asdf"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:26.0.0-alpha3'
implementation 'com.android.support:support-v4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
我希望这对其他人有帮助:-)