gpt4 book ai didi

android - 无法解析声明 android.support.v4.content.LocalBroadcastManager 上的 import LocalBroadcastManager;

转载 作者:行者123 更新时间:2023-12-02 06:36:22 31 4
gpt4 key购买 nike

我在将 Eclipse 项目导入 Android Studio 时遇到此错误。它显示了一条建议将库 Gradle: com.android.support:support-core-utils-27.1.1 添加到类路径。我已将库添加到我的 build.gradle 文件中。

这是我的 gradle 文件。

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "28.0.0"

defaultConfig {
applicationId "com.example.tracking"
minSdkVersion 17
targetSdkVersion 27
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}

allprojects {
repositories {
google()

}
}

dependencies {


implementation project(':asciiProtocol')
implementation project(':deviceList')
implementation project(':captureActivity')
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation "com.android.support:support-core-utils:27.1.1"
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.google.code.gson:gson:2.8.2'
implementation files('libs/opencsv-2.3.jar')
implementation files('libs/rfid.reader.api.jar')
implementation files('libs/scannercontrol.jar')
implementation files('libs/Zebra.jar')

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '27.1.1'
}
}
}
}
}

我用谷歌搜索了它,但找不到合适的解决方案。但是,我尝试了 this 中的解决方案这不是正确的解决方案。感谢任何帮助吗?

最佳答案

我遇到了同样的问题,然后我注意到 Google 将 v4 支持库划分为多个包。

Note: Prior to Support Library revision 24.2.0, there was a single v4 support library. That library was divided into multiple modules to improve efficiency. For backwards compatibility, if you list support-v4 in your Gradle script, your APK will include all of the v4 modules. However, to reduce APK size, we recommend that you just list the specific modules your app needs.

https://developer.android.com/topic/libraries/support-library/packages#v4

然后我检查了 LocalBroadcast 页面。 https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager

页面顶部有说明

belongs to Maven artifact com.android.support:localbroadcastmanager:28.0.0-alpha1

当我遇到这个问题时,v28.0.0(不是alpha)已经可用。

最后,我更改了 build.gradle 中的设置。

之前

implementation 'com.android.support:support-v4:28.0.0'

之后

implementation 'com.android.support:localbroadcastmanager:28.0.0'

AndroidX

implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'

关于android - 无法解析声明 android.support.v4.content.LocalBroadcastManager 上的 import LocalBroadcastManager;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51097099/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com