为什么 Android Studio 3.1.4 会出现渲染问题?
Why there is a Render Problem in Android Studio 3.1.4?
自从 google 在 com.android.support:appcompat-v7:28.0.0-alpha1
之后推出的新存储库以来,在布局的正确预览方面都无法正常工作。
我被迫使用 com.android.support:appcompat-v7:28.0.0-alpha1
即 alpha1
尽管有新的存储库可用,例如
28.0.0-rc02
28.0.0-rc01
28.0.0-beta01
28.0.0-alpha3
每当我尝试使用上述任何一种时,我都会收到以下错误:
此外,我已经尝试过更改布局,但 none 似乎可行。
这是我的 gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.rish.myapplication"
minSdkVersion 19
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
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'
}
AndroidStudio 中的任何其他功能都没有受到影响(据我所知),因为编译后的应用程序仍然可以正常运行,但没有预览就很难工作。
我知道类似的问题已经存在了,但是 none 除了更改存储库版本之外,这些问题中的一些是有意义的。
我想知道这是我电脑的问题还是与 google 开发人员有关?
看起来 api 28 中有一些错误,尝试将其减少到 api 27。
让你的 compileSdkVersion 为 27
compileSdkVersion 27
并且你的 targetSdkVersion 为 27
targetSdkVersion 27
还有
implementation 'com.android.support:appcompat-v7:27.1.1'
完整代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.rish.myapplication"
minSdkVersion 19
targetSdkVersion 27
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(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
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'
}
对我来说很好用
否则将您的主题更改为点亮它也适用于我。
我把风格改成了Theme.AppCompat.Light.DarkActionBar
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
您可以尝试任何 Theme.AppCompat.Light 样式都可以正常工作
也不要忘记从 xml 布局文件和清单文件更改您的主题,然后渲染问题就会消失。
有同样的问题,通过改变值解决了
R.values.styles.xml.
<style name="AppTheme"
parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!--customize your theme here-->
</style>
我通过下载我的应用程序使用的所有 SDK 版本解决了这个问题,结果发现版本 28 没有完全安装!
截至目前,问题已解决。使用 com.android.support:appcompat-v7:28.0.0
(这是稳定的,现在被 Android Studio 使用)而不是 com.android.support:appcompat-v7:28.0.0-XXXX
(XXXX
是 rc
或 beta
)解决问题
自从 google 在 com.android.support:appcompat-v7:28.0.0-alpha1
之后推出的新存储库以来,在布局的正确预览方面都无法正常工作。
我被迫使用 com.android.support:appcompat-v7:28.0.0-alpha1
即 alpha1
尽管有新的存储库可用,例如
28.0.0-rc02
28.0.0-rc01
28.0.0-beta01
28.0.0-alpha3
每当我尝试使用上述任何一种时,我都会收到以下错误:
此外,我已经尝试过更改布局,但 none 似乎可行。 这是我的 gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.rish.myapplication"
minSdkVersion 19
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
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'
}
AndroidStudio 中的任何其他功能都没有受到影响(据我所知),因为编译后的应用程序仍然可以正常运行,但没有预览就很难工作。
我知道类似的问题已经存在了,但是 none 除了更改存储库版本之外,这些问题中的一些是有意义的。 我想知道这是我电脑的问题还是与 google 开发人员有关?
看起来 api 28 中有一些错误,尝试将其减少到 api 27。 让你的 compileSdkVersion 为 27
compileSdkVersion 27
并且你的 targetSdkVersion 为 27
targetSdkVersion 27
还有
implementation 'com.android.support:appcompat-v7:27.1.1'
完整代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.rish.myapplication"
minSdkVersion 19
targetSdkVersion 27
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(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
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'
}
对我来说很好用
否则将您的主题更改为点亮它也适用于我。
我把风格改成了Theme.AppCompat.Light.DarkActionBar
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
您可以尝试任何 Theme.AppCompat.Light 样式都可以正常工作 也不要忘记从 xml 布局文件和清单文件更改您的主题,然后渲染问题就会消失。
有同样的问题,通过改变值解决了 R.values.styles.xml.
<style name="AppTheme"
parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!--customize your theme here-->
</style>
我通过下载我的应用程序使用的所有 SDK 版本解决了这个问题,结果发现版本 28 没有完全安装!
截至目前,问题已解决。使用 com.android.support:appcompat-v7:28.0.0
(这是稳定的,现在被 Android Studio 使用)而不是 com.android.support:appcompat-v7:28.0.0-XXXX
(XXXX
是 rc
或 beta
)解决问题