Unresolved reference but compiles - android

I am running into a weird issue for severals days. My code is totally compiling and working but I have two kotlin objects (not class) flagged red as unresolved reference in my code. They are in different folder path, there is other kotlin objects in these paths totally working.
I use android studio 4.1.3, my kotlin plugin is up to date, I am using kotlin 1.4.32 and use these plugins in my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
I have absolutly no idea of what is going on, someone can help me?
Thanks

Related

How to add Android plugins in build.gradle for Flutter Projects?

In android/app/build.gradle, there is no "plugins {}" block. Instead, there are some "apply plugin":
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
Now, I want to add another Android plugin, how should I do that? I've tried writing a "plugins {}" block, but that does not work. I've also tried apply plugin: 'my.plugin.name', but that also results in an error.
Is there a way that I can add custom Androids plugins into a Flutter Project?
Here is what I want: I need the google map SDK for Android in my project, which requires this plugin :'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'.
I know there is a flutter package on google map, but it does not support heat map, so I have to go native.

Why is it not recognized in main activity when I create text view?

I created a TextView inside activity_main.xml and specified an ID for it, but when I go into MainActivity and click on that ID, it does not recognize TextView, and what does the red line under everything look like? How should I solve this problem?
At gradle app
plugins {
id 'kotlin-android-extensions'
}
or
apply plugin: 'kotlin-android-extensions'
then your Activity Import this
import kotlinx.android.synthetic.main.activity_main.*
The mainActivity does not know where the txt_test is coming from so you have to give it the reference.
I would recommend either use ViewBinding or use the old:
val txt = findViewById(R.id.the_id_of_your_textView)
As indicated in one of the posts above (for kotlin)
I converted a project from java code to kotlin and had to manually add the line
apply plugin: 'kotlin-android-extensions'
to my gradle file
example:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
Edit note:
I get the complier message
The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
So evidently, Google is heading in a "view-binding" direction

Gradle test fixtures plugin for Android development

attempting to use gradle test fixtures with gradle 6.6.1, using the following set of plugins
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'org.jetbrains.kotlin.kapt'
apply plugin: 'java-test-fixtures'
produces an error along the lines of
org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method testFixturesApi() for arguments [io.kotest:kotest-property:4.3.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
(similar results for testFixturesImplementation)
Adding the java-library plugin as apparently required by the documentation:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'org.jetbrains.kotlin.kapt'
apply plugin: 'java-test-fixtures'
apply plugin: 'java-library'
yields something along the lines of
The 'java' plugin has been applied, but it is not compatible with the Android plugins.
How can I get gradle testFixtures working when building with kotlin 1.4 (and possibly kotest) for Android on Ubuntu 20.04? My overall intent is to use custom kotest generators for creating property testing fixtures shared among several testing source trees under the same app project, namely
./app/src/test/java
./app/src/androidTest/java
There are good reasons for sharing test helpers in support of code dryness; such approach is not the subject of this discussion; I am not looking for advice in that regard. The goal of this question is a manner to get testFixtures working, since I'm obviously not understanding how to do so, and your help in this direction is much appreciated. I can provide additional details if the above description, deliberately terse, is lacking in necessary detail.
They are not supported at android projects, I tested on production project, also created example projects. I have such error
Unable to find a variant of project :modtwo providing the requested
capability Fictures:modtwo-test-fixtures:unspecified
It seems they have conflicts with product flavors. Also wrong information here, because in the example it is not an android project.
apply plugin: 'java-test-fixtures'
apply plugin: 'java-library'
You don't want to put either of those plugins in your application module. The belong in the library module that's producing the fixtures.

apply plugin: 'android' or apply plugin: 'com.android.application'

As in topic. Gradle require to set up plugin and there are times that it is mentioned to apply plugin: 'android', and other to apply plugin: 'com.android.application' .
What are the differenceres? Which one should be used ?
apply plugin: 'android' specifies that It's an Android project but it does not specify Its an Application or Library project. To make life easier you can tell gradle the type of project and indicate which plugin should be used. I recommend to use apply plugin: 'com.android.application' if project is an app and apply plugin: 'com.android.library' if project is a lib. It helps gradle to compile project efficiently.
Click here for detailed explanation -
Which one should be used ?
apply plugin: 'com.android.application'
What are the differenceres?
They renamed the plugin to comply with the naming convention that Gradle is starting to adopt for plugins, with an eye towards a new plugin system in future versions of Gradle.

Android Library Project Plugin Name

in the shorter history the Android Gradle based builds need change the names for the plugins.
Like
apply plugin: 'com.android.application'
Anyone can tell me the new plugin name for library projects ?
apply plugin: 'com.android.library'

Categories

Resources