相关疑难解决方法(0)

什么是AndroidX

我正在阅读关于Android的房间库.我看到他们改变包装androidandroidx.我不明白.请有人解释一下.

implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
Run Code Online (Sandbox Code Playgroud)

即使这也适用于android包装.

implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
Run Code Online (Sandbox Code Playgroud)
  • 需要什么来包装新的支持库androidx而不是android.
  • 用例和影响现有项目的因素.

android android-architecture-components android-jetpack androidx

204
推荐指数
8
解决办法
10万
查看次数

Android Material和appcompat Manifest合并失败

我有下一个年级

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.material:material:1.0.0-rc01'
}
Run Code Online (Sandbox Code Playgroud)

但是当我想构建应用程序时,我会得到下一个日志:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0-alpha3] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.
Run Code Online (Sandbox Code Playgroud)

好! 去清单并执行:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="ru.chopcode.myapplication">

    <application
        tools:replace="android:appComponentFactory"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

然后我在Logcat中收到此错误:

Manifest merger failed with multiple errors, see logs that I have …
Run Code Online (Sandbox Code Playgroud)

android build.gradle android-gradle-plugin gradle-plugin

193
推荐指数
19
解决办法
29万
查看次数

错误:程序类型已存在:android.support.design.widget.CoordinatorLayout $ Behavior

我在构建项目时遇到以下错误.在这个项目中没有使用CoordinatorLayout.刚刚在build.gradle中添加为依赖项:

我使用的是Android Studio 3.2 Canary 4.

logcat的

AGPBI:{"kind":"error","text":"程序类型已存在:android.support.design.widget.CoordinatorLayout $ Behavior","sources":[{}],"tool":"D8" }:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED FAILURE:构建因异常而失败.*出了什么问题:任务执行失败':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

com.android.builder.dexing.DexArchiveMergerException:合并dex存档时出错:/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/0.jar,/ windows/Other/app/build/intermediates/transforms/dexBuilder/debug/1.jar,/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/4.jar,.....................

/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/294.jar

程序类型已存在:android.support.design.widget.CoordinatorLayout $ Behavior

的build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "com.dagkot"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "BASE_URL", "\"http://api.openweathermap.org/data/2.5/\""
            buildConfigField "String", "API_KEY", "\"435e9075f348868c2714fe7c6895efa5\""
        }
        debug {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        buildConfigField "String", …
Run Code Online (Sandbox Code Playgroud)

android kotlin dagger-2 android-coordinatorlayout

127
推荐指数
9
解决办法
17万
查看次数

API 28(P)的Android设计支持库无法正常工作

我已经成功配置了android-P SDK环境.当我尝试使用android设计支持库时,我面临项目构建错误.项目配置是:

IDE:3.2 Canary 17目标API:28编译API:28

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.app.navigationpoc"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.1'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'

    implementation 'com.android.support:design:28.0.0-alpha3'
    implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
}
Run Code Online (Sandbox Code Playgroud)

并且构建失败的错误是:

清单合并失败:来自[androidx.core:core:1.0.0-alpha3] AndroidManifest.xml:22:18-86的属性应用程序@ appComponentFactory值=(androidx.core.app.CoreComponentFactory)也出现在[com.android] .support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91 value =(android.support.v4.app.CoreComponentFactory).建议:在AndroidManifest.xml:6:5-40:19中添加'tools:replace ="android:appComponentFactory"'来覆盖.

android android-studio android-design-library android-9.0-pie

90
推荐指数
10
解决办法
15万
查看次数

使用Dagger 2注入Androidx片段

我想用dagger 2注入我的Androidx片段.在我的活动中我有:

  public class MainActivity extends AppCompatActivity implements HasSupportFragmentInjector
{
    @Inject Reposetory reposetory;
    @Inject DispatchingAndroidInjector<androidx.fragment.app.Fragment> dispatchingAndroidInjector;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public AndroidInjector<androidx.fragment.app.Fragment> supportFragmentInjector()
    {
        return dispatchingAndroidInjector;
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是,当我想要构建项目时,我收到此错误:

error: cannot find symbol class MapBuilder
Run Code Online (Sandbox Code Playgroud)

当我在DispatchingAndroidInjector 中将androidx.fragment.app.Fragment更改为Fragment时,我不再收到此错误.

android dependency-injection dagger dagger-2

12
推荐指数
3
解决办法
5931
查看次数

AndroidX迁移依赖/库

我已成功将项目迁移到AndroidX.应用程序运行正常,但我收到编译时错误,因为我的依赖项使用支持包.

此搜索

图像2

这个错误的原因

因为PhotoView是一个依赖类,它使用的android.support.v7.widget.AppCompatImageView是我的项目中不再可用的.因为它现在androidx.appcompat.widget.AppCompatImageView

项目还在运行吗?

是的,android.enableJetifier将此依赖项转换AndroidX为运行时,但我想摆脱编译时错误.

现在有快速解决方案吗?

android androidx android-jetifier

9
推荐指数
2
解决办法
6001
查看次数

重复类 com.google.android.exoplayer2.ui.DownloadNotificationHelper

当我尝试运行我的 flutter 应用程序时出现此错误:

警告:将新的 ns http://schemas.android.com/repository/android/common/02映射到旧的 ns http://schemas.android.com/repository/android/common/01 警告:映射新的 ns http:// /schemas.android.com/repository/android/generic/02到旧 ns http://schemas.android.com/repository/android/generic/01 警告:映射新 ns http://schemas.android.com/sdk /android/repo/addon2/02到旧 ns http://schemas.android.com/sdk/android/repo/addon2/01 警告:映射新 ns http://schemas.android.com/sdk/android/repo /repository2/02到旧的 ns http://schemas.android.com/sdk/android/repo/repository2/01 警告:映射新的 ns http://schemas.android.com/sdk/android/repo/sys-img2 /02到旧 NS http://schemas.android.com/sdk/android/repo/sys-img2/01

失败:构建失败并出现异常。

  • 出了什么问题:任务“:app:checkDebugDuplicateClasses”执行失败。

执行 com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable 时发生故障 在模块 jetified-exoplayer-core-2.17.0-runtime (com.google. android.exoplayer:exoplayer-core:2.17.0) 和 jetified-exoplayer-ui-2.15.0-runtime (com.google.android.exoplayer:exoplayer-ui:2.15.0)

请参阅文档了解如何修复依赖项解析错误。

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

1m 47s 内构建失败异常:Gradle 任务 assembleDebug 失败,退出代码为 1

我该如何修复这个错误?以下是我的 build.gradle 文件:

应用程序\build.gradle

def localProperties = new Properties()
def localPropertiesFile = …
Run Code Online (Sandbox Code Playgroud)

java android gradle android-studio flutter

8
推荐指数
1
解决办法
4626
查看次数

Android X向后兼容

我有使用支持库版本27.1.2的Android App。我想使用一个使用Android X(api 28)编写的库。

库版本的名称间距几乎没有问题。

例子...

库中有一个我想与api一起使用的对话框

Dialog.show(androidx.fragment.app.FragmentActivity activity);
Run Code Online (Sandbox Code Playgroud)

但是我所有的活动都在使用

android.support.v4.app.FragmentActivity
Run Code Online (Sandbox Code Playgroud)

并且编译器不喜欢这样。

当前无法将我的项目升级到最新版本,因此,除非这是唯一的解决方案,否则请不要升级答案。

有没有解决此不兼容问题的方法?

提前致谢。

android backwards-compatibility gradle androidx

6
推荐指数
1
解决办法
650
查看次数