Dependency Implementation is not working - android

So the resource symbol "R" doesn't seem to be working in the MainActivity.java file. I did a clean and rebuild on it but still doesn't work.
Then I get an error message on the console. It says that the implementation file in dependencies is not found. How can I correct this?
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.android.miwok"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.3.0'
}

From the log you posted there is no reference to the maven google repository where the ConstraintLayout package is stored.
Please make sure you add this repository in the main build.gradle file.
repositories {
google()
}
More info here:
https://developer.android.com/training/constraint-layout/

To use ConstraintLayout in your project, proceed as follows:
Ensure you have the maven.google.com repository declared in your module-level build.gradle file:
repositories {
google()
}
Add the library as a dependency in the same build.gradle file, as shown in the example below. Note that the latest version might be different than what is shown in the example:
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
}
In the toolbar or sync notification, click Sync Project with Gradle Files.
Already described here: Constraint-layout

May be you need to set proxy to your gradle file
gradle.properties:
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=your port
systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=your port
check this source

Fixed it:
In the build.gradle (Project) file I added google() to
allprojects {
repositories {
jcenter()
}
}
and made it this:
allprojects {
repositories {
jcenter()
google()
}
}
Is this maven google repository?
I know I fixed it, but I have COMPLETELY no idea why that was the solution. If it is the maven google repository, could someone care to explain?

Related

Failed to resolve: support-fragment error when add google architecture component dependency

I want to use Google architecture components in my app, but after updating android studio to version 3.1.1 when I add android.arch.lifecycle:extensions:1.1.1 dependency into app.gradle file, it will show Failed to resolve: support-fragment
My gradle version is 4.4
This is app gardle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "ir.apptori.myapplication"
minSdkVersion 17
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.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'
implementation "android.arch.lifecycle:extensions:1.1.1"
}
Please guid me how to fix it, Thanks
I had a similar error and changing the repositories order so that google() comes before jcenter() fixed it.
I had to change the order for the repositories within buildscript and allprojects in the top level build.gradle file.
Please see this commit:
https://github.com/kunadawa/ud851-Exercises/commit/9f6720ef4d52c71b206ddaa8477f2cf6e77a66f4
I also had to remove the maven url from the project build.gradle as in:
buildscript {
repositories {
google()
jcenter()
// maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
This now works for me.
add these two to build.gradle -> repositories
{
mavenCentral()
google()
}
and add to these are to allprojects
allprojects {
repositories {
mavenCentral()
google()
}
}
i add this line in build.gradle and fixed bug :
implementation 'androidx.fragment:fragment:1.2.5'
This just happened to me with a project I cloned from github.
I updated my SDK and buildtools and had to double check all the dependencies to match the buildToolsVersion and the compileSdkVersion from the project.
The error message wasn't very clear when I tried to sync the project, it only gave me a more explicit error when I tried to run and it failed.
Could not find support-fragment.jar (com.android.support:support-fragment:27.0.2).
Good Luck!
for a similar issue its solved by changing material implementation from alpha2 version to alpha 7 in the app build.gradle file
implementation 'com.google.android.material:material:1.1.0-alpha07'

Failed to resolve android.design.26.0.0 and appcompat

BuildGrade in /src
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.amirqadir.finalchat"
minSdkVersion 18
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'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//compile 'com.android.support:design:26'
//firebase dependencies
//compile 'com.google.firebase:firebase-database '
compile 'com.google.android:design:26.0.0'
compile 'com.firebaseui:firebase-ui:1.2.0'
}
Build Gradle of whole project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried everything none works I have tried installing repository etc.Its been 2 days I am stuck here
Is there anyway, I can surpass this as you can see in the above code I have used same version at every step but it still gives me error
I have seen somewhere they asked to add a dependency of google in build.gradle Which I already did as you can see
The latest support library version is 26.1.0 so make sure you change to this from 26.0.0.
Upgrade your gradle version for sdk 26. Make sure the dependencies in your top level build.gradle file looks like this:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
Also, the repositories should look like this:
allprojects {
repositories {
google()
jcenter()
}
}
Check your gradle/wrapper/gradle-wrapper.properties file. It should have this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Lastly, you can remove the attribute buildToolsVersion in app's build.gradle file as it is not required when you have the latest gradle version.
add the following at the end of the Module app build
apply plugin: 'com.google.gms.google-services'
and also update the google services and firebase plugins versions..
classpath 'com.google.gms:google-services:3.1.1'
classpath 'com.google.firebase:firebase-plugins:1.1.1'
Please change the dependency
compile 'com.android.support:appcompat-v7:26.0.0'
into
compile 'com.android.support:appcompat-v7:26.+'

Getting an error when using com.google.android.gms:play-services-maps:11.2.0 in my application

I am trying to create a simple Android application. I have the latest version of Android Studio and i think both my gradle build files are correct.
I have placed
implementation 'com.google.android.gms:play-services-maps:11.2.0'
in app gradle dependencies.
Due to this I get the following error:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:11.2.0.
I have looked at various links and tried out proposed solutions but none have worked for me.
Below are both my gradle build files.
project build.gradle:
//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.0.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://repo.situm.es/artifactory/libs-release-local" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "demo.situm.situmapp"
minSdkVersion 21
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'
matchingFallbacks = ['release', 'debug']
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.2.0'
//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'
}
//apply plugin: 'com.google.gms.google-services'
Hope you can help.
Thanks,
Kabir
try this i found:
Failed to resolve com.google.android.gms play-services-auth:11.2.0
Add maven to your root level build.gradle file
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
This maven repo is required starting from 11.2.0.
Or add google() repository to your "build.gradle" file. This gradle method is equivalent to
maven { url "https://maven.google.com" }.
repositories {
jcenter()
google()
}

