Unresolved reference: TextField (Material3) - android

May I use TextField with Material3? I was trying but I got this error: "Unresolved reference: TextField".
I added both libraries:
implementation "androidx.compose.material:material:1.3.1"
implementation 'androidx.compose.material3:material3:1.0.0-alpha02'
And I also imported them into my source code:
import androidx.compose.material.*
import androidx.compose.material3.*
Thanks for your help!

Related

How to resolve 'None of the following candidates is applicable because of receiver type mismatch' for material icons in compose

I'm using compose3 and dolphin Android Studio on Gruda Linux. All updated!
I have a #Composable function called feed which just have a FilledTonalButton.
For the content of FilledTonalButton I'm giving the icons.rounded.Add
Whenever I'm building, it gives me
e: /home/kumar-p/Desktop/AndroidStudio/<app_name>/app/src/main/java/com/f/rateme/MainActivity.kt: (95, 27): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val Icons.Rounded.Add: ImageVector defined in androidx.compose.material.icons.rounded
<app_name> = my app name, removed because of confidentiality.
However when I replace the Icon() with Text(), it works!
My dependencies:
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-alpha02'
implementation "androidx.compose.material:material-icons-extended:$compose_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
My imports on MainActivity.kt
package com.<example>.rateme // <example> = my company name
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.*
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material3.*
//import androidx.compose.material.icons.Icons
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.<example>.<app_name>.ui.theme.AppTheme // <example> = my company name, <app_name> = name of curent app
The function:
#Composable
fun feed(page: String): String {
FilledTonalButton(
onClick = {/*TODO: Add onClick for feed - New Post*/},
enabled = true) {
Icon(
imageVector = Add,
"New Post"
)
}
return page // TODO: implement the changes of page variable
}
If you find any typo please update it or tell me to fix.
PS: This is my first time here and I have an almost zero experience on android development and Kotlin. I developed terminal apps and worked on ML kinda work in Python, C++, C. So I may need more information in explanation. I started learning Android Development a week ago only.
Edit: You can ask me any more information.
Peace
Just specify the actual imageVector like this,
Icon(
imageVector = Icons.Default.Add
"New Post"
)
but you will still get ambiguity error. Since based on your post it looks like you want to use material3, just remove this import
import androidx.compose.material.* // remove this
or if you still want to use them both, you'll then have to declare their fully qualified name on usage,
androidx.compose.material3.Icon(
imageVector = Icons.Default.Add,
"New Post"
)

Cannot import getSignInClient method in Android Studio 4.2.2

In my Class that extends AppCompatActivity
import com.google.android.gms.auth.api.identity.Identity.getSignInClient;
cannot resolve symbol getSignInClient that appears in red.
In Gradle is put
implementation platform('com.google.firebase:firebase-bom:28.1.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-database:20.0.0'
implementation 'com.google.firebase:firebase-storage:20.0.0'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
So, the code has an error on this line
oneTapClient = ContactsContract.CommonDataKinds.Identity.getSignInClient(this);
oneTapClient is declare as follows:
private SignInClient oneTapClient;
where is the mistake ?
I had same issue before
check your imports and remove
import android.provider.ContactsContract; this
and use the following
import com.google.android.gms.auth.api.identity.Identity;
oneTapClient = Identity.getSignInClient(this);
or just use it like this
oneTapClient = com.google.android.gms.auth.api.identity.Identity.getSignInClient(this);

FirebaseRecyclerOptions throwing error

I have added import import com.firebase.ui.database.FirebaseRecyclerAdapter; and
compile 'com.firebaseui:firebase-ui-database:0.4.0'
compile'com.firebaseui:firebase-ui-database:1.1.1'
in my grade files
Still, I am unable to use FirebaseRecyclerOptions
Thanks in advance :)
Gradle dependencies

osmdroid setUserAgentValue Cannot resolve Method

I have used this tutorial: https://github.com/osmdroid/osmdroid/wiki/How-to-use-the-osmdroid-library
But the Map doesn't show and I get an error: setUserAgentValue Cannot resolve Method
In this Line:
org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID);
I have imported this:
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.views.MapView;
And in my Gradle this:
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'org.osmdroid:osmdroid-android:4.3'
osmdroid4.3 is out of date, and was not supporting setUserAgent.
Upgrade to the latest version, replace with:
compile 'org.osmdroid:osmdroid-android:5.4.1:release#aar'

com.google.android.gms.drive.DriveApi.ContentsResult cannot be resolved... But everything else can be?

I'm getting this error:
com.google.android.gms.drive.DriveApi.ContentsResult cannot be resolved
But just with that one import. These all work:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.drive.Contents;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveFile;
import com.google.android.gms.drive.DriveFolder.DriveFileResult;
import com.google.android.gms.drive.MetadataChangeSet;
And for some reason ContentsResult can't be found. Even doing this works:
import com.google.android.gms.drive.DriveApi.*;
And it works in the sense that it doesn't error on the import, but when I do that, ContentsResult still just cannot be found...
Has anyone had this issue before?
There is no ContentsResult class in the DriveApi package, but there is a DriveContentsResult class:
com.google.android.gms.drive.DriveApi.DriveContentsResult
See http://developer.android.com/reference/com/google/android/gms/drive/package-summary.html
The answer 'myanimal' gave you is correct. You are probably using some older version of GDAA code, since 'ContentsResult' used to be there see here. Please make also sure you are compiling with the latest 'play-services:6.5.87'. I'm not sure it you are using Android Studio. If yes, see if your 'build.gradle' config file has the dependencies right:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
....
....
}
Disclaimer: It is not a 'better' answer, just an extension of "myanimal's" answer below.

Categories

Resources