Can not resolve symbol annotation design ActivityCompat v7 - java

I am working on a face recognition app using google API. But android studio says symbol not found.
Here is my activity. All four of them don't work.
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
My build.gradle(module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "ece.course.myapplication"
minSdkVersion 19
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion "28.0.3"
productFlavors{
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-v4: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:12.0.1'
implementation 'com.android.support:design:28.0.0'
//implementation 'com.android.support:support-annotations:28.0.0'
//compile 'com.android.support:support-v4:24.2.0'
//compile 'com.android.support:design:24.2.0'
//compile 'com.google.android.gms:play-services-vision:9.4.0+'
}
My build.gradle(project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
//classpath 'com.android.tools.build:gradle:2.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I am new to android and confused. I cleaned the project and rebuild it several times. Invalidate cache and restart several times.

Yes Because you have to migrate your project into the androidx.
You are using compileSdkVersion 28
Steps to migrate
Add the following properties to gradle.properties
android.useAndroidX=true
android.enableJetifier=true
From the menu bar: Refactor > Migrate to AndroidX…
Here is the reference for whole process.

You need to Migrate your project to androidx
Refactor > Migrate to Androidx
Another thing to remember is to check all your packages are correct in gradle. The Snackbar package for androidx is:
com.google.android.material.snackbar.Snackbar
Answered here:
Snackbar package in AndroidX
For Androidx artifact mapping. Take a look at the Android Developer API here:
https://developer.android.com/jetpack/androidx/migrate/artifact-mappings
Sample:
Artifact Mapping Sample

Thanks everyone for the answers.
As it turns out, during project setup time I used the "basic activity" as a template for fast setup. But I later realized in the "basic activity" in newer version of Android Studio uses AndroidX instead of Android Suppor library. And all my code is based on the legacy android library.
In the file gradle.properties file(located in the base directory of your project same as gradlew), change
android.useAndroidX=true
android.enableJetifier=true
to
android.useAndroidX=false
android.enableJetifier=false
If you have all the dependency right and rebuild and cleared cache several times, still the android support library doesn't work. And if you have a newer version of android studio. It's possible that gradle.properties are wrong.

Related

Ksoap2 Library to android studio Error message, how to fix?

I an trying to import Ksoap2 library in android studio using .jar file version 3.6.4. I have successfully implemented the jar file to android studio. However, on the module app activity when I try to import e.g. import "org.ksoap2.SoapEnvelope;", it gets and error it shows following results:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.google.code.ksoap2-android:ksoap2-android:3.6.4.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
- https://dl.google.com/dl/android/maven2/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
- https://jcenter.bintray.com/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
Required by:
project :app
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Also the imports library have error, please see the pic:
Here is the Build.gradle module code:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is Build.gradle(app) Module code:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.kowloondairycompanykdl.milk_ic"
minSdkVersion 27
targetSdkVersion 30
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation files('libs\\ksoap2-android-assembly-3.6.4.jar')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.4'
}
Please help me, I been stuck here for a long time. How to fix the error and how can I implement the Ksoap2 library properly. Thanks
There doesn't seem to be a 3.4.3 version of that library. There's a 3.4.0. And the newest is 3.6.4. You're going to need to use one of those. I'd move to 3.6.4 as 3.4.0 is over 5 years old, and likely lacks security updates.
Remove the dependencyResolutionManagement block from the setting.gradle file to have your project work the old way.
Related issue: Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'

get Instance() method is not being accepted in android studio to fetch firebase data

I am creating an app based on firebase database. I have followed all steps shown on google. Everything working well except red Ink on getInstace () and getReference() method.
private DatabaseReference rfr;
// code to fetch it
rfr = FirebaseDatabase.getInstance().getReference().child("Progress");//in this line//
.orderByChild("rollnum")
.equalTo(301);
I cant guess where is the error. Please help me.
I have rechecked everything .I could not find any error. Do we have to create helper class like sqlite?
Here are my build gradle files:-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.4'
// 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
}
and app level build gradle:-
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example_my pakage name"
minSdkVersion 19
targetSdkVersion 29
versionCode 3
versionName "1.2"
multiDexEnabled true
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.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.firebase:firebase-database:19.5.1'
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth'
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
implementation 'com.android.support:multidex:1.0.3'
}
I am not really sure why it is not working. I have actually tried also making a project using Firebase in Android Studio, and it has worked pretty well for me.
One thing I would check is that all of your import statements are correct:
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
Also, make sure that you include whatever keys are necessary in the app-level gradle files. You need to be sure that the dependencies are correctly installed in the project and also that you imported them in the scripts. Other than that, based on the code that you sent, I do not see a reason why it doesn't work.
mDatabase = FirebaseDatabase.getInstance().getReference("Message");
This is the exact code that I used in my project and it seemed to work just fine. Based on the code you send, I do not really see an issue. The only suggestion I have is to double check your imports and gradle files.

