我刚刚将我的项目转换为androidx,现在收到的“程序类型已存在”错误com.google.common.util.concurrent.ListenableFuture
。
我浏览了多个stackoverflow解决方案和一些Gradle文档,但仍然无法正常工作。
问题在于,在这些模块中,Gradle引入了两个版本的ListenableFuture:
Gradle: com.google.quava:quava:23.5jre@jar
Gradle: com.google.guava:listenablefuture:1.0@jar
Run Code Online (Sandbox Code Playgroud)
我猜想我想排除第二个,但无法弄清楚该怎么做。
您可以在gradle文件中看到我尝试过的内容,但到目前为止没有任何乐趣。
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.drme.weathertest"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
// added 1/2/19 to try and prevent java.lang.NoClassDefFoundError: Failed resolution of:
// Landroid/view/View$OnUnhandledKeyEventListener;
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "26.+"
}
}
}
// resolutionStrategy.force 'com.google.quava.listenablefuture:1.0',
// 'com.google.common.util.concurrent.listenablefuture'
}
// compile('com.google.guava:listenablefuture:1.0@jar') {
// …
Run Code Online (Sandbox Code Playgroud) 我试图将两个按钮放置在约束布局的底部。在 Android Studio 的设计视图中,一切看起来都不错,但是当我在调试中运行应用程序时,按钮看起来像是与屏幕顶部的最后一个字段对齐。我已经尝试过指南和障碍,但无法让障碍在我的工作室版本(3.0.1)中工作。如果我尝试按下显示屏顶部的按钮,当我切换到横向模式时它们就会消失。有什么建议,或者我应该在这个问题上采用另一种类型的布局吗?谢谢
我的设计图
我的代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
android:id="@+id/location_detail"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="10dp"
app:layout_constraintHeight_min="?attr/actionBarSize"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/location_name_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="@+id/location_name"
android:text="@string/location_name_title"
app:layout_constraintBaseline_toBaselineOf="@+id/location_name"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guideline"/>
<EditText
android:id="@+id/location_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="13"
android:inputType="textPersonName"
app:layout_constraintLeft_toRightOf="@+id/guideline2"
app:layout_constraintTop_toBottomOf="@+id/guideline"/>
<TextView
android:id="@+id/location_region_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/location_region_title"
app:layout_constraintBaseline_toBaselineOf="@+id/location_region"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/location_name_title"/>
<TextView
android:id="@+id/location_region"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/location_detail_region"
app:layout_constraintLeft_toRightOf="@+id/guideline2"
app:layout_constraintTop_toBottomOf="@+id/location_name"/>
<TextView
android:id="@+id/location_country_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/location_country_title"
app:layout_constraintBaseline_toBaselineOf="@+id/location_country"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/location_region_title"/>
<TextView
android:id="@+id/location_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/location_detail_country"
app:layout_constraintLeft_toRightOf="@+id/guideline2"
app:layout_constraintTop_toBottomOf="@+id/location_region"/>
<TextView
android:id="@+id/location_latitude_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/location_detail_latitude" …
Run Code Online (Sandbox Code Playgroud) 我很困惑在Android Studio中添加正确的支持库以便能够使用AutoSizing TextViews.
https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview.html
此页面上对使用哪些支持库的描述有点模糊.我试图导入建议的库,但要么我请求错误的库(找不到它们,例如android.support.v4.widget包)或者我正在做其他错误的操作.
我的最小SDK为21,最大SDK为27,因此如果我导入了正确的库,则AutoSizing功能应该向后兼容我的应用程序.但是,在屏幕设计视图中,我收到警告"属性autoSizeTextType仅用于API级别26及更高级别(当前最小值为21)"
据我所知,我有正确的支持库.项目结构依赖关系如下:
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'android.arch.lifecycle:compiler:1.0.0'
implementation 'android.arch.persistence.room:runtime:1.0.0'
implementation 'android.arch.persistence.room:compiler:1.0.0'
implementation 'android.arch.paging:runtime:1.0.0-alpha4-1'
implementation 'android.arch.core:core-testing:1.0.0'
implementation 'android.arch.persistence.room:testing:1.0.0'
implementation 'android.arch.lifecycle:common-java8:1.0.0'
implementation 'com.android.support:support-v13:27.0.2'
implementation 'com.android.support:appcompat-v7:27.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2-alpha1'
implementation 'com.android.support:support-annotations:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:preference-v14:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'android.arch.lifecycle:extensions:1.1.0'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.android.support:preference-v7:27.0.0'
implementation 'com.android.support:support-compat:27.0.0'
Run Code Online (Sandbox Code Playgroud)
有什么建议?我也可以使用一些链接来了解如何将建议的库转换为要导入的实际库.谢谢
编辑:部分布局列表与android:autoSizeTextType问题.我收到了列出的两个文本视图的警告消息.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="134dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/temperature_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@string/temperature"
android:autoSizeTextType="uniform"
app:layout_constraintEnd_toStartOf="@+id/guideline"
app:layout_constraintStart_toStartOf="parent" …
Run Code Online (Sandbox Code Playgroud) android import-libraries android-layout android-support-library android-studio