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
Related
I have updated my Firebase Crashlytics from
implementation 'com.google.firebase:firebase-crashlytics:17.1.1'
to
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
Now I am getting this error:
error: package com.google.firebase.iid does not exist
When I try to import this:
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
This is my project level build.gradle file:
buildscript {
ext {
kotlin_version = '1.3.72'
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:perf-plugin:1.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20" }
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my app level build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 30
defaultConfig {
applicationId "..."
minSdkVersion 16
targetSdkVersion 30
versionCode ...
versionName "..."
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
//shrinkResources true NOT SUPPORTED FOR DYNAMIC MODULES
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
multiDexEnabled true
}
debug {
multiDexEnabled true
}
}
dynamicFeatures = [":premium", ':tutorial']
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api 'androidx.appcompat:appcompat:1.2.0'
api 'com.google.android.material:material:1.2.1'
api 'androidx.constraintlayout:constraintlayout:2.0.4'
api 'com.google.android.play:core:1.8.3'
api 'com.google.firebase:firebase-analytics:18.0.0'
api 'com.google.firebase:firebase-perf:19.0.10'
api 'com.google.firebase:firebase-invites:17.0.0'
api 'com.google.firebase:firebase-firestore:22.0.0'
api 'androidx.legacy:legacy-support-v4:1.0.0'
api 'com.google.firebase:firebase-config:20.0.1'
implementation 'com.google.firebase:firebase-appindexing:19.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
api 'androidx.navigation:navigation-fragment:2.3.1'
api 'androidx.cardview:cardview:1.0.0'
api 'androidx.recyclerview:recyclerview:1.1.0'
api 'androidx.preference:preference:1.1.1'
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
api 'com.google.firebase:firebase-auth:20.0.1'
api 'com.google.zxing:core:3.3.3'
api 'com.android.billingclient:billing:3.0.1'
//api 'com.facebook.android:facebook-android-sdk:5.15.3'
implementation 'com.google.android.gms:play-services-ads-lite:19.5.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.datatransport:transport-runtime:2.2.5'
}
The error doesn't happen with firebase crashlytics dependency version 17.1.1 and below.
I have already tried:
Rebuilding Project
Cleaning Project
Invalidating Cache and Restarting
The solution to this problem was that FirebaseInstanceId was depreciated. This means that it was removed from the library.
You can find more information about it here: https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId
i am trying to import network library , but android studio shows up with this meessage:ERROR: Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.amitshekhar.android:android-networking:1.0.2.
here is the build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myfaild"
minSdkVersion 16
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'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.amitshekhar.android:android-networking:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I know this is the old question, but I saw such a problem after removing jcenter() from repositories in gradle file:
repositories {
google()
jcenter()
}
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
this worked for me ,i had to add jitpack.io
Try this
compile 'com.amitshekhar.android:android-networking:1.0.2'
When using it with Jackson Parser
implementation 'com.amitshekhar.android:jackson-android-networking:1.0.2'
When using it with RxJava
implementation 'com.amitshekhar.android:rx-android-networking:1.0.2'
When using it with RxJava2
compile 'com.amitshekhar.android:rx2-android-networking:1.0.2'
add this line in gradle.properties:
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
this error occurred when I tried to set up my firebase with this project.
after searching...I found a solution which after then both synced and build works fine and the app run on my device.
But the problem is that:
I don't understand which pair version of android.support and firebase to use.
though the app works fine it's still showing red underlined.
Thanks for the help.
build.gradle(project)
build.gradle(app)
AndroidManifest
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.collegeapp"
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'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation 'com.google.firebase:firebase-analytics:15.0.0'
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'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(project)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.3.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
}
Try to use upgrade version of firebase-analtyics.
implementation 'com.google.firebase:firebase-analytics:16.0.0'
I have been getting the error about the annotation processor for the Realm library fails to load, am I missing something? Where do I add it in or what should I do?
This is the error I get:
"Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- realm-android-0.82.1.jar (io.realm:realm-android:0.82.1)"
Please help.
App.Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.version.crt.myapplication"
minSdkVersion 22
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'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'io.realm:realm-android:0.82.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'
}
Project.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.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
}
Please assist!
Follow the instructions as mentioned in realm docs
Step 1: Add the class path dependency to the project level build.gradle file. (Which you refer to as Project gradle in question)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:5.4.1"
}
}
...
Step 2: Apply the realm-android plugin to the top of the application level build.gradle file. (Which you refer to as App gradle in question)
apply plugin: 'realm-android'
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.version.crt.myapplication"
minSdkVersion 22
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'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.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'
}
Add below two line
implementation 'io.realm:realm-android:0.82.1'
annotationProcessor 'io.realm:realm-android:0.82.1'
instead of just one line
implementation 'io.realm:realm-android:0.82.1'
should resolved the problem.
I use firebase on my project. So at the bottom of my app/build.gradle file is
apply plugin: 'com.google.gms.google-services'.
When I want to activate Databinding with
dataBinding {enabled true}
I'm getting the error;
"Gradle sync failed: Can not change dependencies of configuration ': app: api' after it has been included in dependency resolution."
As a result, when multiple plugins are added, DataBinding gives an error. I still can not find a solution.
How to use data binding in a project using Google Services?
Android Studio 3.1.2
Gradle 4.4
The problem is in the gms version. The problem has been resolved with version 4.0.1
// classpath 'com.google.gms:google-services:3.3.1'
classpath 'com.google.gms:google-services:4.0.1'
Fix with further steps -
1 In App level bulid.gradel file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "test.com.apptest"
minSdkVersion 15
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'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
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'
// add firbase
implementation 'com.google.firebase:firebase-messaging:15.0.2'
}
2. Project level gradel file.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}