I want to use OneSignal in my android app but I get some errors after adding OneSignal dependency in my gradle file.
I am using Android Studio 3.1.
This is my gradle file:
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.nasser.myapplication"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFile 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso- core:2.2.2'
compile 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
}
and this is project's build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha01'
// 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' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
now when i sync gradle file i get many errors like this one:
Could not resolve com.android.support:support-v4:[26.0.0,26.2.0).
Required by:
project :app > com.onesignal:OneSignal:3.6.5
> Could not resolve com.android.support:support-v4:[26.0.0,26.2.0).
> Failed to list versions for com.android.support:support-v4.
> Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/com/android/support/support-v4/maven-metadata.xml.
> Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/support-v4/maven-metadata.xml'.
> dl.google.com:443 failed to respond
You should add the google maven in your project build.gradle:
repositories {
maven { url 'https://maven.google.com' }
}
You need to remember that OneSignal automatically adds the following dependencies:
com.google.android.gms - Version 11.2.+
com.android.support - Version 26.1.+
So, all dependencies must have matching versions.
To force the support library which your selected version, you can use the following:
// Must use 26.0.0 or newer if you have targetSdkVersion 26
def androidSupportVersion = '26.1.+'
compile("com.android.support:support-v4:${androidSupportVersion}") {
force = true
}
compile("com.android.support:customtabs:${androidSupportVersion}") {
force = true
}
Read more at Troubleshooting Android.
p.s: You should fix your build.gradle.
I met the same problem in Android Studio 3.1, and all build tasks are failed.
Finally I found my problem is caused by Gradle proxy setting. The solution:
Open the file ~/.gradle/gradle.properties, and delete proxy settings in it if any, like
systemProp.https.proxyPort=50846
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=50846
then restart Android Studio, build tasks works now.
Related
I need to make a floating circular menu
And I need to add a library to my project
Finally i found a library that would help me do that
implementation 'com.github.recruit-lifestyle:FloatingView:2.4.4'
When i add this library in my gradle i get an error
This is the error :
ERROR: Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.github.recruit-lifestyle:FloatingView:2.4.4.
ERROR: Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve com.github.recruit-lifestyle:FloatingView:2.4.4.
ERROR: Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve com.github.recruit-lifestyle:FloatingView:2.4.4.
does anyone know why is that?!
And I have tried to add other libraries, but every time I get the same error
How can i solve this problem?
Edit1
This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicatiomId "com.example.project"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependency {
implementation fileTree (dir: 'libs', include: ['*.jar])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayouy:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit::1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//This is the library I want to add
implementation 'com.github.recruit-lifestyle:FloatingView:2.4.4'
}
Edit2
My build.gradle (Project)
buildscript {
repositories {
google ()
jcenter ()
}
dependency {
classpath 'com.android.tools.build:gradle:3.5.3'
}
}
allprojects {
repositoriss {
google ()
jcenter ()
maven {
url "https://jitpack.io"
}
}
}
task clean (type: Delete){
delete rootProject.buildDir
}
Try adding below one:
dependencies {
implementation 'com.github.recruit-lifestyle:floatingview:2.4.5'
}
I checked it here and found that this one is working.
Also add this to your build.gradle (project)
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Also make sure to uncheck the Gradle Offline option in Settings.
File > Settings > Build, Execution, Deployment > Gradle > Uncheck Offline Work
I am trying to set up the Firstore API with my Android project however when I try to call FirebaseFirestore.getInstance() I get this error:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.google.firebase.FirebaseApp.<clinit>(com.google.firebase:firebase-common##16.1.0:150)
at com.google.firebase.firestore.FirebaseFirestore.getInstance(com.google.firebase:firebase-firestore##18.1.0:70)
at ip.travelaid.backend.Database.<init>(Database.java:16)
at ip.travelaid.backend.CLITest.main(CLITest.java:11)
Caused by: java.lang.RuntimeException: Stub!
at android.os.Looper.getMainLooper(Looper.java:23)
at com.google.firebase.FirebaseApp$UiExecutor.<clinit>(com.google.firebase:firebase-common##16.1.0:987)
... 4 more
I have checked both my project and app level build.gradle files and they match what the documentation requires, even the Firebase Assistant in AS says that they are right. Just in case though here they are:
Module 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.3.2'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "ip.travelaid"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.firebase:firebase-firestore:18.1.0'
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'
}
apply plugin: 'com.google.gms.google-services'
In the Firebase Console I have set up the database to deny any read/write requests but I thought that wouldn't affect my ability to get an instance to the database.
The google-services.json file for the Firebase project is up to date, I have even tried re-downloading it from the Firebase Console to no avail.
I have tried searching for a solution online but there seem to be nothing out there on it(this could well be down to me not being able to search for the issue properly though).
Is there a setting, either in the Firebase Console or AS, that I am missing that may be causing this issue?
update compiled & target sdk like so v
compiled sdk 26
to
compiled sdk 28
Obligatory: NVM I figured it out.
The problem was that I tried to run the code from the command line and not through an Android Emulator/Device actually running the app.
When I did run it there the problem disappeared.
I am using Android Studio 1.3.1 in Windows and same in Ubuntu.
In Ubuntu, everything is perfect.
But in Windows, when I compile third party libraries, the build fails and says:
Can not find resource
The build.gradle of my module is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "app.android.parking"
minSdkVersion 15
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.2.1'
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'cn.pedant.sweetalert:library:1.3'
}
the error is coming in the last line. And it is coming for every third party library,not only for this one.
When I open same project in Ubuntu, the build is successful.
The build.gradle of my project is:
// 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()
}
}
The exact error is:
Error:A problem occurred configuring project ':parking'.
Could not resolve all dependencies for configuration ':parking:_debugCompile'.
Could not resolve cn.pedant.sweetalert:library:1.3.
Required by:
parking:parking:unspecified
Could not resolve cn.pedant.sweetalert:library:1.3.
Could not get resource 'https://jcenter.bintray.com/cn/pedant/sweetalert/library/1.3/library-1.3.pom'.
Could not GET 'https://jcenter.bintray.com/cn/pedant/sweetalert/library/1.3/library-1.3.pom'.
jcenter.bintray.com
I tried invalidating cache and restart, It did not work. It is compiling everything except those third party libraries.
With the newer versions of Android Studio it has been advertised that you can add compile statements to the build.gradle file for 3rd party libraries that are available on Maven Central and Android Studio should be able to automatically download the appropriate dependencies. However I haven't been able to get the Gradle Sync to successfully complete when I try to add one of these libraries. Here is the build.gradle file for the project
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.appsbysynapps.helloname"
minSdkVersion 14
targetSdkVersion 21
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:21.0.3'
compile 'com.larswerkman:HoloColorPicker:1.5'
}
Here is the build.gradle for the module
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
Here is the error given out by Gradle
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.larswerkman:HoloColorPicker:1.5.
Required by:
HelloName:app:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
I've been having the same issue for any 3rd party library I've tried to add. This is also a brand new project created in Android Studio 1.1.0 and offline mode is disabled. Any ideas for what is going on?
I am using Android Studio 1.1.0 and am trying to add CircularReveal library .I have followed the instructions mentioned there.
my build.gradle(Module: app) is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.geronimo.myapplication"
minSdkVersion 18
targetSdkVersion 21
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:21.0.3'
compile 'com.github.ozodrukh:CircularReveal:(latest-release)#aar'
}
I have added the repository in `build.gradle(Project: MyApplication3)`
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
}
The error that I am getting is
D:\Workspaces\AndroidStudio\Studio1.0\MyApplication3\app\build.gradle
Error:(24, 13) Failed to resolve: com.github.ozodrukh:CircularReveal:(latest-release)
Show in File<br>Show in Project Structure dialog
I have tried variations of the dependency too ie:
compile 'com.github.ozodrukh:CircularReveal:(latest-release)#aar'
compile 'com.github.ozodrukh:CircularReveal:(v1.0.4)#aar'
compile 'com.github.ozodrukh:CircularReveal-v1.0.4 #aar'
The error always remains as Failed to resolve...
Is there any other way to import a remote aar file and to add this dependency?
Copy #aar file to the libs directory manually. Then by going to
Files>Project Structure>Dependency
on the right red cross choose library dependency. This will prompt you a dialog where you can search for your dependency and add them.
or
download circularReveal library from github and import it as Module Dependency from Files>Project Structure>Dependency
You need to put only version number without brackets and 'v' char
com.github.ozodrukh:CircularReveal:1.0.4#aar
I had the same problem before. After I checked, I saw that the problem was the miniSDKversion which was lower than 15. Once I changed it to 15, it worked.
minSdkVersion 14 (change it to 15 or above)
targetSdkVersion 26
Then paste this to your library dependency
implementation ('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
Also add remote maven url
repositories {
maven {
url "https://jitpack.io"
}
}