I was looking for information, there is an answer "Restart android studio" but it did not help
Error: Unresolved reference: setupWithNavController
app:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.relesrulate"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
androidExtensions {
experimental = true
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
// Navigation
implementation "androidx.navigation:navigation-fragment:$navigation_version" // For Kotlin use navigation-fragment-ktx
implementation "androidx.navigation:navigation-ui:$navigation_version" // For Kotlin use navigation-ui-ktx
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.0'
implementation "androidx.core:core-ktx:1.0.1"
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
progect:
buildscript {
ext.kotlin_version = '1.3.31'
ext.room_version = '2.1.0-alpha07'
ext.navigation_version = '2.1.0-alpha02'
ext.kodein_version = '5.2.0'
ext.lifecycle_version = '2.0.0'
ext.retrofit_version = '2.5.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
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 'android.arch.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha02'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha02"
} }
allprojects {
repositories {
google()
jcenter()
} }
task clean(type: Delete) {
delete rootProject.buildDir }
What needs to be fixed?
And sometimes a fragment does not appear in the navigation, new ones that have been recently added
As per the comments at the end of your navigation dependencies: For Kotlin use navigation-fragment-ktx, For Kotlin use navigation-ui-ktx. Since you're using Kotlin, you should use those to get access to Kotlin extension methods, such as setupNavController:
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
I had the same issue for adding navcontroller with toolbar, then I figured out that it was due to incorrect imports.
By mistake, I imported wrong toolbar (android.widget.toolbar), then I changed to androidx.appcompat.widget.Toolbar and it worked fine.
Related
I am trying to create a new project based on MVVM and was adding all the dependencies needed.
This is what i had added and done so far :
Added dependencies inside gradle file
Added plugin
Enabled dataBinding to true
Added classpath in gradle file
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha05"
Added android.databinding.enableV2=true
inside gradle.properties
I am following guide from this youtube playlist :
https://www.youtube.com/watch?v=Rd5dLmKewqg&list=PLk7v1Z2rk4hjVaZ8DZKe8iT9RIM9OUrwp&index=2
Things i had tried so far :
I had checked if
android.useAndroidX=true and android.enableJetifier=true
Replaced to minifyEnable false inside the gradle file
The app cannot even compile and have been showing error
This is my gradle project 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()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
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:2.1.0-alpha05"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my gradle Module:app file :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//kotlin kapt and navigation safeargs plugin
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs"
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mvvmsampleapp"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
[This is the error][1]}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Retrofit and GSON
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
//Kotlin Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
//New Material Design
implementation 'com.google.android.material:material:1.1.0-alpha07'
//Kodein Dependency Injection
implementation "org.kodein.di:kodein-di-generic-jvm:6.2.1"
implementation "org.kodein.di:kodein-di-framework-android-x:6.2.1"
//Android Room
implementation "androidx.room:room-runtime:2.1.0-rc01"
implementation "androidx.room:room-ktx:2.1.0-rc01"
kapt "androidx.room:room-compiler:2.1.0-rc01"
//Android Navigation Architecture
implementation "androidx.navigation:navigation-fragment-ktx:2.1.0-alpha05"
implementation "androidx.navigation:navigation-ui-ktx:2.1.0-alpha05"
implementation 'com.xwray:groupie:2.3.0'
implementation 'com.xwray:groupie-kotlin-android-extensions:2.3.0'
implementation 'com.xwray:groupie-databinding:2.3.0'
}
This is my error message
/Users/garylim/Downloads/MVVMSampleApp/app/build/generated/source/kapt/debug/com/example/mvvmsampleapp/DataBinderMapperImpl.java:9: error: cannot find symbol
import com.example.mvvmsampleapp.databinding.ActivityLoginBindingImpl;
^
symbol: class ActivityLoginBindingImpl
location: package com.example.mvvmsampleapp.databinding
P.S. Cannot post image yet
I am developing new app using android architecture components but I am getting the following error from gradle
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- lifecycle-compiler-2.0.0.jar (androidx.lifecycle:lifecycle-compiler:2.0.0)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for
below is my app.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.lifecycleawaredemo"
minSdkVersion 15
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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.lifecycle:lifecycle-compiler:2.0.0'
def lifecyle_version = "1.1.1"
implementation "android.arch.lifecycle:extensions:$lifecyle_version"
implementation "android.arch.lifecycle:compiler:$lifecyle_version"
}
below my build.gradle
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
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://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
First of all, you appear to be mixing up your androidx lifecycle dependencies. You are using androidx artifacts, so you can drop this part:
def lifecyle_version = "1.1.1"
implementation "android.arch.lifecycle:extensions:$lifecyle_version"
implementation "android.arch.lifecycle:compiler:$lifecyle_version"
You should only need:
implementation 'androidx.lifecycle:lifecycle-compiler:2.0.0'
Now, as to the error, the message says that the lifecycle-compiler contains annotation processors, so you should add them to the annotationProcessor configuration. To do this, add the following line at the apply plugin section for your app.gradle:
apply plugin: 'kotlin-kapt'
This will enable the kotlin annotation processor support. Next, change the:
implementation 'androidx.lifecycle:lifecycle-compiler:2.0.0'
to allow the compiler to use the included annotation processors:
kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0'
and that should compile fine.
Im using kotlin with android vision api for face detection.The build fails when I try to run the project.It looks like this
It gives kotlin compilation errors.I suppose there must be some version conflicts with respect to kotlin databinding , gradle etc.I tried various answers in the stackoverflow posts like this but can't find the solution.
This is my build.gradle(app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.android.ex1"
minSdkVersion 16
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'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-vision:11.8.0'
kapt "com.android.databinding:compiler:3.2.0-alpha10"
implementation "android.arch.persistence.room:runtime:1.0.0"
kapt "android.arch.persistence.room:compiler:1.0.0"
}
This is my build.gradle(root)
buildscript {
ext.kotlin_version = '1.3.10'
ext.gradle_version = '3.2.0-alpha10'
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10"
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()
maven { url "https://maven.google.com" }
}
}
task delete(type: Delete) {
delete rootProject.buildDir
}
Any help will be really useful.Thanks in advance!!
please check this
ext.gradle_version = '3.2.0-alpha10'
And
classpath 'com.android.tools.build:gradle:3.3.1'
Also
kapt "com.android.databinding:compiler:3.2.0-alpha10"
gradle version not the same
I am using android studio 3.2 Beta 2 for the application development. I am facing the error for support version 4 media in media browser compact custom action callback. My Error look like below:
"Error: Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback"
My gradle for app level look like this.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.sa.restaurant"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.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-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation "androidx.room:room-runtime:2.0.0-alpha1"
annotationProcessor "androidx.room:room-compiler:2.0.0-alpha1"
kapt "androidx.room:room-compiler:2.0.0-alpha1"
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
}
And gradle file for Project Level look like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-beta02'
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://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I'm working on a multiplatform project in Kotlin that has an Android module.
In one of my files, I have the code:
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
Which gets the following compiler error:
Unresolved reference: MATCH_PARENT
All of the references to anything beyond Android API level 1 get a similar compiler error, but not any references that are available in Android API level 1.
Android Studio recognizes all of the references made, and code completion is working on them just fine. Only when I compile do these errors show up.
My gradle file looks like this:
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "digital.wup:android-maven-publish:3.1.1"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.kotlinVersion}"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${rootProject.dokkaVersion}"
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-platform-android'
apply plugin: 'org.jetbrains.dokka-android'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
warning('InvalidPackage', 'NewApi')
}
}
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
def compatVersion = '27.1.1'
androidTestImplementation "com.android.support:support-annotations:${compatVersion}"
// androidTestCompile 'com.android.support.test:runner:1.0.2'
testImplementation 'junit:junit:4.12'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${rootProject.kotlinVersion}"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.lightningkite.kotlinx:jvm:${rootProject.libraryVersion}"
implementation "com.github.bigfishcat.android:svg-android:2.0.8"
expectedBy project(':common')
implementation "com.android.support:appcompat-v7:${compatVersion}"
implementation "com.android.support:cardview-v7:${compatVersion}"
implementation "com.android.support:gridlayout-v7:${compatVersion}"
implementation "com.android.support:recyclerview-v7:${compatVersion}"
implementation "com.android.support:design:${compatVersion}"
}
Turns out, whatever the issue was internally, it was actually triggered by this library in my build.gradle file:
implementation "com.github.bigfishcat.android:svg-android:2.0.8"
How a library cause this, I do not know. Everything builds fine now though.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.admin.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"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
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'
implementation 'com.android.support:recyclerview-v7:26.1.0'
}
my android studio version is 3.1.1
wroking properly
remove all kotlin library from your gradle
and put
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions
and in top level gradle bulid.gradle(your_app_name) put
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
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
}
}