gpt4 book ai didi

Android Studio 3.2.1 : Layout preview not working for all projects, 加载旧项目后

转载 作者:行者123 更新时间:2023-12-02 06:17:43 29 4
gpt4 key购买 nike

我需要查看一个旧项目,该项目需要我下载构建工具版本 23.0.0 来获取一些代码,然后我将其加载到更新的 android studio 中。

现在,布局文件不会在我设计的任何工作项目上或在加载旧项目之前在新项目上显示任何预览以下是我在启动新项目时遇到的错误:

NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts.

还有

The following classes could not be found:
- ProjectState (Fix Build Path, Edit XML) - component (Fix Build Path, Edit XML) - config (Fix Build Path, Edit XML) - configuration (Fix Build Path, Edit XML) - configurations (Fix Build Path, Edit XML) - device (Fix Build Path, Edit XML) - entry (Fix Build Path, Edit XML) - expand (Fix Build Path, Edit XML) - file (Fix Build Path, Edit XML) - item (Fix Build Path, Edit XML) - leaf (Fix Build Path, Edit XML) - list (Fix Build Path, Edit XML) - option (Fix Build Path, Edit XML) - path (Fix Build Path, Edit XML) - project (Fix Build Path, Edit XML) - projectState (Fix Build Path, Edit XML) - projects_view (Fix Build Path, Edit XML) - select (Fix Build Path, Edit XML) - shared (Fix Build Path, Edit XML) - state (Fix Build Path, Edit XML) - system (Fix Build Path, Edit XML) - tree_state (Fix Build Path, Edit XML) Tip: Try to build the project. Tip: Try to refresh the layout.

Render Problem: Failed to load AppCompat ActionBar with unknown error

还有

Failed to instantiate one or more classes
The following classes could not be instantiated: - android.support.v7.app.WindowDecorActionBar (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.

Image shows MainActivity as Unresolved class in tool:context=".MainActivity"

我尝试解决此问题的方法:

  1. Invalidate cache and restart
  2. Clean and Rebuild project
  3. Change sdk version from 28.0.0 to 27.1.1 (I've been working on a project with sdk 28.0.0 earlier without any issue before loading that old project)
  4. Reinstalled entire android studio, deleting caches except sdk
  5. Force refresh layout
  6. Set build-tools version in settings to 28.0.3

build.gradle(模块:应用程序):

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "<Name Removed>"
minSdkVersion 28
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}

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'
}

build.gradle(项目:项目名称)

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

合并 list

Manifest Sources 

app main manifest (this file)
Other Manifest Files (Included in merge, but did not contribute any elements) animated-vector- drawable:28.0.0 manifest, appcompat-v7:28.0.0 manifest, support:asynclayoutinflater:28.0.0 manifest, constraint-layout:1.1.3 manifest, support:coordinatorlayout:28.0.0 manifest, support:cursoradapter:28.0.0 manifest, support:customview:28.0.0 manifest, support:documentfile:28.0.0 manifest, support:drawerlayout:28.0.0 manifest, support:interpolator:28.0.0 manifest, lifecycle:livedata:1.1.1 manifest, livedata-core:1.1.1 manifest, support:loader:28.0.0 manifest, support:localbroadcastmanager:28.0.0 manifest, support:print:28.0.0 manifest, core:runtime:1.1.1 manifest, lifecycle:runtime:1.1.1 manifest, support:slidingpanelayout:28.0.0 manifest, support- compat:28.0.0 manifest, support-core-ui:28.0.0 manifest, support-core-utils:28.0.0 manifest, support- fragment:28.0.0 manifest, support-vector- drawable:28.0.0 manifest, support:swiperefreshlayout:28.0.0 manifest, support:versionedparcelable:28.0.0 manifest, lifecycle:viewmodel:1.1.1 manifest, support:viewpager:28.0.0 manifest

最佳答案

我在 Android Studio 3.2.1 中遇到了类似的情况。项目构建成功,没有问题,但我的布局预览 View 上没有显示任何内容。尝试清理/重建、无效缓存/重新启动、关闭/打开项目、强制刷新布局、将项目与 gradle 文件同步。唯一帮助我恢复布局设计预览的是删除 .AndroidStudio3.2\system 中的 caches 文件夹。

关于Android Studio 3.2.1 : Layout preview not working for all projects, 加载旧项目后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53292346/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com