我有这个编译错误!我在stackoverflow上检查了类似的问题但是所有这些都是关于不同的错误而不是"attr/orientation"with config''",但它们对我的问题不起作用!我正在使用androidx库,kotlin,Gradle 4.10.1,
我做了这些步骤,但仍然没有结果:
1-清洁项目
2-重建
3-使高速缓存/重新启动无效
4-在文件夹上创建了另一个attrs.xml文件:res-> values-v21
5-其他许多方式......
但他们都失败了!有解决方案吗
使用Android Studio将项目迁移到AndroidX(并手动修复了很多导入错误)后,我没有遇到编译错误,但是当应用启动时,我崩溃了:
Error inflating class android.support.design.widget.AppBarLayout。
布局文件中有问题的行是:
<android.support.design.widget.AppBarLayout
我的依赖项build.gradle是:
dependencies {
def lifecycle_version = '2.1.0-alpha02'
// used below--will be different for androidx (migrated 2019-02-04)
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha03'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okio:okio:1.15.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0'
// Relay class
implementation 'com.jakewharton.rx2:replaying-share:2.1.0'
// ReplayingShare
implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0'
// RxBinding
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" // see def above
// includes ViewModel and LiveData …Run Code Online (Sandbox Code Playgroud) 我在这里遵循开发指南:
https://developer.android.com/guide/components/activities/testing
并有一个测试类,如:
@RunWith(AndroidJUnit4::class)
class MyTestSuite {
@get:Rule var activityScenarioRule = activityScenarioRule<MyActivity>()
@Test fun testEvent() {
val scenario = activityScenarioRule.scenario
}
}
Run Code Online (Sandbox Code Playgroud)
该方法activityScenarioRule<T>()未定义。我需要什么依赖?另外,在阅读这些文档时确定要添加哪些依赖项的最佳方法是什么?
所以最新的更新来自
到
我收到错误:
FragmentXY 在创建后尝试 registerForActivityResult。片段必须在创建之前调用 registerForActivityResult()(即初始化、onAttach() 或 onCreate())。
在向用户显示有关这些权限的使用以及为什么需要这些权限的信息后,我曾经在我的 StartFragment(单个活动应用程序,在 onViewCreated 中)中检查权限。在过去的 3(?) 个月里,一切都运行良好。
我在变更日志中看到:
行为改变
[...]
Calling registerForActivityResult() after onCreate() now throws an exception indicating that this is not allowed rather than silently failing to deliver results after a configuration change. (b/162255449) "
I downgraded back to version 1.3.0-alpha07 for the moment.
But if I need registerForActivityResult in my Fragments AFTER the view is created (e.g. for permissions), how can …
permissions android-fragments androidx registerforactivityresult
当我将项目转换为AndroidX时,我遇到了
error: package android.support.design.R does not exist
android.support.design.R.styleable.FloatingActionButton_Behavior_Layout);
Run Code Online (Sandbox Code Playgroud)
有什么线索怎么解决呢?
所以我试图按照谷歌的说明来测试我的活动:https : //developer.android.com/guide/components/activities/testing
但是代码launchActivity<MyActivity>() 不起作用。我是否需要将 launchActivity 定义为规则,或者是否需要在 gradle 中导入一个库?
这些是我已经拥有的进口
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
Run Code Online (Sandbox Code Playgroud) 我的问题是我想在我的 Application 中添加一个 PreferenceScreen,但我不能使用它,我不知道为什么。
我实现了库androidx.preference:preference:1.1.0-rc01。然后我想将 PreferenceScreen 添加到我的 XML 布局中,但它没有提出任何建议。
接下来,我将来自 Android-Developers 的 XML 代码复制到我的 XML 布局中并对其进行编译,但是通过启动活动,它因错误而中断: java.lang.ClassCastException: class androidx.preference.PreferenceScreen cannot be cast to android.view.View
有人可以帮我androidx.preference.PreferenceScreen正确使用吗?
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<androidx.preference.SwitchPreference
android:defaultValue="true"
android:key="example_switch"
android:summary="Turn this option on or off"
android:title="Settings option" />
</androidx.preference.PreferenceScreen>
Run Code Online (Sandbox Code Playgroud) 我的应用程序需要一个 ProgressBar,我正在尝试使用 Jetpack Compose 来实现它,所以要么我需要一个内置的 ProgressBar 支持(我没有找到它),要么应该有一种机制来使用 Compose 显示普通的 Android 小部件。这有可能吗?
android android-progressbar kotlin androidx android-jetpack-compose
我在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)