I was working with one of the codelabs tutorials https://codelabs.developers.google.com/codelabs/android-room-with-a-view/index.html?index=..%2F..index#3 .
Int which while editing buil.gradle (app) . I got Failed to resolve : androidx ,Failed to resolve : androidx.arch & Failed to resolve : com.google.android
build.gradle
android {
compileSdkVersion 29
buildToolsVersion "30.0.1"
defaultConfig {
applicationId "com.example.androidroomcodelabs"
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'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// Room components
implementation "androidx.room:room-runtime:$rootProject.2.2.4"
annotationProcessor "androidx.room:room-compiler:$rootProject.2.2.4"
androidTestImplementation "androidx.room:room-testing:$rootProject.2.2.4"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.2.3.0"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$rootProject.2.3.0"
// UI
implementation "com.google.android.material:material:$rootProject.1.0.0"
// Testing
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.1.2.0"
}
Might be because you are missing the reference to the Google's maven repository in the project level build.gradle file:
buildscript {
repositories {
google() // this allow to lookup in the Google's maven repository
jcenter()
}
...
}
allprojects {
repositories {
google() // this allow to lookup in the Google's maven repository
jcenter()
}
}
It was a silly mistake that I made by not seeing the difference in build.gradle(app) and build.gradle. If in case someone ran into same error follow this.It will take me two days to accept my answer but it worked for me.
build.gradle(app)
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle extensions:$rootProject.archLifecycleVersion"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
// UI
implementation "com.google.android.material:material:$rootProject.materialVersion"
// Testing
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
Leaving the roomVersion, archLifecycleVersion, coreTestingVersion & materialVersion as they are and adding the below version in build.gradle
build.gradle
roomVersion = '2.2.1'
archLifecycleVersion = '2.2.0'
coreTestingVersion = '2.1.0'
materialVersion = '1.0.0'
}```
Related
In my project, I am trying to build auto image slider view
I am using SliderView library. And I added dependency from github:
implementation 'com.github.smarteist:autoimageslider:1.4.0-appcompat'
But when add this dependency in project and sync the project, and try to use this library in my xml file. This library not appear although the project is build successfully.
Build.gradle(app):
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.nctr.cd.bmvp"
minSdk 26
targetSdk 32
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.4.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.gitee.archermind-ti:autoimageslider:1.0.0-beta'
testImplementation 'junit:junit:4.13.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// room database dependency
def room_version = "2.4.3"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
//retrofit http client dependency
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
//swipe refresh dependency to add pull to refresh for recycleView
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
// dependency for gson
implementation 'com.google.code.gson:gson:2.9.1'
// dependency for loading image from url
implementation 'com.github.bumptech.glide:glide:4.11.0'
// google service dependency
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
// auto image slider dependency
implementation 'com.github.smarteist:autoimageslider:1.4.0-appcompat'
}
Please check if jcenter() repositories is missing in your build.gradle:
allprojects {
repositories {
google()
//here
jcenter()
mavenCentral()
}
}
And also make sure that your project is on appcompat dependencies.
The error is:
Could not resolve net.java.dev.jna:jna-platform
In the integration of Firebase to mu Grandle I get an error. I don't know if it's because the structure of the document was modified, since in mine it didn't contain "buildscript","allprojects".
I'm programming with java, not with kotlin in case it can help.
My gradle.app is
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.whatdowant"
minSdk 24
targetSdk 32
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.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
///Implement para FIREBASE
implementation 'com.google.firebase:firebase-auth:21.0.3'
implementation 'com.google.android.gms:play-services:play-services-auth:17.0.0'
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:29.3.1')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
apply plugin: 'com.google.gms.google-services'
> `My gradle. project is:`
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// Add the following line:
classpath 'com.google.gms:google-services:4.3.10' // Google Services plugin
classpath "com.android.tools.build:gradle:4.2.2"
}
}
allprojects {
repositories {
mavenCentral()
google() // Google's Maven repository
}
}
```
Hello am facing a problem in android studio
I bought an app source code on codecanyon it's my first to use android studio so im not a developer on Java after import my project getting gradle downloading in the bar below but after finished got this error
Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'
here is my build.gradle file
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and gradle.properties
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1024m
build.gradle inside folder app
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.storeweb.crosswords"
minSdkVersion 19
targetSdkVersion 30
multiDexEnabled true
versionCode 6
versionName "2.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
buildToolsVersion = '30.0.3'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.multidex:multidex:2.0.1"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.browser:browser:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.3.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.gms:play-services-ads:20.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
}
I try to build a release version for my APK but there are problems in the build, and this what is shown in my build-out
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugAndroidTestCompileClasspath'.
> Could not find com.google.firebase:firebase-firestore:.
Required by:
project :app > com.firebaseui:firebase-ui-firestore:7.2.0
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
and this is my code Module build.gradle
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'com.google.firebase.firebase-perf'
id 'com.google.firebase.crashlytics'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example"
minSdkVersion 21
targetSdkVersion 30
versionCode 3
versionName "2.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
assets {
srcDirs 'src\\main\\assets'
}
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.google.firebase:firebase-inappmessaging-display:20.0.0'
implementation 'com.google.firebase:firebase-config:21.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.lifecycle:lifecycle-process:2.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.daimajia.swipelayout:library:1.2.0#aar'
implementation 'com.airbnb.android:lottie:3.7.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
// For control over item selection of both touch and mouse driven selection
implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'
// FireBase Start implementation
implementation 'com.google.firebase:firebase-ads:20.2.0'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.firebase:firebase-perf:20.0.1'
implementation 'com.google.firebase:firebase-crashlytics:18.1.0'
implementation 'com.google.firebase:firebase-analytics:19.0.0'
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation 'com.firebaseui:firebase-ui-firestore:7.2.0'/*i think here is problem*/
implementation 'com.firebaseui:firebase-ui-database:7.2.0'
implementation 'com.google.firebase:firebase-bom:28.2.0'
implementation 'com.google.firebase:firebase-database:20.0.0'
implementation 'com.google.firebase:firebase-auth:21.0.1'
// FireBase End implementation
implementation 'com.github.tapadoo:alerter:7.1.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.20'
implementation 'com.pranavpandey.android:dynamic-toasts:4.0.0'
}
and this is project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.google.gms:google-services:4.3.8'
classpath 'com.google.firebase:perf-plugin:1.4.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I try many things to solve it but the problem is still found and if you have notes in my build.gradle alert me and thanks
in the firebase documentation, they also mention adding below implementations
implementation "com.google.firebase:firebase-firestore:$X.Y.Z"
implementation "androidx.legacy:legacy-support-v4:$X.Y.Z"
implementation "androidx.recyclerview:recyclerview:$X.Y.Z"
I recently added a card-stack-view dependency (implementation 'com.yuyakaido.android:card-stack-view:2.3.4') to my app level build.gradle and after that my project is giving syncing failure like:-
ERROR: Failed to resolve: androidx
Affected Modules: app
This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.animeapp.brijender.myapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
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:run ner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.yuyakaido.android:card-stack-view:2.3.4'
}
Can anyone help what i might be doing wrong?
Just add jCenter repository in project’s build.gradle (or if you are using the new way just add it in your settings.gradle)
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
}
}
include ':app'
Just Needed to remove these dependencies androidTestImplementation 'androidx.test:run ner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'