can't build android project it shows error - java

project gradle
// 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:3.0.0-alpha3'
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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.arun4fms.efix"
minSdkVersion 17
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'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.chabbal:slidingdotsplash:1.0.2'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Error:A problem occurred configuring root project 'webapp'.
Could not resolve all dependencies for configuration ':classpath'.
Could not find com.android.tools.build:gradle:3.0.0-alpha3.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
Required by:
project :

As already answered here:
Google have new maven repo, so it could be the reason.
https://android-developers.googleblog.com/2017/05/android-studio-3-0-canary1.html
section Google's Maven Repository
https://developer.android.com/studio/preview/features/new-android-plugin-migration.html
https://developer.android.com/studio/build/dependencies.html#google-maven
Add Google’s Maven Repository to the buildscript repositories section to fix it like #KG87 did here.
buildscript {
repositories {
jcenter()
maven { url "https://maven.google.com" } // Add this line to fix it
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
...
}
}
As explained here:
The repositories in the buildScript block are used to fetch the
dependencies of your buildScript dependencies. These are the
dependencies that are put on the classpath of your build and that you
can refer to from your build file. For instance, extra plugins that
exist on the internet.
The repositories on the root level are used to fetch the dependencies
that your project depends on. So all the dependencies you need to
compile your project.
And here:
The buildScript block determines which plugins, task classes, and
other classes are available for use in the rest of the build script.
Without a buildScript block, you can use everything that ships with
Gradle out-of-the-box. If you additionally want to use third-party
plugins, task classes, or other classes (in the build script!), you
have to specify the corresponding dependencies in the buildScript
block.
As announced here:
The Android Gradle Plugin 3.0.0-alpha3 was also released through
maven.google.com.
So, try to fix it by adding Google’s Maven Repository.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Also add the repository here for other dependencies like the support libraries like this:
Make sure that the repositories section includes a maven section with
the "https://maven.google.com" endpoint. For example:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
The difference is explained here
The "buildscript" block only controls dependencies for the buildscript
process itself, not for the application code, which the top-level
"dependencies" block controls.
For instance, you could define dependencies in "buildscript/classpath"
that represent Gradle plugins used in the build process. Those plugins
would not be referenced as dependencies for the application code.
As commented here by #lugegege, this version doesn't exist in Bintray JCenter:
com.android.tools.build.gradle
latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3

com.android.tools.build.gradle latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3

Use this.. This may work because this worked in my case:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
}
and put this at the end of the app-level build.gradle file (after the dependencies).
apply plugin: 'com.google.gms.google-services'
I have no clue why putting this at the end (and not at the beginning ) solves the error.
Ok… So trying to put an end to all problems you guys have faced with my solution
This is my final app level gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "your-app-name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:design:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.6#aar'
}
apply plugin: 'com.google.gms.google-services'
and this is my final project level gradle
// 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.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Compare this with your own gradle files, and add or modify any values which are different from what I've written.

I had the same problem this morning !
As Vishal said, there is no gradle-3.0.0-alpha3..
I am sure that, since I downloaded "Android studio 3.0 Canary (Alpha3)", I was on on the same version of gradle (3.0.0 alpha3), and it worked ! (Since today).
So I've put : classpath 'com.android.tools.build:gradle:2.3.2' to compile.
EDIT : I have two versions of Android studio, When I used Android Studio 3.0, it changes gradle to gradle 3.0.0-alpha3 !

write these gradles..
compile 'com.android.support:appcompat-v7:25.0.2'
compile 'com.android.support:design:25.0.2'
classpath 'com.android.tools.build:gradle:2.2.3'

Related

ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher

