当我加载Android Studio并构建项目时,清单文件中出现了一个未解决的类。
<activity
android:name="com.google.zxing.client.android.CaptureActivity" //THIS IS WHERE THE ERROR POINTS TO
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="google.zxing.client.android.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
我还将其引用添加到我的build.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:28.0.0-rc01'
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
implementation 'com.google.zxing:core:3.3.2'
//...More dependencies below
}
我尝试清理和重建,运行gradle文件,重新启动Android Studio,但仍然遇到未解决的类问题。我相信可能不再使用CaptureActivity。这只是猜测。我已经遍历了android开发者网站,看是否可以找到它,但没有运气。
编辑 Iforgot提到我在运行代码分析时首先看到了这一点。 分析->检查代码。在Android资源验证下。
更新!请阅读 进行此更改后,清理/重建项目时似乎遇到了问题
D:\Foo_Workspace\Library Build\Foo\mobile\src\main\AndroidManifest.xml:151:13-50 Error:
Attribute activity#com.journeyapps.barcodescanner.CaptureActivity@screenOrientation value=(landscape) from [:Foo] AndroidManifest.xml:151:13-50
is also present at [com.journeyapps:zxing-android-embedded:3.0.2] AndroidManifest.xml:51:13-56 value=(sensorLandscape).
Suggestion: add 'tools:replace="android:screenOrientation"' to <activity> element at AndroidManifest.xml:148:9-164:20 to override.
D:\Foo_Workspace\Library Build\Foo\mobile\src\main\AndroidManifest.xml:152:13-71 Error:
Attribute activity#com.journeyapps.barcodescanner.CaptureActivity@theme value=(@android:style/Theme.NoTitleBar.Fullscreen) from [:Foo] AndroidManifest.xml:152:13-71
is also present at [com.journeyapps:zxing-android-embedded:3.0.2] AndroidManifest.xml:53:13-54 value=(@style/zxing_CaptureTheme).
Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:148:9-164:20 to override.
:mobile:processDebugManifest
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
:mobile:processDebugManifest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mobile:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
答案 0 :(得分:2)
清单中的类错误,将其更改为
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden"
tools:replace="screenOrientation,android:theme" />
还可以更好地更新gradle依赖项
implementation ('com.journeyapps:zxing-android-embedded:3.6.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'