aapt2 3.5.0-5435860 windows gradle error on Android Studio

I am having some issue with my android studio, I recently updated my android studio to version 3.5 and since then I having been encountering with Gradle build error.
I even went ahead and created a new project with no code and an empty activity, when sync it compile without any issue. but upon launching it on my virtual device emulator, it brings this Gradle error
C:\Users.gradle\caches\transforms-2\files-2.1\995db56542b8715d4dfc10fddfcc653d\aapt2-3.5.0-5435860-windows
Config file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
// 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
}
App's config:
[apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.loyalteams.application"
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:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}][1]
I was able to fix it, it was due to paint virus that was on my pc, so during Gradle runtime and build, the hijack any exe file resulting in Gradle cache build error.
As the sole aim of this malware was to affect any runnable exe file on one's desktop and at the same time reduce the size to some kb.
What I did to fix the issue was to install Malwarebytes and Rkill to fix the issue.
I hope this helps some of us being face with the same issue.
In the main configuration file build.gradle compare what lines you have for example I have these:
What was missing is that of google() in the allprojects;
==========================================================
The gradle-wrapper.properties configuration file should look like this:
Finally I found,
I try change versions and more (taked one day from me)
Do those steps:
Remove .gradle directories
Remove all *.iml files
Remove .idea files
Reopen project
Remove intellij system directory (it is contains caches)
Everyhitg work fine ;)

Android 3.3.0 update, ERROR: Cause: invalid type code: 68

After the new update of Android Studio (3.3.0) I'm getting error from Gradle sync saying "ERROR: Cause: invalid type code: 68". Even in project, that have been created before the update and hasn't changed at all.
I've tried to reinstall Android Studio, which hasn't helped either, so there has to be something incompatible with my project, but it doesn't say what and why.
App gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "cz.cubeit.cubeit"
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-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:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
Project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
ext.anko_version='0.10.7'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
I had the same problem. I was working on a project on two PCs: one at my office and one at home. In my office, after the AS 3.3 update, everything was fine but at home, after the same steps that I did at the office, the Error code 68 came out.
After a couple of hours, I figured out how to solve it.
Android Studio 3.3 has the " Only sync the active variant" option enabled by default in Settings>Experimental. Disabling this feature resolved the problem. But reactivating the feature the same error shows up, even after a successful Gradle sync. So I think this isn't a complete solution, but at least now I can work.
I had the same issu with IntelliJ 2019.1, Untick this option works for me.
Alter path JDK location to .....\Android Studio\jre
I got a similar message ("invalid type code: E5") and resolved it by first building from the command line, which revealed it was a Firebase libs version conflict, and then switching to use firebase-bom instead of manually specifying each version.
I had the same error (6C) during a LinkedIn Learning course, I managed to solve it through the following steps
Updating Kotlin in project-level build.gradle file
Update gradle build version in project-level build.gradle file.
Open Project Structure and using the Suggestions tab, update all modules to the latest version.
Update the compileSdkVersion & targetSdkVersion to latest.

Google material design library error Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy

