Getting gradle error with OneSignal in Android Studio - android

I am trying to incorporate OneSignal in my Android project. Getting following gradle error which saying Support libraries must have same version.
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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-ads:10.2.4'
compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)'
testCompile 'junit:junit:4.12'
}
Gradle giving error on compile 'com.android.support:appcompat-v7:25.3.1' and compile 'com.google.android.gms:play-services-ads:10.2.4' .

You have to provide onesignal_app_id and onesignal_google_project_number values in your Android Manifest.
Attribute meta-data#onesignal_app_id#value at AndroidManifest.xml requires a placeholder substitution but no value for <onesignal_app_id> is provided.
Attribute meta-data#onesignal_google_project_number#value at AndroidManifest.xml requires a placeholder substitution but no value for <onesignal_google_project_number> is provided.
These are the actual reasons for the build failure. Not the libraries/dependencies that you have mentioned

Related

Android libraries: versions conflict issue

I've the below dependence in my Android app build.gradle
compileSdkVersion 25
buildToolsVersion "25.0.2"
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:design:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
}
but getting an error about versions compatibility, as shown below, what is the one to be changed here, i could not figure it out :(
I had same problem what i did was compile the higher version of libraries ,which were creating this error,in app:gradle only.
for example in your case
compile 'com.android.support:mediarouter-v7:25.0.0'
Add this in app:gradle.
There may be more like this mediarouter libraries if it still give error add them jst like this(making them higher version).
First you need to find out where's what consists of a conflicting version of the library. The easiest way to do so is to:
Open Terminal pane in your Android Studio.
Type in: ./gradlew androidDependencies
Find the row that represents the ENCLOSING library consisting of a conflict.
Then just use exclude statement for the conflicting library, like so:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
(the example assuming com.android.support.test.espresso:espresso-core:2.2.2 was the ENCLOSING library, and com.android.support:support-annotations being the conflict)

Gradle indentation issue in Android Studio 2.3

Every time I create a new Activity in AS 2.3 it messes up the build.gradle indentation that results in errors like this.
Error:Could not get unknown property 'compile' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I have to redo the indentations every time. Any idea how to fix this permanently?
Don't use compile as a property and don't change the gradle structure.
compile 'com.android.support:appcompat-v7:22.2.1' compile
'com.parse:parse-android:1.11.0'
Sometimes Gradle build messes up the code like above, it still happens. Probably related to Java JDK updates.
The problem seems to be caused by the lines which contain curly braces like:
compile('com.github.tony19:logback-android-core:1.1.1-4') {
exclude group: 'ch.qos.logback.core.net'
}
In order to avoid the bug just put all the lines with curly braces above the "usual" (i.e. compile 'something') lines like this:
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.github.tony19:logback-android-core:1.1.1-4') {
exclude group: 'ch.qos.logback.core.net'
}
compile('com.github.tony19:logback-android-classic:1.1.1-4') {
exclude group: 'ch.qos.logback.core.net'
}
compile 'com.bolyartech.forge.android:forge-android:6.1.0'
compile 'com.bolyartech.scram_sasl:scram_sasl:2.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup:otto:1.3.6'
compile 'com.google.code.gson:gson:2.7'
compile 'com.github.franmontiel:PersistentCookieJar:v0.9.3'
compile 'com.google.dagger:dagger:2.9'
...

TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/content/res/TypedArrayUtils.class

I have shared graddle Image HereError:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/content/res/TypedArrayUtils.class
This error usually occurs when there is duplication of dependencies in gradle file. Check your app gradle file again, search for duplicate dependencies.
For instance, if google services of version 9.2.0 is added and another google service version for instance say maps is added with version 10.0.0 so here conflict will occur hence resulting with this error
Lİke #Techlnsect mentioned above we need to give direct import, try to remove ++ at the end of compiling element and find suitable for your work
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:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:2+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:multidex:1.0.0'
}
I changed it to and problem gone
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:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:multidex:1.0.0'
}

Unable to use Snackbar after updating Android Studio

I have recently updated my Android Studio version to 2.3
I am working on a project now and I've noticed that I am unable to import Snackbar class. I never had that problem before.
I can use it by adding compile 'com.nispok:snackbar:2.6.1' and I can import it then, but I don't think I should have to do that instead of just using Android's android.support.design.widget.Snackbar;
This is are my dependencies from build.gradle:
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:25.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I have also tried to play around with DataBinding concept in my project but I don't think this could cause that issue?
Thank you.
You are missing the compile 'com.android.support:design:25.2.0' in your dependencies. As the library is not added you are unable to get the Snackbar class.

Authorizing google API error

I'm trying to Authorizing and using googel API for android but when I try to configure build dependencies and sync the project it give me an error like
Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'.> Dependency Error.
See console for details.
build gradle (app):
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:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.api-client:google-api-client:1.22.0'
compile 'com.google.api-client:google-api-client-android:1.22.0'
compile 'com.google.apis:google-api-services-people:v1-rev4-1.22.0'
how can I solve this?
Not sure, but I think your google apis are conflicting
compile 'com.google.android.gms:play-services-auth:10.2.0'
and
compile 'com.google.api-client:google-api-client:1.22.0'
Might internally be using other dependencies, with different versions.
Try running: /gradlew app:dependencies to see all your dependencies

Categories

Resources