Cannot resolve symbol 'services' import com.google.api.services; - java

I am trying to follow this sample for google-api-java-client for android app but in my andoid project it is not resolving the symbol services and drive. I downloaded the lib files of google-api-java-client and copied it to the apps lib folder.
Included following to app build.gradle
implementation 'com.google.android.gms:play-services-drive:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation 'com.google.android.gms:play-services-identity:15.0.1'
implementation 'com.google.apis:google-api-services-storage:v1-rev134-1.23.0'
and added the following to project build.gradle
buildscript {
repositories {
google()
maven {url "https://maven.google.com"}
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
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 {
google()
maven {url "https://maven.google.com"}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
but still I am getting the error that can not resolve the symbol.

Related

How does Android search for dependencies on GitHub?

i want to implement a dependency from GitHub in my android project but it gives me this error
Could not find com.github.RobertApikyan:SegmentedControl:1.2.0
I'm implementing this:
implementation 'com.github.RobertApikyan:SegmentedControl:1.2.0'
I think is the case because by build.gradle file doesn't search on GitHub for repos.
This is my build.gradle file:
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
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
}
Workaround 1:
You can host a project release into mavenCentral using github, it is located at:
https://github.com/{user}/{repository}/packages?package_type=Maven
And in order to pull packages from it, add new repository in your build.gradle:
mavenCentral()
Wordaround 2:
You can host your project's any branch or version at jitpack.io
and the great thing is that you don't need to setup anything it'll build your packages in their server and notify you. Your project will be located at:
https://jitpack.io/#{user}/{repository}
And in order to pull packages from it, add new repository in your build.gradle:
maven { url 'https://jitpack.io' }

Could not set unknown property 'nav_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

I was trying to add Navigation dependencies to utilize the Navigation graph in my project and android studio threw this error.
This is my project Gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
nav_version = "2.3.0-alpha01" //extra property, used like variables
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
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
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
As you can see I added both a $nav_version dependency and the nav_version variable. But, android studio throws a "Could not set unknown property 'nav_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler" error. I wonder if it has something to do with the Gradle version or my Kotlin version. I tried to clean and re-build my project but it didn't work. I was wondering if anyone has encountered something similar.
It should be part of app level build.gradle.
Something like
dependencies {
def nav_version = "2.3.0-alpha01"
// Kotlin
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
// Dynamic Feature Module Support
implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
// Testing Navigation
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
}
& top/project level gradle
buildscript {
repositories {
google()
}
dependencies {
def nav_version = "2.3.0-alpha01"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
Or place it like ${nav_version}
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:${nav_version}"
Or
buildScript {
ext {
nav_version = "2.3.0-alpha01"
kotlin_version = "1.3.50"
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
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
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:${nav_version}"
}
}
Reference
https://developer.android.com/guide/navigation/navigation-getting-started

ERROR: Could not find com.android.tools.build:gradle:3.5.2

ERROR: Could not find com.android.tools.build:gradle:3.5.2.
Searched in the following locations:
-
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
-
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
Required by:
project :
Open File
ext {
var = '3.5.2'
var1 = '3.5.2'
}// 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.5.2'
// 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
}
we recived this error from my android studio when run my projects
we used online and offline mod but they not worked corectly
This error has confused me
The following code is related to wrapper
ext {
var = '3.5.2'
var1 = '3.5.2'
}// 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.5.2'
// 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 problem basically occurs when you are trying to load an old project. The best solution as of my knowledge is to download the links one by one, the project is showing and sync it. Check out the build Gradle files for any outdated dependencies.
Check out if you have
google()
repo in your project. Make sure you find this line in your dependencies.
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
I also had this problem on Linux (ubuntu)
I tried different ways but the problem still didn't work out.
Finally, I remove /home/(user)/.gradle directory and restart Android Studio and this error fixed.
Follow these steps:
Copy paste the below code into Project level 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.5.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Clean your project from Build > Clean Project
Rebuild you project from Build > Rebuild Project
Make Project from Build > Make Project
Then, File > Invalidate Caches/Restart

ERROR: Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8

I have problem with build project in android-studio from https://github.com/Samsung/microbit.
I imported repository by git, but while build gradle project from in android-studio I have error:
ERROR: Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71.
I am not sure how I can change version 1.2.72 to other version.
Edit:
Solution:
I added mavenCentral() to
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
google()
}
}
I think there is no need to use that as you can use kotlin-stdlib directly.
Try this:
In your app level build.gradle file, under dependencies section:
dependencies{
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.41"
}

Gradle project refresh failed Error: Cannot find JAR 'kotlin-compiler-embeddable-1.1.3-2.jar'

I created a new project and getting following Gradle Sync error.
Gradle 'ProjectX' project refresh failed Error: Cannot find JAR 'kotlin-compiler-embeddable-1.1.3-2.jar' required by module 'gradle-kotlin-dsl' using classpath or distribution.
I am not using 'Kotlin' and using Android 4.0(IceCreamSandwich). Below is my build.gradle
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Categories