user2529011
user2529011

Reputation: 743

Fighting with Unresolved class in AndroidManifest.xml

When I load up Android Studio and build my project I get a unresolved class in my manifest file.

       <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>

I also added its reference to my 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
}

I have tried cleaning and rebuilding, running my gradle file, restarting Android Studio but I am still getting that unresolved class issue. I believe it might be that CaptureActivity is no longer being used. This is just speculation. I have gone through the android developer site to see if I can find it but no such luck.

EDIT Iforgot to mention that I first saw this when I ran the code analyze. Analyze->Inspect Code. Its under Android Resource Validation.

UPDATE! Please read After making this change I seem to have an issue when I clean/rebuild my project

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

Upvotes: 1

Views: 3479

Answers (1)

5ec20ab0
5ec20ab0

Reputation: 742

Class in manifest is wrong, change it to

        <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" />

Also Better update gradle dependencies

implementation ('com.journeyapps:zxing-android-embedded:3.6.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'

Upvotes: 2

Related Questions