Access remote gradle dependency

This is my first time to make remote repository. But I am facing some problem in accessing it. Following are my gradle files:
root gradle file
// Top-level build file where you can add configuration options
common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.imagelettericon"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.github.akashandroid90:imageletter:1.0'
}
and each time when I sync the code I am getting same error
Failed to resolve: com.github.akashandroid90:imageletter:1.0
I have follow this and this link to make my repo. But now I am not able to access it in gradle file.
Yo have to change your dependency.
compile 'com.github.akashandroid90:imageletter:1.0' is wrong.
Reading the doc in the github repo you should use.
dependencies {
compile 'com.imageletter:ImageLetterIcon:1.0'
}
However you can check the dependency in the jcenter repo.
Reading the pom file in the repo, I have some doubs about the name.
It should be:
compile 'com.github.akashandroid90:image-letter-icon:1.0'
You can use another way to add a dependency with a github project,using the github repo and the jitpack plugin
In this case you have to add this repo tp your build.gradle
repositories {
// ...
maven { url "https://jitpack.io" }
}
and the dependency:
dependencies {
compile 'com.github.User:Repo:Tag'
}
In your case it is
compile 'com.github.akashandroid90:ImageLetterIcon:1.0'
More info here.

Can't add ViewPagerIndicator to app with Gradle

i am trying to add Jack Whartons ViewPagerIndicator library https://github.com/JakeWharton/ViewPagerIndicator
to my app as i want to use the circle indicator for the viewpager i have. However i am having trouble adding it to my app.
i have followed this tutorial - Using ViewPagerIndicator library with Android Studio and Gradle
However i am getting this error
Error:Artifact 'library.aar (com.viewpagerindicator:library:2.4.1)' not found.
Searched in the following locations:
https://jcenter.bintray.com/com/viewpagerindicator/library/2.4.1/library-2.4.1.aar
if i remove the jCenter() code in my gradle then it works but the other dependencies i have included do not, so i am not sure how to get round having all the dependencies work together.
Here is my top level gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
}
And here is my module:app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.app.al.app"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.afollestad:material-dialogs:0.6.2.3'
compile files('libs/volley.jar')
compile 'uk.co.chrisjenx:calligraphy:2.0.2'
compile 'com.viewpagerindicator:library:2.4.1#aar'
}
Thanks for any and all help
You can check the maven repository or jcenter:
http://search.maven.org/#search%7Cga%7C1%7Ccom.viewpagerindicator
https://bintray.com/bintray/jcenter/com.viewpagerindicator%3Alibrary/view#files
There is a library artifact with 2.4.1, but it ISN'T an AAR file.
You have to use an alternative repo
maven { url "http://dl.bintray.com/populov/maven" }, but it is important the order.
Change your script:
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
mavenCentral()
}
}

Categories

Resources