I have a problem I want to add com.github.PhilJay:MPAndroidChart:v3.1.0. implementation class but gradle reports that it does not find it despite the fact that I added the repositories and the class implementation in both gradle.
I have updated the version of the gradle but gradle still can't find com.github.PhilJay:MPAndroidChart:v3.1.0. implementation
Here's my project level's gradle file :
plugins {
id 'kotlin-android'
id 'com.android.application'
id 'kotlin-kapt'
id 'com.google.gms.google-services'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.wheeler"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
dataBinding = true
}
}
dependencies {
implementation 'com.google.firebase:firebase-storage-ktx:20.1.0'
implementation 'com.google.firebase:firebase-database-ktx:20.1.0'
def lifecycle_version = "2.2.0"
// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version")
// LiveData
implementation("androidx.lifecycle:lifecycle-livedata:$lifecycle_version")
def room_version = "2.4.2"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.android.gms:play-services-auth:20.4.0'
implementation 'com.google.firebase:firebase-database-ktx'
implementation platform('com.google.firebase:firebase-bom:31.1.1')
implementation 'com.google.android.material:material:1.6.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
Here's my app's gradle file :
buildscript {
repositories {
google()
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }// Warning: this repository is going to shut down soon
}
dependencies{
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.android.tools.build:gradle:7.2.1'
}}
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
What's the solution?
You need to add the maven { url "https://jitpack.io" } line to settings.gradle now (depending on the repositoryMode - new projects in Android Studio default to PREFER_SETTINGS, which means it looks for repositories in settings.gradle instead of the other gradle files).
For example:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url "https://jitpack.io" } // add this to get MPAndroidChart
}
}
Related
My aim is to add the KSP plugin to gradle as stated in the question heading.
just go through the line below each //from quickstart comments and you'll see all the error origins.
To add the dependencies I referred the Kotlin KSP quickstart documentation.
Now, the code might not be an exact replica of the one from the docs because that didn't work and so, I attempted some failed changes to try and make it work.
build.gradle(app/module) -
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
//from quickstart
id 'org.jetbrains.kotlin.jvm'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.cryptile"
minSdk 26
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'
implementation 'com.google.android.material:material:1.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
def room_version = "2.4.2"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
//what I want to implement
ksp "androidx.room:room-compiler:$room_version"
//from quickstart
implementation 'com.google.devtools.ksp:symbol-processing-api:1.6.10-1.0.2'
}
build.gradle(project) -
//from quickstart
buildscript {
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
}
}
plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
//from quickstart
id 'org.jetbrains.kotlin.jvm' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
settings.gradle -
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "CRYPTILE"
include ':app'
Any help is appriciated.
KSP guides failed to mention where to reference your processor. Use META-INF resource directory to reference your processor processor in your processormodule:
src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider
In this file you reference your ProcessorProvider:
com.my.package.processor.MySymbolProcessorProvider
This is important step in order your processor provider be recognized and later instantiate the actual processor.
If your dependencies setup are not in place please read further here https://medium.com/#nikoladespotoski/hands-on-google-ksp-c0508d623863
When I want to run the app, I get the following Build output:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all files for configuration ':app:kapt'.
> Could not find com.android.databinding:compiler:4.2.1.
I searched it already up on stackoverflow but it didn't help. I am stuck on this issue for 2 days now and it's driving me nuts :/
My project build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.10"
ext.version_navigation = "2.3.0"
ext.version_core = "1.3.1"
ext.version_constraint_layout = "2.0.0-rc1"
ext.version_lifecycle_extensions = "2.2.0"
ext.version_material = "1.2.0"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Navigation
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$version_navigation"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My module build.gradle file:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'androidx.navigation.safeargs'
id 'kotlin-kapt'
}
android {
buildFeatures {
dataBinding = true
viewBinding = true
}
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.commentapp"
minSdkVersion 27
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Navigation
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
kapt "com.android.databinding:compiler:4.2.1"
}
I hope you can help me with that. Write me if you need more information on my project (e.g. fragment file or something like that).
you dont need to put
kapt "com.android.databinding:compiler:4.2.1"
only need enable data binding in the gradle, and you did this
documentation: https://developer.android.com/jetpack/androidx/releases/databinding
I have implemented retrofit library with gson but getting an importing error.
Android studio version
Android Studio Arctic Fox | 2020.3.1 Patch 2 Build
#AI-203.7717.56.2031.7678000, built on August 27, 2021
App level build.gradle
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.app"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
dataBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:29.0.3')
// Declare the dependency for the Firebase Authentication library
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.android.gms:play-services-safetynet:18.0.0'
//Nav Component
implementation "androidx.fragment:fragment-ktx:1.3.6"
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
// Live Data
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
//Material Dialog
implementation 'com.afollestad.material-dialogs:core:3.3.0'
implementation 'com.afollestad.material-dialogs:bottomsheets:3.3.0'
//RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
//interceptor
implementation 'com.itkacher.okhttpprofiler:okhttpprofiler:1.0.7'
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.8.0"
implementation 'org.conscrypt:conscrypt-android:2.2.1'
testImplementation 'junit:junit:'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Top-level build.gradle
// 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:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
settings.gradel
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url "https://jitpack.io" }
}
}
rootProject.name = "Exaple app"
include ':app'
getting this error
I have already done some stuff like clean project, rebuild and invalidate caches, and restart. But still getting the same error.
Thanks in advance.
You need to implement also the GSON dependency
You missing this I'd say
implementation("com.google.code.gson:gson:2.8.9")
Hey guys im making an app in kotlin with jetpack compose but when i run the app its gives me this error.
"Execution failed for task ':app:compileDebugKotlin'.
Could not resolve all files for configuration ':app:kotlin-extension'.
Could not find androidx.compose.compiler:compiler:0.1.0-dev07.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/androidx/compose/compiler/compiler/0.1.0-dev07/compiler-0.1.0-dev07.pom
- https://jcenter.bintray.com/androidx/compose/compiler/compiler/0.1.0-dev07/compiler-0.1.0-dev07.pom
- https://jitpack.io/androidx/compose/compiler/compiler/0.1.0-dev07/compiler-0.1.0-dev07.pom
Required by:
project :app
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
"
This is my code(build-gradle):
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.github.zsoltk.pokedex"
minSdkVersion 21
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion "0.1.0-dev07"
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation "androidx.lifecycle:lifecycle-livedata:2.3.1"
implementation 'androidx.ui:ui-framework:0.1.0-dev07'
implementation 'androidx.ui:ui-layout:0.1.0-dev07'
implementation 'androidx.ui:ui-foundation:0.1.0-dev07'
implementation 'androidx.ui:ui-material:0.1.0-dev07'
implementation 'androidx.ui:ui-tooling:0.1.0-dev07'
implementation 'com.github.zsoltk:compose-router:0.7.0'
implementation "io.reactivex.rxjava2:rxjava:2.2.17"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
buildscript {
ext.kotlin_version = "1.3.61"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.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()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Any ideia of what i need to do?
How about adding the dependency it demands?
One needs this Gradle plugin:
https://mvnrepository.com/artifact/androidx.compose.compiler/compiler
And these are the Java dependencies:
https://mvnrepository.com/artifact/androidx.compose
implementation "androidx.compose:compose-compiler:0.1.0-dev17"
It's meanwhile dev17 and not dev7.
I am struggling with installation of Realm Library.
I've got failure massage like below
A problem occurred configuring root project 'My Application'.
Could not resolve all artifacts for configuration ':classpath'.
Could not find io.realm:realm-gradle-plugin:7.0.0-beta.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/io/realm/realm-gradle-plugin/7.0.0-beta/realm-gradle-plugin-7.0.0-beta.pom
- https://jcenter.bintray.com/io/realm/realm-gradle-plugin/7.0.0-beta/realm-gradle-plugin-7.0.0-beta.pom
Required by:
project :
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
build.gradle(:Module)
plugins {
id 'com.android.application'
id 'kotlin-android'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation 'io.reactivex.rxjava3:rxjava:3.0.7'
implementation 'io.reactivex.rxjava3:rxkotlin:3.0.0'
implementation 'com.facebook.stetho:stetho:1.5.1'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
implementation 'com.facebook.stetho:stetho-js-rhino:1.5.1'
}
build.gradle(:project)
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:7.0.0-beta"
// 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
}
Please let me know how yo fix it.