Error:Execution failed for task ':app:compileDebugKotlinAfterJava' - android

Information:Gradle tasks [:app:assembleDebug]
/Users/liwei/Desktop/Schedule/app/src/main/java/com/schedule/MainActivity.kt
Error:(5, 16) Unresolved reference: os
Error:(12, 8) Unresolved reference: java
Error:(13, 8) Unresolved reference: java
Error:(21, 5) 'onCreate' overrides nothing
Error:(21, 47) Unresolved reference: Bundle
Error:(27, 26) Unresolved reference: SimpleDateFormat
Error:(28, 20) Unresolved reference: Date
Error:(28, 25) Unresolved reference: System
Error:(31, 19) Unresolved reference: Calendar
Error:(35, 41) Unresolved reference: Calendar
Error:(46, 47) Type mismatch: inferred type is MainActivity but Context was expected
Error:(49, 25) Type mismatch: inferred type is kotlin.String but java.lang.String was expected
Error:(50, 24) The integer literal does not conform to the expected type Object
Error:(52, 45) Type mismatch: inferred type is MainActivity but Context was expected
Error:(55, 25) Type mismatch: inferred type is kotlin.String but java.lang.String was expected
Error:(56, 24) The integer literal does not conform to the expected type Object
Error:(58, 45) Type mismatch: inferred type is MainActivity but Context was expected
Error:(61, 25) Type mismatch: inferred type is kotlin.String but java.lang.String was expected
Error:(62, 24) The integer literal does not conform to the expected type Object
Error:(64, 44) Type mismatch: inferred type is MainActivity but Context was expected
Error:(67, 25) Type mismatch: inferred type is kotlin.String but java.lang.String was expected
Error:(68, 24) The integer literal does not conform to the expected type Object
Error:(70, 37) Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val [ERROR : ].tab: PagerBottomTabLayout! defined in kotlinx.android.synthetic.main.activity_main
Error:(84, 5) Class 'OnTabItemlistener' must be declared abstract or implement abstract member public abstract fun onSelected(p0: Int, p1: Object!): Unit defined in me.majiajie.pagerbottomtabstrip.listener.OnTabItemSelectListener
Error:(85, 9) 'onSelected' overrides nothing
Error:(86, 19) Unresolved reference: UnsupportedOperationException
Error:(89, 9) 'onRepeatClick' overrides nothing
Error:(90, 19) Unresolved reference: UnsupportedOperationException
Error:Execution failed for task ':app:compileDebugKotlinAfterJava'.
Compilation error. See log for more details
Information:BUILD FAILED
Information:Total time: 8.812 secs
Information:29 errors
Information:0 warnings
Information:See complete output in console
Kotlin Error
I don‘t down
Always appear this type of problem
Please
Help
Thanks

First of all, check if you have done all steps described in article below correctly: https://kotlinlang.org/docs/tutorials/kotlin-android.html
Then check which kotlin-plugin are you're already using. Hope you're not using 1.0.4 version and you chose Stable channel for kotlin updates, if not please downgrade it and rebuild projects.
There are some known issues dealing Kotlin with Data Binding library. Please, if possible - remove all its dependencies and rewrite binded code using kotlin-extensions library. Trust me, you don't need this library, when you're using code.
Then choose File -> Invalidate Caches, after invalidating and restart android studio, clean and rebuild your project.
Hope it will help

maybe u change version Kotlin language to ext.kotlin_version = '1.0.2-1'
by
https://github.com/djuarez/KotlinCleanArchitecture/blob/master/build.gradle

Related

android studio unresolved reference

I try to run my app and get this errors
e: /Users/idanfadlon/Desktop/Law-Tech-App/app/src/main/java/com/example/law_tech_app/fragments/BaseFragment.kt: (11, 24): Unresolved reference: synthetic
2.e: /Users/idanfadlon/Desktop/Law-Tech-App/app/src/main/java/com/example/law_tech_app/fragments/BaseFragment.kt: (19, 25): Unresolved reference: tv_progress_text
3.e: /Users/idanfadlon/Desktop/Law-Tech-App/app/src/main/java/com/example/law_tech_app/fragments/BaseFragment.kt: (19, 42): Variable expected
the problem is in base activity file and I dont touch him
I try to pull project again from my repository

Multiple warning and errors using Git with Flutter in Android Studio

