我在Android Studio中有一个Flutter项目。我正计划迁移到AndroidX。每当我进行重构->迁移到AndroidX时,Android Studio都会显示错误消息:
您需要在模块build.gradle中将compileSdk设置为至少28,才能迁移到AndroidX。
但是,我已经在我的app / gradle.build文件中设置了compileSdkVersion 28。
我还有什么需要做的吗?
我正在尝试使用androidX espresso库通过工具测试来测试我的UI。在我的年级,我有:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"
android {
compileSdkVersion 28
defaultConfig {
applicationId "it.zehus.mybike"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
android.defaultConfig.manifestPlaceholders = ['appAuthRedirectScheme': 'net.openid.appauthdemo']
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def lifecycle_version = "2.0.0"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
// room persistence library
def room_version = "2.1.0-alpha04"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version" // use …Run Code Online (Sandbox Code Playgroud) 今天我刚刚更新了我dependencies的material design
从1.0.0到1.1.0-alpha09
implementation 'com.google.android.material:material:1.1.0-alpha09'
Run Code Online (Sandbox Code Playgroud)
现在我遇到了奇怪的问题 com.google.android.material.textfield.TextInputLayout
这是我的代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/emailTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10sdp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/emailTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_enter_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
更新依赖项后,我在我的 TextInputLayout
上面代码的输出
如果我使用implementation 'com.google.android.material:material:1.0.0'我会得到预期的结果
谁能帮我解决这个问题
如果需要更多信息,请告诉我。提前致谢。您的努力将不胜感激。
更新
我已经试过
app:boxBackgroundMode="none"了,我得到了这个
,
如果我使用
app:boxBackgroundMode="outline"然后得到这个

无需使用 boxBackgroundMode
你需要@style/Widget.Design.TextInputLayout在你的TextInputLayout
示例代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/emailTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10sdp"
style="@style/Widget.Design.TextInputLayout"
app:errorTextAppearance="@style/error_appearance"
android:textColorHint="@android:color/white">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:id="@+id/emailTextInputEditText"
android:layout_height="wrap_content"
android:backgroundTint="@android:color/white"
android:gravity="center"
android:hint="@string/hint_enter_email"
android:imeOptions="actionNext"
android:textColorHint="@android:color/white"
android:inputType="textEmailAddress"
android:textColor="@android:color/white"
android:textSize="@dimen/_15ssp"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
android android-layout material-design android-textinputlayout androidx
在 Jetpack Compose 中,如何在仅布置可见项目的同时显示大数据列表,而不是在初始布局过程中组合和布置每个项目?这将是类似RecyclerView与ListView在View工具包。
可以使用for循环将 aColumn中的所有组件放在 a中VerticalScroller,但这会导致丢帧和大量项目的性能不佳。
注意:这是一个规范的自我回答问题,以抢先/处理类似的问题
android kotlin android-jetpack androidx android-jetpack-compose
Use legacy android.support libraries创建新项目时是否应该选择该选项?如果我不选择此选项会怎样?

任何人都可以帮助我如何将setFragmentResult 和 setFragmentResultListener导入到我的项目中?
我已经实现了 'androidx.fragment:fragment-ktx:1.2.5' 但它似乎不是正确的包。
该注释@RequiresApi有助于要求仅在给定的 API 级别或更高级别上调用带注释的元素。然而,似乎没有相应的注释来要求仅在给定的 API 或更低版本上调用带注释的元素。
例如,给出类似的内容:
@RequiresMaxApi(28) // or @DeprecatedSinceAndroid(29)
fun doSomethingWithExternalStorage() {
val dir = Environment.getExternalStorageDirectory() // This is deprecated in API 29
// ...
}
Run Code Online (Sandbox Code Playgroud)
doSomethingWithExternalStorage()从不包含检查的代码调用,例如:
if (VERSION.SDK_INT < 29) {
doSomethingWithExternalStorage()
}
Run Code Online (Sandbox Code Playgroud)
如果没有上述 API 检查,doSomethingWithExternalStorage()将显示 lint 错误/警告,类似于如何@RequiresApi显示。
据我了解,这也和工作原理类似@DeprecatedSinceKotlin。
是否有现有的注释可以满足这些要求,或者是否有其他方法可以达到预期的结果?
android backwards-compatibility android-appcompat android-annotations androidx
我刚刚将Android Studio更新到版本3.2并按照说明使用androidx.
我一直在Fragment活动中使用Youtube片段,一切都运行得很好但是,在更新之后,这3条简单的行现在给我错误"无法解析方法'添加(...)'":
YouTubePlayerSupportFragment youTubePlayerFragment = YouTubePlayerSupportFragment.newInstance();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.youtube_fragment, youTubePlayerFragment).commit();
Run Code Online (Sandbox Code Playgroud)
...当我尝试使用"替换"而不是"添加"时,它说:"错误的第二个参数类型.发现:'com.google.android.youtube.player.YouTubePlayerSupportFragment',必需:'androidx.fragment.app .分段'"
...这让我觉得问题与新的AndroidX功能有关.
问题是add方法需要第二个类型的参数:
androidx.fragment.app.Fragment
Run Code Online (Sandbox Code Playgroud)
...但是YouTubePlayerSupportFragment会返回:
android.support.v4.app.Fragment
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?有没有办法将"android.support.v4.app.Fragment"强制转换为"androidx.fragment.app.Fragment"?
我刚刚创建了一个新的flutter项目,添加了一些插件,并且我将插件切换到了android x,因此我需要切换到android x。我尝试了所有不同的方法来迁移到android x,到目前为止,没有一种方法对我有用。现在,我什至不知道该怎么办,它是如此令人沮丧,为什么在自动创建新项目时不那么处理。可能在项目中使用离子。
在React Native项目上工作,但是突然间它停止工作并开始出现错误:
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add ‘tools:replace=“android:appComponentFactory”’ to <application> element at AndroidManifest.xml:7:5-117 to override.
Run Code Online (Sandbox Code Playgroud)
我知道Google在28岁以后就完成了支持库类,并且我知道如何将整个项目从支持库类迁移到AndroidX类。
我的问题是:
有什么办法可以继续使用支持库类,而不是转移到AndroidX类?
如何解决这个问题?
androidx ×10
android ×8
flutter ×2
kotlin ×2
legacy-code ×1
react-native ×1
testing ×1
youtube ×1