Whenever i add implemntation 'com.google.android.material:material:1.0.0-alpha1' when i try to build my project Android Studio says:
Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
Message{kind=ERROR, text=Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy, sources=[Unknown source file], tool name=Optional.of(D8)}
This is my gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "it.smart.bab3"
minSdkVersion 21
targetSdkVersion 'p'
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-alpha1'
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
}
I'm new ith this type of errors, and i didn't find anithing with this error. Thanks
I've been struggling all day with this issue too. Finally I managed to compile and run the project successfully.
First of all, get rid of this:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
Add the following in your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = false
And finally, sync the project and then compile.
If it doesn't work, clean the project and then rebuild.
PS: I can't get targetSdkVersion 'p' to work. My build.gradle file end up as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.github.alvarosct02.demo"
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.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
}
Hope it works for you too.
I wasted 2 days looking for a solution. Anyone who's still looking for a solution can follow the steps below:
Update your Android Studio to the latest version.
Update your compileSdkVersion and targetSdkVersion to 28.
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.your.appid"
minSdkVersion 19
targetSdkVersion 28
versionCode 50
versionName "1.50"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
setProperty("archivesBaseName", "your-app-$versionName")
resConfigs "en"
}
}
Go to your project structure and change your gradle version to 4.10.
Add this dependency first:
implementation 'com.google.android.material:material:1.0.0'
Now remove all the support library dependencies:
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
androidTestImplementation('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
})
Now paste the following into your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = true
In your project level build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0'
};
For those who are using Butterknife add below lines in your project level build.gradle file:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
And in your module build.gradle file add below dependencies:
implementation "com.jakewharton:butterknife:9.0.0-SNAPSHOT"
annotationProcessor "com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT"
Now Goto Build > Rebuild Project then you might be getting a lot of errors.
Now refer this link.
It has the list of all the old (android.support) vs new (androidx.*) dependencies.
Replace all your old imports with the new ones(Use replaceAll feature of android studio [ctrl + shift + R] which will save you some time).
Finally After refactoring all the old libraries with the new ones:Rebuild the project again and hopefully it should work.
Note: You can also use Refactor > Migrate to androidx in android studio but it didn't work for me.
I started getting this error after upgrading the ButterKnife to the version 8.8.1.
So, I run the command gradle -q dependencies to generate a dependency report, after that you should see where D8 is coming from. In my case from the "ButterKnife" library:
+--- com.jakewharton:butterknife:8.8.1
| | \--- com.android.support:support-compat:d8
Also you can see your android dependencies by going to your Android Studio Gradle view (In Android Studio tool bar navigate to "View/Tool Windows/Gradle"), and selecting the target "androidDependencies" under "My-Project-Name/Tasks/android" (Double click to run or Right click and run).
To solve this problem I added this piece of code exclude module: 'support-compat' to my "app/build.gradle" as below:
implementation ('com.jakewharton:butterknife:8.8.1') {
exclude module: 'support-compat'
}
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
Hope it works for someone else :] Cheers!
Android Studio v3.2+ resolves this issue. It also adds a "Migrate to AndroidX" item under the Refactor menu. No work-around or rollback required.
Update Android Studio from the beta channel to use 3.2+ or wait until a stable version is released.
EDIT: Android Studio v3.2 is now in the stable channel. It is important you no longer use the support libraries and migrate to AndroidX libraries because support for the old support libraries has ended.
If you are including a library that has a transitive dependency on the Android support library you also have to use the jetifier feature that is part of the Android Gradle plugin version 3.2.0-alpha14 or higher. You can determine if you have a library that depends on the support library by running your Gradle dependencies task.
From the Android Developer's blog post (https://android-developers.googleblog.com/2018/05/hello-world-androidx.html):
If you depend on a library that references the older Support Library,
Android Studio will update that library to reference androidx instead
via dependency translation. Dependency translation is automatically
applied by the Android Gradle Plugin 3.2.0-alpha14, which rewrites
bytecode and resources of JAR and AAR dependencies (and transitive
dependencies) to reference the new androidx-packaged classes and
artifacts. We will also provide a standalone translation tool as a
JAR.
In your gradle.properties file make sure that you have:
android.enableJetifier=true
android.useAndroidX=true
I had this issue with Leak Canary on a small project and it was solved by upgrading the Android Gradle plugin to the appropriate version. https://github.com/square/leakcanary/issues/1103
Go to app/build.gradle, in dependencies, remove this line:
implementation "com.android.support:appcompat-v7
Try to add
android.enableD8 = false
to gradle.properties file.
If you want to use
com.android.support:support-v4:28.0.0-alpha1,
then you have to use
com.android.support:design:28.0.0-alpha1
instead of
com.google.android.material:material:1.0.0-alpha1.
Use this
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "ir.uncode.newdesign"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguardrules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha3'}
repositories {
mavenCentral()
}
and If the problem persists change "import" on class and xml.
like :
import androidx.fragment.app.Fragment;
import android.support.v4.app.Fragment;
or
import androidx.core.app.ActivityCompat;
import android.support.v4.app.ActivityCompat;
or
com.google.android.material.bottomappbar.BottomAppBar
android.support.design.bottomappbar.BottomAppBar
If you are using Android Studio V. 3.2.1 , You can simply go to the tools bar open Refactor -> migrate to AndroidX and Android studio will take care of the rest.
I am using android studio 3.3 version. I wasted my one and a half day looking for this solution. I tried all the answer in this post but nothing helped. Then I find the link which helped me to solve the error.
I removed the below dependency I added,
implemntation 'com.google.android.material:material:1.0.0'
Instead, I used android design support library,
implementation 'com.android.support:design:27.1.1'
try setting android.enableJetifier=true and android.useAndroidX=true
in your gradle.properties file.
If you have 3.1.0 change to 3.2.0:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
You need to move to androidx
Remove all the imports which start with
import android.support.*
Change All imports to import androix.* and corresponding components.

Categories