Questions tagged «androidx»

代表Android支持库的新的Android扩展库(AndroidX)。

10
什么是AndroidX?
我正在阅读有关Android房间库的信息。我看到他们将软件包更改android为androidx。我不明白。有人可以解释一下吗? implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version" android包也提供此功能。 implementation "android.arch.persistence.room:runtime:$room_version" annotationProcessor "android.arch.persistence.room:compiler:$room_version" 有什么需要打包新的支持库androidx而不是android? 现有项目中的用例和影响因素。

8
不推荐使用AndroidJUnit4.class:如何使用androidx.test.ext.junit.runners.AndroidJUnit4?
我在进行仪器测试时 @RunWith(AndroidJUnit4.class) 从 import androidx.test.runner.AndroidJUnit4; 为了建立我的测试用例。现在,这条线被标记为与提示使用过时AndroidJUnit4的 import androidx.test.ext.junit.runners.AndroidJUnit4 但是,如果我尝试AndroidJUnit4从命名包中导入,ext则会出现错误,无法解决。 您有什么想法,应在gradle中包括哪些软件包来解决此问题?


15
迁移到AndroidX时无法解析变量'$ {animal.sniffer.version}'
我正在使用Android Studio 3.2 Beta5将我的项目迁移到AndroidX。重建应用程序时,出现以下错误: 错误:[TAG]无法解析变量'$ {animal.sniffer.version}' 错误:[TAG]无法解析变量'$ {junit.version}' 全面清理和重建无济于事!有人知道怎么修这个东西吗? gradle.properties android.enableJetifier=true android.useAndroidX=true build.gradle buildscript { repositories { google() jcenter() mavenCentral() maven { url 'https://maven.fabric.io/public' } maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } dependencies { classpath 'com.android.tools.build:gradle:3.2.0-beta05' classpath 'com.google.gms:google-services:4.0.1' classpath "io.realm:realm-gradle-plugin:5.3.1" classpath 'io.fabric.tools:gradle:1.25.4' classpath 'com.google.firebase:firebase-plugins:1.1.5' } } allprojects { repositories { google() …

7
AndroidX:Appcompat I:艺术错误android.view.View $ OnUnhandledKeyEventListener
在一个使用Androidx:appcompat:appcompat:1.0.0-rc01新建的项目中, java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList 我还添加了configuration.all configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == "androidx.appcompat") { if (!requested.name.startsWith("multidex")) { details.useVersion "1.+" } } } } 这不影响应用程序功能或崩溃。但是在应用程序运行时始终会出现此错误。请帮助我解决错误。整个堆栈跟踪如下。 I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener; I/art: at …
105 android  androidx 

9
给定的工件包含一个字符串文字,其字符串包参考'android.support.v4.content'无法安全地重写。对于androidx
我升级了我的软件android studio to 3.4 canary,由于以下错误,我现在无法成功构建: The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx. 更多细节: Caused by: java.lang.RuntimeException: Failed to transform '.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/9.0.0-SNAPSHOT/732f93940c74cf32a7c5ddcc5ef66e53be052352/butterknife-compiler-9.0.0-SNAPSHOT.jar' using Jetifier. Reason: …

6
什么是Jetifier?
什么是Jetifier?例如,要使用androidx打包的依赖项创建新项目,此新项目需要将以下行添加到gradle.properties文件中: android.enableJetifier=true 那是什么意思-“启用喷射器”?

3
BottomSheetBehavior不在androidX库中
我BottomSheetBehavior在原始支持库中使用: implementation 'com.android.support:design:27.1.1' 当我迁移使用新androidx库时,尽管BottomSheetBehavior缺少了。以上支持库中的映射也不在AndroidX重构列表中,但迁移工具已将其删除。 我缺少将BottomSheetBehavior包含在新androidx库中的功能。 dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.google.android.material:material:1.0.0-beta01' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // ReactiveX implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0' implementation 'com.android.support:design:28.1.0' // Android Compatability Libraries // Version: https://developer.android.com/topic/libraries/support-library/refactor implementation 'androidx.appcompat:appcompat:1.0.0-beta01' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha1' implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01' implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-beta01' implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01' // Android Navigation Component // Check here for updated …

