Android- Could not resolve android.arch.persistence.room:runtime:1.0.0 - android

I've been trying to add room library dependency to my project. but I keep seeing this error:
Error:Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve android.arch.persistence.room:runtime:1.0.0.
I've searched a lot to solve the problem but I couldn't
build.gradle file of the Project
android {
compileSdkVersion 25
defaultConfig {
applicationId "com.reminder"
minSdkVersion 24
targetSdkVersion 25
buildToolsVersion '26.0.2'
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
allprojects {
repositories {
jcenter()
google()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
}
dependencies {
// Room
implementation "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
}
root build.gradle file
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Add like this:
allprojects {
repositories {
jcenter()
google()
}
}
and:
dependencies {
// Room
implementation "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
}
EDIT:
If you are using Offline Mode of Gradle, then disable the offline mode and sync gradle again. You can turn on Offline Mode after successful sync.
Offline Mode:
File > Settings > From left Pane: Build, Execution, Deployment > Gradle
Change "Offline work" to enable/disable Offline Mode

Related

Android: Failed to resolve: com.github.vpotvin:caldroidx:1.0

I am trying to integrate the CaldroidX library in my app (https://github.com/vpotvin/CaldroidX). However, I receive the below error:
Failed to resolve: com.github.vpotvin:caldroidx:1.0
This seems strange, as I believe I have followed the instructions correctly:
Specified maven { url 'https://jitpack.io' } in the project-level build.gradle.
Specified implementation 'com.github.vpotvin:caldroidx:1.0' in the app-level build.gradle.
Below is my project-level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Below is my app-level build.gradle:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.hijriconversioncalendar"
minSdkVersion 26
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 'com.github.vpotvin:caldroidx:1.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
You have added the maven repository at wrong place, change your project level gradle file like,
// 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"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

BillingClient and PurchasesUpdateListener classes not available

I'm trying to add in-app billing as described here:
https://developer.android.com/google/play/billing/integrate
and think I have set up dependencies as instructed, but still, both the BillingClient and PurchasesUpdateListener classes as in the code example on the page are not available.
My project's build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.myproject"
minSdkVersion 17
targetSdkVersion 26
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:19.5.0'
implementation 'com.android.billingclient:billing:3.0.1'
}
My top-level build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
How to fix this?
Changing my global build.gradle as follows helped me to resolve the missing dependencies:
buildscript {
repositories {
jcenter()
google()
mavenLocal()
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://maven.springframework.org/release" }
maven { url "https://maven.restlet.com" }
maven { url "https://jcenter.bintray.com" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
Hopefully this helps someone.
Make sure the global build.gradle is using the latest versions.
Then resyncing will resolve all the issues.

Cannot add task ':app:reportSourceSetTransformTest' as a task with that name already exists

Minimum supported gradle version 4.6 Current version is 4.4.
After updating gradle version to 4.6, am getting this error
Cannot add task ':app:reportSourceSetTransformTest' as a task with that name already exists.
How can I avoid this error. It seems like two different files have same task. But I didnot find any or explicitly define any task in my app level build.gradle file.
My project level build.gradle file is this:
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and app level build.gradle file is this:
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 27
buildToolsVersion '27.0.1'
flavorDimensions "default"
defaultConfig {
applicationId "com.applicationId"
minSdkVersion 16
targetSdkVersion 27
versionCode 3
versionName "1.0.2"
vectorDrawables.useSupportLibrary = true
}
aaptOptions {
cruncherEnabled = false
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
implementation project(':demo')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
androidTestImplementation('junit:junit:4.12')
implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
}
In my case I had a conflict with my flavour name and new gradle plugin.
The problem was solved when I changed the names of my flavours (Production, Test) -> (production, develop)

Android Studio: Error (2,0) Could not find method android() for arguments

Android Studio: Error (2,0) Could not find method android() for arguments [build_a4vgo3afez72iz8asoewhe39c$_run_closure1#7748caff] on root project '[ProjectName]' of type org.gradle.api.Project.
I am a new programmer just starting out, however I've had a problem with Android Studio in that my project will not successfully build. The response each build is the one stated above.
Anything you spot that can be the source of the problem? (Thanks in advance)
My Module app:
apply plugin: 'com.android.application'
apply plugin: 'java'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.rookr.scientificcalculator"
minSdkVersion 16
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.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
My Top-end app:
android {
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}
Remove android from top build
File should be start with buildscript
Remove android from the Top-level build.gradle.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

firebase jobdispatcher- I can't add dependency

I have problem w adding dependency for firebase jobdispatcher, I have tried back and forth with my gradle file, I have installed Google Play service in my android SDK and still I can't compile this depencency.
Here is my gradle file -app level
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.android.project"
minSdkVersion 19
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'
}
}
dataBinding.enabled = true
}
repositories {
mavenCentral()
maven {url "https://clojars.org/repo/"}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:preference-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
}
and here project level
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
try this in project-level build.gradle

Categories

Resources