please how can I solve this error ?
ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin
version 1.3.0 and higher. The following dependencies do not satisfy
the required version: root project 'android' ->
org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.6 Affected Modules:
android-app
WARNING: Configuration 'compile' is obsolete and has been replaced
with 'implementation' and 'api'. It will be removed at the end of
2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: android-app
WARNING: Configuration 'testCompile' is obsolete and has been replaced
with 'testImplementation'. It will be removed at the end of 2018. For
more information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: android-app
WARNING: Configuration 'androidTestCompile' is obsolete and has been
replaced with 'androidTestImplementation'. It will be removed at the
end of 2018. For more information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: android-app
WARNING: The specified Android SDK Build Tools version (26.0.2) is
ignored, as it is below the minimum supported version (28.0.3) for
Android Gradle Plugin 3.3.1. Android SDK Build Tools 28.0.3 will be
used. To suppress this warning, remove "buildToolsVersion '26.0.2'"
from your build.gradle file, as each version of the Android Gradle
Plugin now has a default version of the build tools. Remove Build
Tools version and sync project Affected Modules: android-app
my android-app file :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "fr.curie.jonquille.jonquille_curie"
minSdkVersion 18
targetSdkVersion 26
versionCode 203000
versionName "2.3.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:design:26.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.2.4'
compile 'io.reactivex:rxkotlin:0.60.0'
compile 'com.jakewharton.rxbinding:rxbinding-kotlin:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4-kotlin:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-appcompat-v7-kotlin:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-design-kotlin:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-recyclerview-v7-kotlin:1.0.0'
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.1#aar'
compile 'pl.charmas.android:android-reactive-location:0.10#aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.sdoward:rxgooglemaps:1.1.1#aar'
compile 'com.github.kittinunf.fuel:fuel:1.3.1'
compile 'com.github.kittinunf.fuel:fuel-android:1.3.1'
compile 'com.github.kittinunf.fuel:fuel-rxjava:1.3.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-wallet:10.0.1'
compile 'com.stripe:stripe-android:2.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.twitter.sdk.android:twitter-core:3.1.1'
compile 'com.twitter.sdk.android:tweet-composer:3.1.1'
testCompile 'junit:junit:4.12'
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
my android file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.0.6'
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
The error is caused by the old version of Kotlin in your project level file, you can update it to the latest version like so:
ext.kotlin_version = '1.3.21'
As for your warnings:
You should remove the explicit build tools version (buildToolsVersion "26.0.2") from your module level file, as the new Android Gradle plugins already pick the correct build tools to use automatically.
You should check out the link in the warnings and update your dependency configuration, e.g. replace compile with implementation or api, and so on.

ERROR Multiple dex files define Lcom/google/android/gms/location/places/zza;

I am facing this issue from 2 days, still not found any solution.
I tried changing versions of libraries, clean and build project, and invalidate cache etc.
Below is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.root.ambulancetracking"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//noinspection GradleCompatible
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:support-v4:27.1.1'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.firebase:firebase-core:16.0.0'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.ar-android:DrawRouteMaps:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.1'
}
}
}
}
And below is build.gradle (project):
// 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.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is what i am getting in message window.
Information:Gradle tasks [:app:assembleDebug]
Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/location/places/zza;
Information:BUILD FAILED in 1m 22s
Information:4 errors
Information:0 warnings
Information:See complete output in console
I tried my level best
Please, any help would be appreciated.
Thank you very much for your time and assistance in this matter.
please add this lib to resolve this issue
implementation 'com.android.support:multidex:1.0.3'
also, enable multidex in your application class
#Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
}
your version are conflict
compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.firebase:firebase-core:16.0.0'
compile 'com.google.android.gms:play-services-location:15.0.1'
covert to this lines :
compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.firebase:firebase-core:17.0.0'
compile 'com.google.android.gms:play-services-location:17.0.0'
You need to use the same version of Firebase and Google Play Service if you're using google play service plugin below 3.3.0.
If you want to use multiple version of Firebase and Google Play Service (starting from version 15), you need to use google play service plugin 3.3.0. So, change your project build.gradle to:
// 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.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
...
Last, don't forget to always add the following line:
apply plugin: 'com.google.gms.google-services'
to the bottom of your app build.gradle.

Failed to resolve: com.google.firebase:firebase-core:16.0.1