17
迁移到androidx后,膨胀类androidx.constraintlayout.ConstraintLayout时出错
我刚刚通过Android Studio菜单选项Refactor- > Refactor to AndroidX迁移到androidx 我收到以下错误: android.view.InflateException:二进制XML文件第2行:二进制XML文件第2行:错误膨胀了类androidx.constraintlayout.ConstraintLayout 任何的想法? 堆栈跟踪: 2018-10-19 00:25:58.128 28131-28131/com.midounoo.midounoo E/AndroidRuntime: FATAL EXCEPTION: main Process: com.midounoo.midounoo, PID: 28131 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.midounoo.midounoo/com.midounoo.midounoo.Base.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527) …
87 android  androidx 


6
在模块类中找到重复的类android.support.v4.app.INotificationSideChannel?
我正在开发新闻应用程序,但是从gradle控制台中收到以下错误 (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.os.IResultReceiver found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0) Duplicate …
75 gradle  chat  androidx 

9
Android X:tools:replace在属性行指定:但未指定新值
我已经在该网站上尝试了许多解决方案,但是仍然无法解决问题。该问题归因于Android X库。当我添加Android X时,此问题已解决,但打开了新问题。如何解决这个问题? 较早出现此错误: 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:19:5-142:19 to override. 添加完后tools:replace="android:appComponentFactory",出现此错误: java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs at com.android.builder.core.AndroidBuilder.mergeManifestsForApplication(AndroidBuilder.java:540) at com.android.build.gradle.tasks.MergeManifests.doFullTaskAction(MergeManifests.java:173) 合并错误(在Android清单中): 错误:在属性:android:appComponentFactory的第2行指定了tools:replace,但未在应用主清单(此文件)的第1行中指定新值 表现: <?xml version="1.0" …

2
Android:已弃用的不能转换为注释
不再是迁移到AndroidX的烦恼... 我几乎完成了迁移,但是遇到了一个似乎无法逾越的错误。 已经尝试Clean & Rebuild和Invalidate Caches / Restart 似乎是将@Deprecated注入​​到无法识别的R.java文件中。 该应用程序的build.gradle文件很长,但是这里有相关部分(如果相关,可以发布更多内容): android { compileSdkVersion 29 defaultConfig { minSdkVersion 17 targetSdkVersion 29 } compileOptions { dataBinding { enabled = true } } dependencies { ... implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.2.0-alpha01' def rxlifecycleVersion = "3.1.0" implementation "io.reactivex.rxjava3:rxjava:3.0.0-RC4" implementation "com.trello.rxlifecycle3:rxlifecycle:$rxlifecycleVersion" implementation "com.trello.rxlifecycle3:rxlifecycle-kotlin:$rxlifecycleVersion" implementation "com.trello.rxlifecycle3:rxlifecycle-android:$rxlifecycleVersion" implementation …

2
如何使用Dagger 2在ViewPager中注入相同片段的ViewModel
我正在尝试将Dagger 2添加到我的项目中。我能够为片段注入ViewModels(AndroidX体系结构组件)。 我有一个ViewPager,它具有2个相同片段的实例(每个选项卡只有一个小的更改),并且在每个选项卡中,我正在观察一个LiveData以获取有关数据更改的更新(从API)。 问题在于,当api响应出现并更新时LiveData,当前可见片段中的相同数据将发送给所有选项卡中的观察者。(我认为这可能是因为的范围ViewModel)。 这就是我观察数据的方式: override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) activityViewModel.expenseList.observe(this, Observer { swipeToRefreshLayout.isRefreshing = false viewAdapter.setData(it) }) .... } 我正在使用此类提供ViewModel: class ViewModelProviderFactory @Inject constructor(creators: MutableMap<Class<out ViewModel?>?, Provider<ViewModel?>?>?) : ViewModelProvider.Factory { private val creators: MutableMap<Class<out ViewModel?>?, Provider<ViewModel?>?>? = creators override fun <T : ViewModel?> create(modelClass: Class<T>): T { var …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.