AppCompatActivity library not found with Sdk Version 28 - java

I'm creating a new android project with SDK 28 when project finished to create I have an error in MainActivity.
I tried some methods:
Clean project
Clean Android Studio cache
Clean Gradle cache
Re-installed IDE
File-> Invalidate cache/restart
Remove .idea folder
Restart Android Studio.
Android Studio About:
Android Studio 3.3.2
Build #AI-182.5107.16.33.5314842, built on February 15, 2019
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
build.gradle (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.israteneda.myapplicationtest2"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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'
}
MainActivity.java
package com.israteneda.myapplicationtest2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
The error showed is:
Android resource linking failed
error: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.israteneda.horariu:style/Theme.AppCompat.Light.DarkActionBar) not found.
D:\israt\android_apps\HorariU\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:173: error: style attribute 'attr/colorPrimary (aka com.israteneda.horariu:attr/colorPrimary)' not found.
D:\israt\android_apps\HorariU\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:174: error: style attribute 'attr/colorPrimaryDark (aka com.israteneda.horariu:attr/colorPrimaryDark)' not found.
D:\israt\android_apps\HorariU\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:175: error: style attribute 'attr/colorAccent (aka com.israteneda.horariu:attr/colorAccent)' not found.
error: failed linking references.
When I change the SDK to 27 the MainActivity works.
build.gradle (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.israteneda.horariu"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.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'
}
MainActivity.java
package com.israteneda.myapplicationtest2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Also works with androidx library.
build.gradle (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.israteneda.myapplicationtest"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
MainACtivity.java
package com.israteneda.myapplicationtest;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
I expect to create an android project without problems, but the actual output is an error with AppCompatActivity on MainActivity. Why does this problem happen?

I got the same issue and solved it by updating Android Studio

1.Go to your project directory (or to Project View)
2.Find and open .idea directory
3.Remove caches and libraries directories
4.Invalidate Caches / Restart

The problem was solved by updating the new version of android studio 3.4, without importing the settings of the previus version.

Related

ERROR: Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.1.0

I am trying to create a project in the android studio. But every time i find the following gradle error
ERROR: Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.1.0.
Show Details
Affected Modules: app
I have solved the proxy problem and also unchecked the offline work option. Please help me in this regard.
I have the following dependencies.
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.buraqht"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

ERROR: Failed to resolve: core Affected Modules: app

i updated android studio to version 3.5 and started new project and there is a mistake in gradle files i couldn't understand it what should i do ? i don't understand how gradle files work,
so would someone commanded to me a course or website teeth how is it work ?
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.hibaadil.myapplication897"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

error: package android.support.v7.app does not exist

i'm going to integrate firebase to my android project, but after following the tutorial i found that this error showing up
error: package android.support.v7.app does not exist.
i tried to clean the project,and i checked update in android .
this is my build.gradle [module ]
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.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 'com.google.android.gms:play-services-auth:17.0.0'
}
and this my build.gradle [ project ]
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
please help to solve this problem i spent all this day looking for a solution . thank you
For latest version (3.4 or higher) of Android Studio
Instead of
import android.support.v7.app.AppcompatActivity
Use this
import androidx.appcompat.app.AppcompatActivity
In MainActivity.java or in main java file
I think you should Migrate to AndroidX if you want to use 'com.google.android.gms:play-services-auth:17.0.0' (17.0.0 version) or if you don't want to migrate androdiX use version 16.0.0 implementation 'com.google.android.gms:play-services-auth:16.0.0'
The c in AppcompatActivity must be in uppercase:
import androidx.appcompat.app.AppCompatActivity

Could not find class 'dalvik.system....'

I am running one android application in version 4.4.4 After load application i can't tap any button and in logcat this is an error:
E/dalvikvm: Could not find class 'dalvik.system.DelegateLastClassLoader', referenced from method ab.b
This is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.app.name"
minSdkVersion 14
targetSdkVersion 28
versionCode 105
versionName "1.0.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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.google.android.gms:play-services-ads:17.1.2'
}
In higher android versions everything works fine. Help please )
Reduce your compile sdk version and target version to 26
and change the appcompat-v7
to the following
com.android.support:appcompat-v7:26.0.0-beta1
then check run it.

:app:processDebugResources Error in Android Studio

Not quite sure why I keep getting this error:
errors
After some searching, it seems like the issue is in my build.gradle file but I cannot find it. I've attached the file, but also include the screenshot of my errors in case there is something I am missing.
but that did not changed anything.
Build.gradle file below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.0"
defaultConfig {
applicationId "com.cormac.splashscreen"
minSdkVersion 17
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.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'
}
refer this site
https://github.com/thevarungupta1/Android-Training-2/blob/master/SplashScreen/app/build.gradle
and
you seem forgot
implementation 'com.android.support:support-v4:28.0.0-alpha3'

Categories