I'm trying to add firebase cloud storage to my app. Below is the app build.gradle. But it says:
Failed to resolve: com.google.firebase:firebase-core:16.0.1.
Why? There is no firebase-core in the dependencies at all.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.louise.udacity.mydict"
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'
}
}
}
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.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.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'
implementation 'com.google.cloud:google-cloud-storage:1.31.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
}
apply plugin: 'com.google.gms.google-services'
From the docs:-
Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.
Add:
implementation 'com.google.firebase:firebase-core:16.0.1'
and in top level gradle file use the latest version of google play services:
classpath 'com.google.gms:google-services:4.0.2'
https://firebase.google.com/support/release-notes/android
https://bintray.com/android/android-tools/com.google.gms.google-services
Note:
You need to add the google() repo in the top level gradle file, as specified in the firebase docs and also it should be before jcenter():
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
https://firebase.google.com/docs/android/setup
As #Peter Haddad mentioned above,
To fix this issue I followed Google firebase integration guidelines and did the following changes in my app/build.gradle and project/build.gradle
Follow below mentioned link if you have any doubts
https://firebase.google.com/docs/android/setup
changes in app/build.gradle
implementation 'com.google.android.gms:play-services-base:15.0.2'
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.4.0"
Changes in Project/build.gradle
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.2.0'// // google-services plugin it should be latest if you are using firebase version 16.0 +
}
allprojects {
repositories {
google()// add it to top instead of bottom or somewhere in middle
mavenLocal()
mavenCentral()
maven {
url 'https://maven.google.com'
}
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
Add maven { url "https://maven.google.com" } to your root level build.gradle file
repositories {
maven { url "https://maven.google.com" }
flatDir {
dirs 'libs'
}
}
Since May 23, 2018 update, when you're using a firebase dependency, you must include the firebase-core dependency, too.
If adding it, you still having the error, try to update the gradle plugin in your gradle-wrapper.properties to 4.5 version:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
and resync the project.
I get the same issue and i solved it by replacing :
implementation 'com.google.firebase:firebase-core:16.0.1'
to
implementation 'com.google.firebase:firebase-core:15.0.2'
and everything solved and worked well.
What actually was missing for me and what made it work then was downloading'Google Play services' and 'Google Repository'
Go to: Settings -> Android SDK -> SDK Tools -> check/install Google Play services + repository
Hope it helps.
I was able to solve the issue by following these steps-
1.) This error occurs when you didn't connect your project to firebase.
Do that from Tools->Firebase if you are using Android studio version 2.2 or above.
2.) Make sure you have replaced the compile with implementation in dependencies in app/build.gradle
3.) Include your firebase dependency from the firebase docs. Everything should work fine now
This is rare, but there is a chance your project's gradle offline mode is enable, disable offline mode with the following steps;
In android studio, locate the file tab of the header and click
In the drop own menu, select settings
In the dialog produced, select "Build, Execution, Deploy" and then select "Gradle"
Finally uncheck the "offline work" check box and apply changes
If this doesn't work leave a comment describing your Logcat response and i'll try to help more.
In my case it was resolved by changing the compileSdkVersion and targetSdkVersion from 26 to 27
If you use Firebase in a library module, you need to apply the google play services gradle plugin to it in addition to the app(s) module(s), but also, you need to beware of version 4.2.0 (and 4.1.0) which are broken, and use version 4.0.2 instead.
Here's the issue: https://github.com/google/play-services-plugins/issues/22
if you are using
compileSdkVersion 23
in app-level gradle, and
classpath 'com.android.tools.build:gradle:2.1.0'
in project-level gradle
and you have added the
google-services.json file to your project.
you need to add just below code
maven {
url "https://maven.google.com"
}
at below of jcenter() in repositories blocks in project-level gradle file
here are my gradle files:
project-level gradle file:
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and app-level gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.moslem.amazonlikeapp"
minSdkVersion 21
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.3.0'
compile 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
Just add below code and update all firebase versions that will work
implementation 'com.google.firebase:firebase-core:17.2.0'
If you receive an error stating the library cannot be found, check the Google maven repo for your library and version. I had a version suddenly disappear and make my builds fail.
https://maven.google.com/web/index.html
Go to
Settings -> Android SDK -> SDK Tools ->
and make sure you install Google Play Services

