Hare is my app gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.atumanin.testandroidannotations"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.1.18"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'io.reactivex.rxjava2:rxjava:2.1.6'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
}
and this is my project gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If I try to build project, I get error:
Could not resolve io.reactivex.rxjava2:rxjava:2.1.6.
and
Could not resolve io.reactivex.rxjava2:rxandroid:2.0.1.
I tried to clean, to rebuild the project and to invalidate cache. Nothing helps. I also tried to use compile instead of implementation. I also tried different versions of both libraries, also without success.
It will give error because official release for rxjava is 2.1.5.
simply change below lines of code
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
Official documentation
I found the solution. The issue was my proxy, it blocks https and I need to use the http version of repository. So instead of:
repositories {
jcenter()
}
I use now:
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
and it compiles now.
Changing
implementation 'io.reactivex.rxjava2:rxjava:2.1.6'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
to
api 'io.reactivex.rxjava2:rxjava:2.x.x'
api 'io.reactivex.rxjava2:rxandroid:2.0.1'
worked for me
#link https://github.com/ReactiveX/RxAndroid
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
// (see https://github.com/ReactiveX/RxJava/releases for latest 3.x.x version)
// Step 1 : in side build.gradle(Module:app)
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
// Step 2 : in side build.gradel(Project:ProjectName)
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
jcenter {
url "http://jcenter.bintray.com/"
}
}
}
Just try to uncheck the offline mode in your
Settings -> Gradle
and try again.That's worked for me
Related
There are many different questions about this, but the problems there are about using v7.28.0, v7.28.+, v7.28.0.0-rc02 But when I sync my project I get this error:
Unable to resolve dependency for ':app#debug/compileClasspath': Could
not resolve com.android.support:appcompat-v7:28.0.0.
I've checked Support library setup and followed it's instructions but it didn't help.
This is my module app
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.mobaleghan.nasimnoor"
manifestPlaceholders = [
onesignal_app_id: 'b1ced87b-48d1-4857-a68b-9c287aa4003f',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
minSdkVersion 16
targetSdkVersion 28
versionCode 8
versionName "1.6.3"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
debuggable true
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation "com.android.support:support-core-utils:28.0.0"
implementation 'com.onesignal:OneSignal:3.10.3'
}
and project gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
The android studio internet connection is fine as I've tested in settings and I don't know where else to look.
I even created a new project in AS 3.2.1 But I get same error.
I don't know why this happens every time I update AS!
I'm sure other answers are good and working. but mine got solved by set proxy to Freedom of Developers.
This solution is for Persians like me who suffer from strict limitations for Iranians by google.
Now my app gradle look like this:
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.mobaleghan.nasimnoor"
manifestPlaceholders = [
onesignal_app_id: 'b1ced87b-48d1-4857-a68b-9c287aa4003f',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
minSdkVersion 16
targetSdkVersion 28
versionCode 9
versionName "1.6.4"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
debuggable true
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:support-core-utils:28.0.0"
implementation 'com.onesignal:OneSignal:3.10.3'
}
Those repositories are there based on OneSignal documentations.
And top level build:
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// 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'
}
}
}
And everything is working fine.
Android project has 2 gradle files: one stored in project scope and one stored in application scope. (noted that one project can have many applications inside, but you usually have one). So you only need to swap defined repository url in those 2 gradle files.
Step 1: Remove these lines of code in your build.gradle (app)
repositories {
maven { url 'https://maven.google.com' }
}
Step 2: Add this to your build.gradle (project)
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
mavenCentral()
}
}
One thing you have to aware that 28.0.0 is the last stable version of android.support. So you might want to downgrade version or migrate everything to androidX.
The stable release of 28.0.0 will be the final feature release packaged as android.support. All subsequent feature releases will only be made available as androidx-packaged artifacts.
Check out this link and welcome to the new era of androidX.
Try the following:
1) Uncheck offline work from build tools:
File -> Other Settings -> Default Settings -> Build, Execution, Deployment -> Build Tools->Gradle->Uncheck Offline work option.
2) If above doesn't work then go to your project's build gradle and add the following under repositories:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
merge this part from the module's build.gradle into the root project's build.gradle:
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
}
}
repositories {
maven { url 'https://maven.google.com' }
}
only keep these lines in the module's build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
android {
...
}
the root project's build.gradle should look about like this then:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
You can still use version 28.0.0 but it seems its time to migrate to Android X!
According to Support Library Documentation:
Note: With the release of Android 9.0 (API level 28) there is a new
version of the support library called AndroidX which is part of
Jetpack. The AndroidX library contains the existing support library
and also includes the latest Jetpack components.
You can continue to use the support library. Historical artifacts
(those versioned 27 and earlier, and packaged as android.support.*)
will remain available on Google Maven. However, all new library
development will occur in the AndroidX library.
We recommend using the AndroidX libraries in all new projects. You
should also consider migrating existing projects to AndroidX as well.
I am developing an application and I am getting the following error:
error: cannot access zzbgl
class file for com.google.android.gms.internal.zzbgl not found
I know there's a question here in StackOverflow with the same error that I'm getting posted 4 days ago but the answer did not help in my case. (I am talking about this one)
The error appeared just right after setting Firebase Analytics in my project.
My build.gradle (Module: app) file is this:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId 'com.geoactio.montferri'
minSdkVersion 14
targetSdkVersion 26
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:26.1.0'
// compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0'
implementation 'com.google.android.gms:play-services:12.0.1'
//implementation 'com.google.android.gms:play-services-maps:15.0.1'
//implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation 'com.navercorp.pulltorefresh:library:3.2.3#aar'
}
productFlavors {
}
lintOptions {
disable 'MissingTranslation'
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
}
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
My build.gradle (Project: myPorojectName) file is this:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
And clicking in the error leads me here, just after new MarkerOptions():
mapView.addMarker(new MarkerOptions().position(new LatLng(puntomarker.getLatitud(), puntomarker.getLongitud()))
.zIndex(0.5f)
.anchor(0.5f, 0.5f)
.title(puntomarker.getId() + "")
.snippet(puntomarker.getNombre())
.icon(BitmapDescriptorFactory.fromBitmap(((BitmapDrawable) marker).getBitmap())));
(being mapView a GoogleMap instance).
I hope someone can see the error and solve this, thank you so much in advance.
If you need any more information in order to solve this, please let me know.
The Google API Release Notes indicate that support for the combined play-services library ended in April 2018:
Starting with 15.0.0, there will no longer be a play-services alias target to pull in all Google Play services components. This has been recommended against for some time.
You can no longer specify a single dependency on the combined Google Play services target like this anymore:
implementation 'com.google.android.gms:play-services:12.0.1'.
When this was supported with previous versions, it pulled in ALL the Google Play libs way more than you need. See the list of APIs in Table 1 of the Setup Guide and include only the specific ones your app uses.
A check of the Google Maven Repository confirms that version 12.0.1 was the last version of the combined play-services target.
So please delete the above implementation and use only:
implementation "com.google.android.gms:play-services-base:15.0.1"
If you are also using other play services, please add them as separate dependencies.
I think your main reason for the error is that you are using 2 different versions for play services libraries
implementation 'com.google.android.gms:play-services:12.0.1'
Here it is 12.0.1
implementation "com.google.android.gms:play-services-base:15.0.1"
While here it is 15.0.1.
Try to use same version of related libraries everywhere.
Just simply you need to change a Dependency because 12.0.1 is no more
implementation 'com.google.android.gms:play-services:12.0.1'
To
implementation 'com.google.android.gms:play-services-base:15.0.1'
And press sync Gradle
Hope this may help you
updates the version of all dependencies.
Generally, this error will happen if you are working with several new and old dependencies.
I am trying to setup firebase on my android studio.I am using a 2.2.3 version.So this is my code in app.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.parth.carpool"
minSdkVersion 22
targetSdkVersion 25
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-a`enter code here`nnotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.firebase:firebase-core:16.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
This is the error that I am receiving.
Error:(27, 13) Failed to resolve: com.google.firebase:firebase-core:16.0.1
This is my project.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:2.2.3'
classpath 'com.google.gms:google-services:4.0.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
}
To correct this error I installed google play services, google repository, SDK platform,SDK platform tools etc. after I saw some of the posts on stackoverflow. Does anybody have a solution?
First you need to upgrade android studio to the newest version:
If you're not using Android Studio 3.1 to develop your app, you will need to upgrade in order to get the correct version checking behavior within the IDE.
https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html
Then you need to use the following top level gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android Studio provides Awesome tool called Firebase Assistant, it handles any thing you need to setup firebase in you'r project
from Tools->Firebase
just pick which product you want and it'll do all the work for you
Make sure you are connected to a good network
Goto >file -> other settings -> Under build, execution, and deployment
-> you will see Gradle. uncheck the checkbox offline work. Then rebuild your project.
buildscript {
repositories {
// add google here
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:4.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Did you try on this link
In your root build.gradle file add the repo:
maven { url "https://maven.google.com" }
It depends upon you how you want to setup you can try both explicit way and implicit way of setting up firebase .the easiest one is implicit one which is given in android studio
I'm trying my hand at android development for the first time, and I'd like to create an app, "MyFirstApp", that's going to make calls to REST services. I did a little research and it looks like Spring for Android is a good tool to help me with this. I've never used Spring, and I'm not very familiar with Android Studio yet, so I'm confused how I should add the dependencies for Spring into my project.
Spring's website has a piece of code they say to copy and paste into my dependencies:
dependencies {
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
}repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
I realize there's already a question posted that addresses a very similar issue, but I need help knowing EXACTLY which file to add the above code to, and EXACTLY where to do so.
I have two "build.gradle" files that were created in my project. First is
build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.owner.myfirstapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
Second is build.gradle(Project: MyFirstApp)
// 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.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
}repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Can anyone help show me where in these two files I should include the Spring dependency? I really appreciate any help.
Add this in build.gradle (Module: app) inside dependencies
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
Add this in build.gradle(Project: MyFirstApp) inside repositories
maven {
url 'https://repo.spring.io/libs-milestone'
}
That's it. You are good to go.
I don't know if you are behind a firewall, so this should really be a suggestion, but need to show formatted code:
Try replacing https with http here:
maven {
url 'http**s**://repo.spring.io/libs-milestone'
}
And add a url for jcenter:
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
You add the compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3' under the dependencies in build.gradle(Module:app) and then the maven block:
maven {
url 'https://repo.spring.io/libs-milestone'
}
Is put in the allprojects set of braces below the dependencies block.
I'm trying to use this library
I've added
compile 'net.rdrei.android.dirchooser:library:2.0#aar'
to dependecies.
My top level build file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
And it gives me error "failed to refresh gradle project" with reference to the project, that I'm trying to import.
This library is not on Central Maven as aar.
Check here:
http://search.maven.org/#search%7Cga%7C1%7Cnet.rdrei.android.dirchooser
it is an apklib format.
I've checked the snapshots repo, and here you can find this library.
https://oss.sonatype.org/content/repositories/snapshots/net/rdrei/android/dirchooser/library/
To use the snap repo you have to change your script:
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
Then add you depencency, for example
compile 'net.rdrei.android.dirchooser:library:2.1-SNAPSHOT'
The answer provided by #unify #GabrieleMariotti and #AndyJoiner is correct. However it confused be since we have two gradle files - a project level gradle and a inner gradle (where you write your dependencies). The solution is to add the code suggested by #AndyJoiner inside your inner gradle.
Since I was confused as to where to add the code, which took me an hour to figure out, I don't want it to happen to others. So, I am posting my both gradle files.
Project Level Gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Inner Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.itcse.materialdesignsearchviewlikegoogleplay"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// Add the code for repositories here
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'http://guardian.github.com/maven/repo-releases' }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
// Add the dependencies here
compile 'com.quinny898.library.persistentsearch:library:1.0.0-SNAPSHOT#aar'
}
Hope this help others in future.
This worked for me:
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
You can find the repository here
https://oss.sonatype.org/#nexus-search;quick~dirchooser
After trying the answer by Gabriele and a bit more digging, this worked for me
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'http://guardian.github.com/maven/repo-releases' }
}
dependencies {
compile 'net.rdrei.android.dirchooser:library:2.2-SNAPSHOT#aar'
}