Store the database on any outside server of an android app - android

I have used Firebase to store my database. But I am getting errors in setting it up for the application.
I have created a new project in the website and then configured it by using the package name.I also downloaded the json file and then copied it to the Project folder. And I also made changes to the Build.gradle file and module based gradle file.
Build.gradle file is as follows:
// 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'
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
}
build.gradle (module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.hsports.bandpop"
minSdkVersion 14
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.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-storage:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
I am getting the following errors on pressing sync button.
Error:Failed to resolve: com.google.firebase:firebase-core:9.6.1
Open File<br>Show in Project Structure dialog
Error:(26, 13) Failed to resolve: com.google.firebase:firebase-storage:9.6.1
Show in File<br>Show in Project Structure dialog
How to resolve this?

There is no Android class for this. Instead, you could build you own server/api to help you achieve it or you can use some third party services that help you easily sync/store your client data.
It's recommended to use Firebase . It's easy to use and cross platform.

Related

android studio the '-d' option with a directory destination is ignored because '-Xbuild-file' is specified

I am new to android development and just created my first "hello world" project in android studio 3.2 ( canary ) following this tutorial. https://developer.android.com/jetpack/docs/getting-started
and then I just did Build- > make project project tried to build and gave me following error.
Could not get unknown property 'archLifecycleVersion' for root project 'JetpackHelloWorld' of type org.gradle.api.Project.
but I was able to solve that error with help of answers on a question I posted.
android jetpack project gives archlifecycleversion build error
after that error was solved I tried to build again and now I have the following error.
the '-d' option with a directory destination is ignored because '-Xbuild-file' is specified
Update
Build.gradle (app folder level )
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.touseef.jetpackhelloworld"
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"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'android.arch.lifecycle:extensions:1.1.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'
}
build.gradle (project level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha14'
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run is disabled
as you can see in the screenshot, run option of the app is disabled and it asks me to edit configuration if I click on the drop down, what kind of configurations I am supposed to do in a empty project?
I had the same issue while building the project with Kotlin version 1.2.61, it worked after updating the version to 1.2.71 from 1.2.61
The classpath dependencies are(inside project level build.gradle) :
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha10'
classpath 'com.google.gms:google-services:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71"
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha06"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:1.2.71"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
For some reason the problem is that in settings of Kotlin compiler activated incremental compilation. If you disable these options - you will not receive the warning.

Failed to resolve: com.google.firebase:firebase-auth:11.2.2 [duplicate]

This question already has answers here:
Failed to resolve: com.google.firebase:firebase-core:11.2.0
(6 answers)
Closed 5 years ago.
I know that this question has been asked a lot, but the answer is always to go to your SDK Manager and make sure that Google Play Services and Google Repository are installed/updated.
Mine are both updated and installed. Google Play services is version 44 and Google Repository is version 58. Also, if I check for an update of Android Studio, it says that I have the latest version installed. So, this isn't the issue. Can anyone help me?
Here's my app build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.angelakarl.flashchatnewfirebase"
minSdkVersion 16
targetSdkVersion 25
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:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.firebase:firebase-database:11.2.2'
compile 'com.google.firebase:firebase-auth:11.2.2'
}
apply plugin: 'com.google.gms.google-services'
Here's my other build.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.3.3'
classpath 'com.google.gms:google-services:3.1.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
}
The errors I'm getting are
Error:(27, 13) Failed to resolve: com.google.firebase:firebase-auth:11.2.2
Error:Failed to resolve: com.google.firebase:firebase-core:11.2.2
Error:(26, 13) Failed to resolve: com.google.firebase:firebase-database:11.2.2
Please add Google's Maven repository like this to your project level build.gradle file:
allprojects
{
repositories
{
jcenter()
maven { url "https://maven.google.com" // Google's Maven repository}
}
}

android : cannot build project after upgrading Android Studio to 2.3

So, happily updated my Android Studio from stable version 2.2 to canary channel 2.3.
But, unfortunately, it has serious bug. Project is not able to build.
I tried opening my previous projects and also tried creating new sample application, I got same below error:
Gradle 'MyApplication' project refresh failed
Error:A problem occurred configuring project ':app'.
build.gradle(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.0-alpha1'
// 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(app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.chint.myapplication"
minSdkVersion 16
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-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:design:25.0.0'
testCompile 'junit:junit:4.12'
}
Am I the only one with this issue ?
So, be careful while this dialog appears:
Choose "Remind me later" and NOT "Update"
Stay with the build version you already have.
Incase, you pressed Update, so just rollback your Android Gradle Plugin classpath in build.gradle(project) to below one:
classpath 'com.android.tools.build:gradle:2.2.2'
This worked for me.
You should update your Android Studio gradle manually.
1° Step:
Follow this path and get your gradle version
C:\Users\[USER_NAME]\.gradle\wrapper\dists
Here you will get "gradle-X.X" (X- is version) in my case it was "gradle-3.3-all"
2° Step:
Go to the following link :
https://services.gradle.org/distributions/
Download your respective version zip file and just past it in the last folder with long random name.
C:\Users\[USER_NAME]\.gradle\wrapper\dists\gradle-x.x\55gk2rcmfc6p2dg9u9ohc31212 HERE
Now open the Android studio, I hope this will work.
I fought a similar issue and resolved it with the addition of 2 characters...
And after updating the gradle-wrapper.properties to target 3.2.1 everything was great for me
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip
If you import external libraries apply changes for "allprojects"
// 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.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Android Build Gradle doesn't complete

I had a problem to run android-studios build gradle, so I tested many solution but unfortunately I couldn't solve my problem:
Now i uninstall my old Android studio and Android-sdk , then I download android studio 1.5.1 that contains default SDK .
I install them and I create an empty project , But it take 30 minutes to build project, I will add dialog window that shown in this period of time .
Finally project created with this error :
Error:(23, 17) Failed to resolve: junit:junit:4.12
Could any one help me ,please ?
build.gradle file content:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.armangar.app.fortest"
minSdkVersion 23
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')
androidTestCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
top build.gradle file content:
// 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
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
testCompile is the configuration for unit tests (located in src/test) and androidTestCompile is used for the test api (located in src/androidTest).
The main distinction between the two is that test runs in a regular Java JVM, and androidTest tests run on an Android device (or an emulator).
So, use
testCompile 'junit:junit:4.12'
instead of
androidTestCompile 'junit:junit:4.12'
source: http://tools.android.com/tech-docs/unit-testing-support
I think you have SSL problem.
Try by replacing
jcenter { url 'http://jcenter.bintray.com' }
with
jcenter()
in both repository blocks in build.gradle file and try to build gradle again.
I change jcenter() to mavenCentral() in build.gradle .
So my problem solved
EDIT:
This issue was related to my proxy . So I could not download from jcenter().
If you have a problem same this one, please check your Internet proxy .

Where can I put individual dependencies in Android Studio?

I am trying to install Picasso (http://square.github.io/picasso/) for use in Android Studio. One of the steps is to add this line: compile 'com.squareup.picasso:picasso:2.5.2' in build.gradle under dependencies. However, there is a message in gradle that tells me not to insert individual dependencies in the dependencies folder. What should I do?
// 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
}
You need to add it to the gradle.build file that is located in the "app" directory, not the one in your project directory. find the gradle.build file that sits within the "app" directory of your project.
Here is mine as an example:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.your.packagename"
minSdkVersion 15
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories { mavenCentral() }
dependencies {
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}
And a link to some supporting documentation:
http://developer.android.com/tools/building/configuring-gradle.html
Screenshot of the build.gradle(Module:app file)
Take a look at the image.
Do you see that there are actually 2 build.gradle files?
what you need is the (Module:app) gradle build file select that and paste the link in the dependencies part in the bottom of that file just like what i have done , then Android Studio will ask you to sync the file.
Do it.
It will download the dependency from your link provided and integrate with the project
Hope this helps..

Categories

Resources