Error: more than one library with package name 'com.google.android.gms.license'

Today, I opened Android Studio, then I get this error. Yesterday, there was a no problem such that!
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms.license'
com.google.android.gms:play-services-xxx libraries was
11.8.0
Onesignal library was
'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
Then I changed them to latest version.
Now App/Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "xxx.xxx.xxx"
minSdkVersion 15
targetSdkVersion 24
versionCode 10
versionName 'x.x.x'
manifestPlaceholders = [onesignal_app_id: "xxxxx-xx-xxx",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "XXX"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url 'https://maven.google.com' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
compile 'com.google.android.gms:play-services-ads:12.0.0'
//compile 'com.google.android.gms:play-services-ads:11.2.2'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
//compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.balysv:material-ripple:1.0.2'
compile "com.google.firebase:firebase-messaging:12.0.0"
compile 'com.github.hotchemi:android-rate:1.0.1'
compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
compile 'com.google.android.gms:play-services-analytics:12.0.0'
}
apply plugin: 'com.google.gms.google-services'
Project/Gradle:
// 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:3.1.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 {
jcenter()
}
}
But I am still getting same error that stated above. How can I solve this problem? Why did this problem occur Today when there was no problem, yesterday?
This probably because the play services version is not in the range defined for
OneSignal:[3.7.1, 3.99.99] which is (you can see it at this commit):
// Limit upper number (exclusive) to prevent untested versions
static def versionGroupOverrides = [
'com.google.android.gms': '[10.2.1, 11.7.0)',
'com.android.support': '[26.0.0, 27.1.0)'
]
So, try changing the play services version to 11.7.0.
You should try using OneSignal Gradle Plugin which helps make the OneSignal Android SDK compatible with your Android Studio project. Use OneSignal-Gradle-Plugin 0.8.0 for OneSignal:[3.7.1, 3.99.99]

Unable to merge Dex in Android Studio 3.0

I'm a beginner with Android Studio.
Every time I try running my app on my Google Tango tablet, the following error emerges:
Execution failed for task:':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchibeMergerException: Unable to merge dex
This is my app Module build.gradle file...
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.cs15yyo.myfyp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
//multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.tango:sdk-base:1.55'
compile 'com.google.tango:support-base:1.54'
compile 'com.google.tango:sdk-depth-interpolation:1.55'
compile 'com.google.tango:sdk-transform-helpers:1.55'
compile 'org.rajawali3d:rajawali:1.1.668#aar'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
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 project(':tango_support_java_lib')
implementation project(':tango_ux_support_library')
}
This is my Project build.gradle file...
// 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.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my tango_support_java_lib Module build.gradle file...
configurations.maybeCreate("default")
artifacts.add("default", file('tango_support_java_lib.aar'))
This is my tango_ux_support_library Module build.gradle file...
configurations.maybeCreate("default")
artifacts.add("default", file('tango_ux_support_library.aar'))
Attempted Solutions
Looking at existing solutions in StackOverFlow, I've tried the following....
Writing multiDexEnabled true in the buildConfig block of code within the module build.gradle file
Build > Clean Project and afterwards, Build > Rebuild Project
Deleting the .gradle folder, and then running the app
Changing each compile word to compileOnly in the dependencies of my Module build.gradle file.
All have failed me, annoyingly so.
This is for my work on my final year Computer Science project.
I've solved the issue, as it turns out, the cause of the problem was importing JAR/AAR files as libraries AFTER writing the necessary dependencies (in the module build.gradle file) to get the same libraries; therefore, after removing the JAR/AAR files, my app was able to run

Categories

Resources