Gradle dependencies not being downloaded in new project - android

I created a new project and am trying to include an external dependency: https://github.com/KirkBushman/ARAW
I expect that when I add a dependency to my app-level build.gradle and re-sync my project, that the external dependency gets downloaded.
This is a screenshot of one of my old projects' file structure:
And this is my current project:
Why aren't I getting the same "External Libraries" part in my new project? This is what my new project's build.gradle(app-level) file looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.sometimestwo.jumblev2"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.github.KirkBushman:ARAW:v1.0.0-rc01' // what im trying to include
}
This is the "top-level" build.gradle file in my new 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:4.0.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://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Why aren't I getting the same "External Libraries" part in my new project?
Immediately above the portion of Android Studio you show in those screenshots, you will find a drop-down or similar sort of selector.
Your first screenshot probably has that set to Project:
Your second screenshot probably has that set to Android, which is the overall default:
Switch the new project to the Project view, and you should see the External Libraries branch of the tree.

Related

I tried connecting my Android project with Firebase but JSON file error is coming

this is my build.gradle(.app) file
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.moviebookingapp"
minSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-database:19.5.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation'com.android.support:recyclerview-v7:29.3.1'
implementation 'com.basgeekball:awesome-validation:1.3'
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation'com.google.firebase:firebase-database:19.5.1'
}
this is my build.gradle(movie booking app) 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:4.1.0'
classpath "com.google.gms:google-services:4.3.4"
// 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
}
google-services(1).json is the file which I have added
this is error is coming.
Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
D:\ankita\android\moviebookingapp2\app\google-services.json
D:\ankita\android\moviebookingapp2\app\src\nullnull\google-services.json
D:\ankita\android\moviebookingapp2\app\src\debug\google-services.json
D:\ankita\android\moviebookingapp2\app\src\nullnullDebug\google-services.json
D:\ankita\android\moviebookingapp2\app\src\nullnull\debug\google-services.json
D:\ankita\android\moviebookingapp2\app\src\debug\nullnull\google-services.json
I tried many other approaches, I also searched that the file is added or not, all I have searched, I don't know where I went wrong.
I ran into this issue at the start when I created my project. Make sure you have the proper json file added. Your current json file says "google-services(1).json". The app doesn't recognize the (1) and so it thinks it is a different file. Rename that to "google-services.json" and your code should work. It' kinda annoying that they are treated differently and I spent a lot of time at the start working this out too.
Before: google-services(1).json
After: google-services.json

Gradle Faild:ASCII

i'm using android 3.0.1. i began use firebase with android. after adding json file and updating both gradle file , i have got error message at the top of screen: Gradle project sync failed:Basic functionality (eg. editing , debugging) will not work. and down in the thin bar below : Gradle failed: ASCII as seen at below pic
error image
when i clicked Open File link occur below at pic,it opens build.gradle(Module: app).
To solve this issue, i have tried :
1- use gradle 4.4.1 instead of current one (file->settings->Gradle->use local gradle distribution).
2 -downgrade com.google.gms:google-services 4.3.0 or 4.2.0 - current is 4.3.3
but all useless.
any idea?
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.android.tools.build:gradle:4.4'
classpath 'com.google.gms:google-services:4.3.3'
// 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
}
build .gradle(Module)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.abdalla.home.ecommerce"
minSdkVersion 23
targetSdkVersion 26
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:26.1.0'
// compile 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-analytics:17.2.3'
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'
}
i changed dependency at gradle.build - Project as follows :
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
}
took a long time to sync successfully but succeeded at the end. i could not understand the logic behind.

Not Showing Developer Services in Project Structure

Not Showing Developer Services in Project Structure.
Hi currently i am working with
GoogleFirebase
and i successfully added my project with firebase but problem comes when i need to add the dependency for firebase client but when i open my File->project Structure i am getting this type pf project structure.
MyProject Strcuture
I am not able to add the dependency for firebase client.
This is my
build.gardle(Project)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my
build.gardle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.amk52.mymusic"
minSdkVersion 21
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.2'
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.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.firebaseui:firebase-ui:4.0.1'
}
apply plugin: 'com.google.gms.google-services'
How should i resolve my problem?
It's because you are trying to show the window from Files > Project Structure which it doesn't related to current project i suppose.
Instead, if you already added the dependencies of Firebase and Build was successful, go through Right click on the project, Open module Settings and then you should be able to see the Developer Services:
The developer services has been removed from Android Studio 2.2 and above and this is the link about this;
https://stackoverflow.com/a/37704210/4409113
Use Tools > Firebase

Unable to install Navigation in android

I am trying to install the latest release Navigation in Architecture components .
i am following this document Tutorial link
When i am trying to sync it is giving error .
Could not find androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.pom
https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.jar
https://jcenter.bintray.com/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.pom
https://jcenter.bintray.com/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.jar
Required by:
project :
Module Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.ard.navigationapp"
minSdkVersion 19
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'
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'
def nav_version = "1.0.0-alpha01"
implementation 'android.arch.navigation:navigation-fragment:$nav_version' // use -ktx for Kotlin
implementation 'android.arch.navigation:navigation-ui:$nav_version' // use -ktx for Kotlin
// optional - Test helpers
androidTestImplementation 'android.arch.navigation:navigation-testing:$nav_version' // use -ktx for Kotlin
}
apply plugin: 'androidx.navigation.safeargs'
Project 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.1.2'
classpath "androidx.navigation:safe-args-gradle-plugin:1.0.0-alph
a01"
// 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
}
That artifact does not seem to exist, based on what's in https://maven.google.com right now. Try android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01 instead. See also this issue.
Try to add
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01"
instead of
classpath "androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01"
If you're not concerned with type-safety of argument, you can skip the Safe args part and you will be good to go with Navigation Component.

Android Studio 3.0.1. won't sync the project

I just installed a fresh new Android Studio on a fresh new Windows 7. I created a new empty project and Android Studio keeps failing at project syncing. I tried few solutions people posted on SO, but none of them worked so I decided to show you my project structure hoping someone can help.
So, this is my project's 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.1'
// 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
}
And module's gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.kompjutor.myapplication"
minSdkVersion 15
targetSdkVersion 26
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:26.1.0'
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'
}
And those are the errors I'm getting:
Any ideas, please?
Issue could be caused by the following reasons
Gradle has not synced the libraries.
Android Studios offline mode is activated.
See this for more info
Go to File->Project Structure.
In the Dependency Tab Choose Plus icon appears green then choose Library dependency. And add through that. If still problem appears update Support Repository through SDK Manager

Categories

Resources