After updating support library version 27.1.0 Android Studio unable to render CardView. It shows error message as
failed to find style 'cardView Style' in current theme
But no error in compiling and no difference while seeing on the phone.
I have reverted the support library version to 27.0.2 and it's rendering fine.
The issue with support library or Android studio? How to fix this?
App Level Gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.tmmmt.tmmmt"
minSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
buildConfigField 'String', 'FS_CLIENT_ID', FOURSQUARE_CLIENT_ID
buildConfigField 'String', 'FS_CLIENT_SECRET', FOURSQUARE_CLIENT_SECRET
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
buildConfigField 'String', 'FS_CLIENT_ID', FOURSQUARE_CLIENT_ID
buildConfigField 'String', 'FS_CLIENT_SECRET', FOURSQUARE_CLIENT_SECRET
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "default"
productFlavors {
dev {
dimension "default"
versionNameSuffix "-dev"
buildConfigField 'String', 'BASE_URL', BASE_URL_DEV
manifestPlaceholders = [GEO_API_KEY: GOOGLE_MAP_KEY_DEV]
}
beta {
dimension "default"
versionNameSuffix "-beta"
buildConfigField 'String', 'BASE_URL', BASE_URL_BETA
manifestPlaceholders = [GEO_API_KEY: GOOGLE_MAP_KEY_BETA]
}
live {
dimension "default"
buildConfigField 'String', 'BASE_URL', BASE_URL_LIVE
manifestPlaceholders = [GEO_API_KEY: GOOGLE_MAP_KEY_LIVE]
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "org.jetbrains.anko:anko-common:$anko_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:support-v13:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.google.firebase:firebase-messaging:$play_version"
implementation "com.google.android.gms:play-services-maps:$play_version"
implementation "com.google.android.gms:play-services-location:$play_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.tmmmt.library:arrowtab:1.3'
implementation 'com.github.stfalcon:chatkit:0.2.2'
implementation 'com.amazonaws:aws-android-sdk-core:2.6.16'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.6.16'
implementation 'com.amazonaws:aws-android-sdk-s3:2.6.16'
implementation 'com.orhanobut:logger:2.1.1'
implementation 'com.tmmmt.library:animations:0.6'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
compile('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'
}
/*Fort*/
implementation project(':FortSDKv1.4.1')
implementation 'com.victor:lib:1.0.1'
implementation 'com.shamanland:fonticon:0.1.8'
implementation('com.nispok:snackbar:2.11.0') {
exclude group: 'com.google.android', module: 'support-v4'
}
implementation 'com.google.guava:guava:23.0-android'
implementation 'org.bouncycastle:bcprov-jdk16:1.46'
implementation 'commons-codec:commons-codec:1.10'
/*Fort*/
}
apply plugin: 'com.google.gms.google-services'
Project Level Gradle:
buildscript {
ext.kotlin_version = '1.2.30'
ext.anko_version = '0.10.1'
ext.support_version = '27.1.0'
ext.play_version = '11.8.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:4.3.2"
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://mymavenrepo.com/repo/eDGOo6Dqr4f6uNA0HoWX/"
credentials {
username = 'myMavenRepo'
password = 'tmmmt123'
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Update:
There is no such error from Android Studio 3.2. The error was gone completely.
Checking the source of CardView one can see that the constructor
public CardView(#NonNull Context context, #Nullable AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs, 0);
}
has been changed to
public CardView(#NonNull Context context, #Nullable AttributeSet attrs) {
this(context, attrs, R.attr.cardViewStyle);
}
And the new attribute cardViewStyle is defined in the library. I guess that the Android Studio preview is not including the value for this attribute from the library, for some reason. I'm not sure if it usually resolves custom attributes defined in libraries and this is a bug, or if this is intended.
Workaround 1
Resolve the attribute in your theme (maybe only in debug version), this way the error is gone. #style/CardView is already defined in the support library so you don't need to create the style, just reference it.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="cardViewStyle">#style/CardView</item>
</style>
Be sure to use AppTheme in the layout preview and clean build.
Workaround 2
Add the style with tools namespace so that it won't affect your production code. The rendering error will be logged, but you will see the CardView anyway
<android.support.v7.widget.CardView
tools:style="#style/CardView"
...
Good news
Android Studio 3.1 seems to be handling this correctly, no workaround needed (the error in the layout preview is still logged though).
On Android Studio 3.2 (currently in Canary channel) the error is gone.
I also had the same problem, so I added
<item name="cardViewStyle">#style/CardView</item>
in my styles.xml file. But it was showing a warning "The resource #style/CardView is marked as private in com.android.support:design".
So, after that I tried this one
<item name="cardViewStyle">#style/CardView.Light</item>
and this worked for me. I am using Android Studio 3.1.4 and Gradle 4.4.
updating the CardView from 27.1.1 to 28.0.0-alpha3 fixed the XML preview for me on AS 3.1.3.
implementation "com.android.support:cardview-v7:28.0.0-alpha3"
it still complains, but it renders the preview.
there's also a new androidx class now, which should be the same:
implementation "androidx.cardview:cardview:1.0.0"
when updating com.android.support:design to 28.0.0-alpha3, it hints for:
The resource #style/CardView is marked as private in com.android.support:design
downgrading back to API 27 with buildTools 27.0.3 & supportLibrary 27.1.1 also prevents the issues. might upgrade to 28.0.0 with Android Studio 3.2 then.
In my case the reason of the error with CardView was because of the wrong listheader attribute of a child Spinner. Alongside the failed to find style 'cardView Style' in current theme error message I got Spinner adapter view type count must be 1, so the roots of the CardView failing were surprisingly in Spinner rendering failure.
Related
So I use SwitchMaterial in one layout:
<com.google.android.material.switchmaterial.SwitchMaterial...
And Firebase Crashlytics spams me with the following errors for many users
Fatal Exception: java.lang.RuntimeException Unable to start activity
ComponentInfo{...}: android.view.InflateException: Binary XML file
line #324: Binary XML file line #324: Error inflating class
com.google.android.material.switchmaterial.SwitchMaterial
Caused by android.content.res.Resources$NotFoundException File
res/drawable/abc_switch_thumb_material.xml from drawable resource ID
#0x7f080047
App theme:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">...
Material dep:
implementation "com.google.android.material:material:1.6.1"
What does it mean?
Update
I tried to use Switch from AndroidX AppCompat library instead and still the same issue with drawable:
Fatal Exception: java.lang.RuntimeException Unable to start activity ComponentInfo{****.ui.MainActivity}: android.view.InflateException: Binary XML file line #324: Binary XML file line #324: Error inflating class androidx.appcompat.widget.SwitchCompat
Caused by android.content.res.Resources$NotFoundException Drawable ***:drawable/abc_switch_thumb_material with resource ID #0x7f080047
This is so weird, it works fine for my smartphones though but it's effected 22 my users already
Yes, I have both the following options enabled for release builds
minifyEnabled true
shrinkResources true
But it worked fine all the time for different apps and I never had to add anything to a proguard file to keep drawable of some third party libraries (especially Google libraries) - abc_switch_thumb_material
Update 2
I just tried to download APK generated by Google Play Console from my AAB file
I checked apk\res\drawable\ and found that drawable is available
This is magic...
But this generated APK is universal and Google Play Consoles generates different APK based on type of device and its Android version, so what happens in this case I don't know
Update 3
I will try to use just Switch even if Android Studio shows the following warning:
Use SwitchCompat from AppCompat or SwitchMaterial from Material
library
But at least I hope my app will stop getting crashed for some users because of it
p.s. devices for which the error happens (Firebase Crashlytics):
My build.gradle files of that app (if it's helpful in anyway and mb there are some conflicts between libraries)
Project build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
kotlin_version = "1.7.10"
nav_version = "2.5.1"
hilt_version = "2.43.2"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.gms:google-services:4.3.13"
classpath "com.google.firebase:firebase-crashlytics-gradle:2.9.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" // for DataStore
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App module build.gradle:
plugins {
id "com.android.application"
id "kotlin-android"
id "kotlin-kapt"
id "com.google.gms.google-services"
id "com.google.firebase.crashlytics"
id "kotlin-parcelize"
id "dagger.hilt.android.plugin"
id "androidx.navigation.safeargs.kotlin"
id "kotlinx-serialization" // for DataStore
}
android {
compileSdkVersion 32
defaultConfig {
applicationId ***
minSdkVersion 21
targetSdkVersion 32
multiDexEnabled true
versionCode 18
versionName "1.0.15"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
manifestPlaceholders = [crashlyticsEnabled: false]
signingConfig signingConfigs.release
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
manifestPlaceholders = [crashlyticsEnabled: true]
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
}
buildFeatures {
dataBinding = true
}
}
dependencies {
implementation "androidx.core:core-ktx:1.8.0"
implementation "androidx.appcompat:appcompat:1.5.0"
implementation "androidx.activity:activity-ktx:1.5.1"
implementation "androidx.fragment:fragment-ktx:1.5.2"
implementation "androidx.multidex:multidex:2.0.1"
implementation "com.google.android.material:material:1.6.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "com.jakewharton.timber:timber:5.0.1"
implementation platform("com.google.firebase:firebase-bom:30.3.2")
implementation "com.google.firebase:firebase-analytics"
implementation "com.google.firebase:firebase-crashlytics"
implementation "com.google.firebase:firebase-ads:21.1.0"
implementation "com.google.android.ump:user-messaging-platform:2.0.0"
implementation "com.android.billingclient:billing-ktx:5.0.0"
def lifecycle_version = "2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
// Hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
// OkHttp
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.0"))
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")
// Retrofit
def retrofit = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit"
implementation "com.squareup.retrofit2:converter-gson:$retrofit"
// Glide
def glide_version = "4.13.2"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
// Pagination
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
// Datastore
implementation "androidx.datastore:datastore:1.0.0"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.4.0"
implementation "org.jsoup:jsoup:1.15.2"
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
}
the crashes stopped when i switched to using <Switch>
both <SwitchCompat> and <SwitchMaterial> caused crashes in production
I'm trying to compile an Android app and the Gradle build is failing. The project is in Java but does have Room code as well, which I believe is where the issue is arising from. The build is unable to find the Guava repository at www.google.com:guava:23.6-Android even though this file has been added as a dependency.
The initial result build fail looks like this:
Could not find com.google.guava:guava:23.6-android.
Required by:
project :App
The project-level build file:
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The app level build file contains the following:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.nathan.digipizza"
minSdkVersion 19
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
dataBinding true
}
}
dependencies {
implementation 'com.google.guava:guava:26.3-android'
def room_version = "2.3.0"
implementation 'androidx.appcompat:appcompat:1.4.0-rc01'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.5.0-alpha05'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-compiler:2.4.0'
implementation 'androidx.room:room-runtime:2.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
annotationProcessor 'androidx.room:room-compiler:2.3.0'
}
It is difficult to post the entire dependency tree since I'm still unable to post screen images. But the repository in question, com.google.guava:guava:23.6-android, is not listed as a dependency for any other files, and its entry in the tree for the release variant reflects this fact as it is situated furthest left on the tree as follows:
+--- com.google.guava:guava:23.6-android FAILED
This repository only appears once in the dependency tree, furthermost to the left.
The com.google.guava:guava:23.6-android repository has an updated version to 30.1-android. I did update the version, but the error remains and everything is the same as above except version 30.1-android replaces version 23.6-android.
I need to figure out how to resolve the build error, which I'll post here again for ease of use:
Could not find com.google.guava:guava:23.6-android.
Required by:
project :app
I don't understand how the build is failing to see this repository when it has been added as a dependency, and there doesn't appear to be any complications apparent by analyzing the dependency tree.
I am beginner to android development. When I build my android project, it is throwing an error
INFO: API 'variantOutput.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getPackageLibrary(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
Affected Modules: capacitor-android
I tried the solutions suggested in other topic at implementation 'com.android.support:appcompat-v7:28.0.0'
Can anyone help me please? Thank you for your time!
My build.gradle(capacitor-android) file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.novoda:bintray-release:0.9.1'
}
}
tasks.withType(Javadoc).all { enabled = false }
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
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'
}
}
lintOptions {
abortOnError false
}
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
//implementation 'com.android.support:appcompat-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
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 'org.apache.cordova:framework:7.0.0'
}
def version = System.getenv("BINTRAY_PKG_VERSION")
publish {
userOrg = 'ionic-team'
repoName = 'capacitor'
groupId = 'ionic-team'
artifactId = 'capacitor-android'
if (version != null) {
publishVersion = System.getenv("BINTRAY_PKG_VERSION")
} else {
publishVersion = '0.0.0'
}
desc = 'Capacitor Android Runtime'
website = 'https://github.com/ionic-team/capacitor'
}
Best of luck with this platform.
This is not a direct solution, just a small piece of advise. But from now, please do not use the support library. Recently, Google has been introduced Android JetPack. The current stable version of Android Studio 3.6.1, you will be introduced to AndroidX by default and Google is highly recommended to use it.
AndroidX - Android Extension Library: From AndroidX documentation
You can also migrate from support Android to AndroidX. Just follow this step: Android Studio > Refactor Menu > Migrate to AndroidX. It is independent of the Android SDK version.
From Android Support Revision 28.0.0, you can see that this version will be the last feature release under the android.support packaging and developers are encouraged to migrate to AndroidX 1.0.0. You may face trouble getting support or a solution if you use the support library. So, it will be wise to use AndroidX.
Replace 'variantOutput.getPackageLibrary()' with 'variant.getPackageLibraryProvider()' in your code. It may works.
Option 1:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
instead of
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:appcompat-v4:28.0.0'
Option 2:
Migrate your project to AndroidX
In my Android project, I have needed to enable the dataBinding library in module level build.gradle as below, but it gives me the error in the image. How can resolve it?
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "com.nasser.studio.multipledeletelistview"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding{
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.codesgood:justifiedtextview:1.0.2'
}
Edit 1.
I've changed the project level build.gradle to add support-v4 library, but now it throws the following error:
repositories {
google()
jcenter()
configurations.all {
resolutionStrategy.force "com.android.support:support-v4:27.0.2"
}
}
one of your 3rd party libraries or sdk you use rely on support version 21.0.3. Either remove it or have resolutionStrategy in your Gradle.
configurations.all {
resolutionStrategy {
force ....
}
}
Try upgrade your android gradle plugin.
Add compile "com.android.support:support-v4:27.0.2" manually to your gradle file.
That should solve your problem.
That's not a Databinding error, It's just saying that all your support-related libraries should use the same version. For example look at my gradle file:
implementation "com.android.support:recyclerview-v7:$libraries.googleSupportVersion"
implementation "com.android.support:appcompat-v7:$libraries.googleSupportVersion"
implementation "com.android.support:support-v13:$libraries.googleSupportVersion"
implementation "com.android.support:design:$libraries.googleSupportVersion"
implementation "com.android.support:cardview-v7:$libraries.googleSupportVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
My support library version being:
ext.libraries = [
...
googleSupportVersion : '27.1.1',
...
]
Your issue seems to be that compile 'com.codesgood:justifiedtextview:1.0.2' internally is using the support library with a version different than yours. However your version is totally updated I wouldn't downgrade it just to have it match with the other, in any case you could just add a:
allprojects {
configurations.all {
resolutionStrategy.force "com.android.support:support-v4:27.0.2"
}
}
In your project gradle. You could also run gradlew app:dependencies in the Android Studio console, do a Ctrl+F on the output, search for that com.android.support:support-v4:27.0.2 and figure out from where is coming. (You only have one dependency for what I see, so there's not much science from where IT should be coming)
Let me know if this works for you.
I tried looking other similar questions on stackoverflow, they advice us to changw version of "buildToolsVersion" but I dont see word like that in my gradle file.
My Gradle File (PROJECT):-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// 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
}
My build.gradle (Module:app): This the my second gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.dhruv.testhello"
minSdkVersion 15
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-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
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'
}
I had the same problem. I searched so much and I finally found that appcompat-v7:28.0.0-alpha3 has some bug with "Design View" part of Android Studio.
So I suggest to change com.android.support:appcompat-v7:28.0.0-alpha3 to com.android.support:appcompat-v7:28.0.0-alpha1 version and then click File -> Invalidate Caches / Restart. Volla everything is OK.
Of course you should have internet access to download com.android.support:appcompat-v7:28.0.0-alpha1
I was helped by Hossein Seifi's reply but with a change
implementation 'com.android.support:design:28.0.0-alpha3'
to
implementation 'com.android.support:design:28.0.0-alpha1'
and click File -> Invalidate Caches / Restart
Update 2
As you can see in support 28.0.0 release notes.
This will be the last feature release under the android.support
packaging, and developers are encouraged to migrate to AndroidX 1.0.0
Android will not update support libraries from now. So I suggest you migrate to androidx before they deprecated support libraries.
Update
Support 28.0.0 is released, so you can use this stable version.
implementation 'com.android.support:design:28.0.0'
I suggest never use alpha versions, because alpha, beta versions have bugs, that are testing libraries.
module app gradle file looks like this...In your file you are missing buildToolsVersion, adding this may help you
apply plugin: 'com.android.application'
android {
//changes
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.example.dhruv.testhello"
minSdkVersion 24
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(dir: 'libs', include: ['*.jar'])
//changes
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
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'
}
In styles.xml,
Changing the theme from Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar has worked for me.
yes its work,
implementation 'com.android.support:design:28.0.0-alpha3'
to
implementation 'com.android.support:design:28.0.0-alpha1'
After that got to File and click -> Invalidate Caches / Restart
At the time of this answer Android Studio 3.1.4 is out with Android Support 28.0.0 Release Candidate(Potential Final, Beta) so please update.
Well, here is a config that will certainly work for you.
targetSdkVersion 28
com.android.support:*:28.0.0-rc01
Where * is the resource type.
Open, res>values>styles.xml, here you will find a line:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
replace the line with:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
That means: Add the word "Base." starting the name of the parent theme.
Open, res --> values --> styles.xml, here you will find a line like this:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
change it to:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
In otherwords, change DarkActionBar to NoActionBar