Whenever I enable Git in any Flutter Project in Android Studio it gives me the following warning when I try to commit:
9 files contain problems.
18 errors and 12 warnings found.
Would you like to review them?
Is this supposed to happen? Because it also happens on a fresh standard Flutter App without any modifications. This is what it shows when clicked to review.
C:\Users\me\AndroidStudioProjects\flutter_app\android\app\src\main\AndroidManifest.xml
Warning:(1, 2) Should set `android:versionCode` to specify the application version
Warning:(1, 2) Should set `android:versionName` to specify the application version
Warning:(5, 9) Unknown attribute android:icon
Warning:(8, 13) Unknown attribute android:launchMode
Warning:(9, 13) Unknown attribute android:theme
Warning:(10, 13) Unknown attribute android:configChanges
Warning:(11, 13) Unknown attribute android:hardwareAccelerated
Warning:(11, 13) Attribute `hardwareAccelerated` is only used in API level 11 and higher (current min is 1)
Warning:(12, 13) Unknown attribute android:windowSoftInputMode
Warning:(12, 13) Attribute `windowSoftInputMode` is only used in API level 3 and higher (current min is 1)
Error:(19, 33) Cannot resolve symbol '#style/NormalTheme'
Error:(28, 33) Cannot resolve symbol '#drawable/launch_background'
C:\Users\me\AndroidStudioProjects\flutter_app\android\app\build.gradle
Error:(1, 27) Cannot resolve symbol 'Properties'
Error:(11, 15) Cannot resolve symbol 'GradleException'
C:\Users\me\AndroidStudioProjects\flutter_app\android\settings.gradle
Error:(3, 31) Cannot resolve symbol 'File'
Error:(4, 22) Cannot resolve symbol 'Properties'
C:\Users\me\AndroidStudioProjects\flutter_app\android\app\src\main\kotlin\com\heitorfranca\flutter_app\MainActivity.kt
Error:(3, 19) Unresolved reference: embedding
Error:(5, 21) Unresolved reference: FlutterActivity
C:\Users\me\AndroidStudioProjects\flutter_app\android\build.gradle
C:\Users\me\AndroidStudioProjects\flutter_app\android\app\src\main\res\drawable\launch_background.xml
Error:(4, 29) Cannot resolve symbol '#android:color/white'
C:\Users\me\AndroidStudioProjects\flutter_app\android\app\src\main\res\drawable-v21\launch_background.xml
Error:(4, 29) Cannot resolve symbol '?android:colorBackground'
C:\Users\me\AndroidStudioProjects\flutter_app\android\app\src\main\res\values-night\styles.xml
Error:(4, 39) Cannot resolve symbol '#android:style/Theme.Black.NoTitleBar'
Error:(7, 21) Cannot resolve symbol 'android:windowBackground'
Error:(15, 39) Cannot resolve symbol '#android:style/Theme.Black.NoTitleBar'
Error:(16, 21) Cannot resolve symbol 'android:windowBackground'
C:\Users\me\AndroidStudioProjects\flutter_app\android\app\src\main\res\values\styles.xml
Error:(4, 39) Cannot resolve symbol '#android:style/Theme.Light.NoTitleBar'
Error:(7, 21) Cannot resolve symbol 'android:windowBackground'
Error:(15, 39) Cannot resolve symbol '#android:style/Theme.Light.NoTitleBar'
Error:(16, 21) Cannot resolve symbol 'android:windowBackground'```

Can't run tests from Espresso Test Recorder

I used the test recorder to create a simple UI Test. However when I run the test that was generated, I get an error
Error:(4, 37) error: package android.support.test.espresso does not exist
Error:(5, 33) error: package android.support.test.rule does not exist
Error:(6, 35) error: package android.support.test.runner does not exist
Error:(14, 20) error: package org.hamcrest does not exist
Error:(15, 20) error: package org.hamcrest does not exist
Error:(16, 20) error: package org.hamcrest does not exist
Error:(17, 25) error: package org.hamcrest.core does not exist
Error:(18, 17) error: package org.junit does not exist
Error:(19, 17) error: package org.junit does not exist
Error:(20, 24) error: package org.junit.runner does not exist
Error:(22, 44) error: package android.support.test.espresso does not exist
Error:(22, 1) error: static import only from classes and interfaces
Error:(23, 51) error: package android.support.test.espresso.action does not exist
Error:(23, 1) error: static import only from classes and interfaces
You get the idea. I don't see any warnings or errors in Android Studio until I try to run the test.
Does anyone have an idea of what may be the problem?
Did you add forget add espresso to your dependencies ?
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
Upon further inspection, similar issue found here:
https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=98326
Their solution didn't work for me. Turns out that I head to exclude the test package from the java sourceset in the build.gradle.
sourceSets{
main {
java.srcDirs = ['src']
java.excludes = ['instrumentTest/**','test/**']
...
}
}

Migrate to Google API Client

I picked LoginActivity template from Android Studio and started working on it. When I tried to run the project it gave me following errors:
Error:(10, 37) error: cannot find symbol class GooglePlayServicesClient
Error:(12, 35) error: cannot find symbol class PlusClient
Error:(18, 44) error: package GooglePlayServicesClient does not exist
Error:(19, 33) error: package GooglePlayServicesClient does not exist
Error:(33, 13) error: cannot find symbol class PlusClient
Error:(276, 12) error: cannot find symbol class PlusClient
Error:(75, 31) error: package PlusClient does not exist
Error:(157, 65) error: package PlusClient does not exist
Error:(236, 5) error: method does not override or implement a method from a supertype
Attached is the screen shot for my Android Studio version and SDK downloaded on my machine.
I know that I need to migrate to Google API Client.
So my questions are:
Is there any document to do the same which provides step by step guide ?
Why default template provided with Android Studio are not working ?

Android cannot resolve play-services symbols

When trying to compile, I get the following errors:
Error:(59, 13) error: cannot find symbol class InstanceID
Error:(59, 37) error: cannot find symbol variable InstanceID
Error:(60, 59) error: package R does not exist
Error:(61, 21) error: cannot find symbol variable GoogleCloudMessaging
Error:(88, 9) error: cannot find symbol variable LocalBroadcastManager
Error:(117, 9) error: cannot find symbol class GcmPubSub
Error:(117, 28) error: cannot find symbol variable GcmPubSub
This is in a module, which is compiled as dependent on play-services:
com.google.android.gms:play-services:7.8.0 compile
I have tried cleaning and building, invalidating the cache and restarting. What am I missing here? Why can't it find the play-services library?

Categories

Resources