Android Studio 1.4 渲染问题 注意:此项目包含 Java 编译错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33029558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio 1.4 Rendering Problems NOTE: This project contains Java compilation errors
提问by Ajey
Rendering Problems
NOTE:This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first.
The following classes could not be found:
渲染问题
注意:该项目包含 Java 编译错误,这可能会导致自定义视图的渲染失败。先修复编译问题。
找不到以下类:
-?android.support.design.widget.AppBarLayout (Fix Build Path, Edit XML, Create Class)
-?android.support.design.widget.CoordinatorLayout (Fix Build Path, Edit XML, Create Class)
I am using Android Studio 1.4
我正在使用 Android Studio 1.4
Problems here:
这里的问题:
回答by jyanks
Have you imported the design library into your project? It looks like you're missing a reference in your build.gradle
您是否将设计库导入到您的项目中?看起来你在你的build.gradle
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
回答by Mightian
Check for the following if you have done all of the below then you shouls be able to compile and build your project.
如果您已完成以下所有操作,请检查以下内容,然后您应该能够编译和构建您的项目。
1) Is your Activity extending AppCompactActivity
2) Is your Theme extending Theme.AppCompat.Light or its subclass
3) Have you imported these to your build.gradle
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1 or add them as jar if you are using eclipse
回答by Awesomeness
I also had these issues with the Android Studio designer in 1.4. I uninstalled it and went back to 1.3.2, this version seems to work fine!
我在 1.4 中的 Android Studio 设计器中也遇到了这些问题。我卸载了又回到了1.3.2,这个版本好像还不错!
回答by William
i had this problem and i've looked everywhere for answers and none could help me fix this bug. and my final solution is to reinstall android studio 1.3.2 and it worked just fine.
我遇到了这个问题,我到处寻找答案,但没有人能帮我解决这个错误。我的最终解决方案是重新安装 android studio 1.3.2,它工作得很好。
For Windows: IDE + SDK bundle: https://dl.google.com/dl/android/studio/install/1.3.2.0/android-studio-bundle-141.2178183-windows.exe(1.1 GB)
对于 Windows:IDE + SDK 包:https: //dl.google.com/dl/android/studio/install/1.3.2.0/android-studio-bundle-141.2178183-windows.exe(1.1 GB)
For Mac: DMG: https://dl.google.com/dl/android/studio/install/1.3.2.0/android-studio-ide-141.2178183-mac.dmg(351 MB)
对于 Mac:DMG:https: //dl.google.com/dl/android/studio/install/1.3.2.0/android-studio-ide-141.2178183-mac.dmg(351 MB)
回答by Amit Upadhyay
To use the class ActionBarOverlayLayout
you need to include this in the dependencies section :
要使用该类,ActionBarOverlayLayout
您需要将其包含在依赖项部分中:
compile 'com.android.support:design:24.1.1'
Sync the project once again and then you will find no problem
再次同步项目,然后你会发现没有问题
回答by Md Imran Choudhury
- See which Android SDK Build-toolsversion you Installed from Android SDK Manager.
- Use this version in buildToolsVersioninside build.gradleand remember that targetSdkVersionmust be same.
- After that add this library, Remember that 23.0.1is my downloaded version. I use targetSdkVersion 25and buildToolsVersion "25.0.2".
- 查看您从Android SDK Manager安装的Android SDK Build-tools版本 。
- 使用此版本中buildToolsVersion内的build.gradle和记住targetSdkVersion必须相同。
- 之后添加这个库,记住23.0.1是我下载的版本。我使用targetSdkVersion 25和buildToolsVersion "25.0.2"。
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
编译'com.android.support:appcompat-v7:25.1.0'
编译'com.android.support:design:25.1.0'
Now from File menu Invalidate cached/Restartyou project. And one more thing in XML preview must select your download version.
现在从文件菜单使缓存无效/重新启动您的项目。XML 预览中的另一件事必须选择您的下载版本。
回答by Md Imran Choudhury
if you used sdk 28
如果您使用 sdk 28
compileSdkVersion 28
targetSdkVersion 28
you change it to 27 , that means :
您将其更改为 27 ,这意味着:
compileSdkVersion 27
targetSdkVersion 27
and in dependencies:
并在依赖项中:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
}
.... this way solved my problem! happy code!
....这样解决了我的问题!快乐的代码!
回答by DEVSHK
Well i also face this problem so i Cleanmy project but still the error occur then i close Android Studio. And then again open it. and the error gone. this method solved my problem here is my gradle file
好吧,我也面临这个问题,所以我清理了我的项目,但仍然发生错误,然后我关闭了Android Studio。然后再次打开它。并且错误消失了。这个方法解决了我的问题, 这里是我的 gradle 文件
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.project.apps.myproject"
minSdkVersion 21
targetSdkVersion 28
versionCode 7
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'}