Android Studio 3.1 does not render xml file due to a java class missing

后端 未结 5 1268
余生分开走
余生分开走 2020-12-29 09:55

Always shows me the error in the massages

java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener

My pr

相关标签:
5条回答
  • 2020-12-29 10:35

    Yes, it happens. You can fix it easily.

    First Method: Open build.gradle(Module: app) under Gradle Scripts and change version alpha3 to alpha1 and Sync now

    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

    Second Method: Open style.xml under res -> values -> style.xml and change this line

    style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    

    put Base. before Theme.AppCompat.Light.DarkActionBar like

    style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    

    Hope problem will be solved.

    0 讨论(0)
  • 2020-12-29 10:39

    Use:

    implementation 'com.android.support:appcompat-v7:27.1.1'
    

    and of course

    compileSdkVersion 27
    

    Until version 28 full ver comes!

    0 讨论(0)
  • 2020-12-29 10:48

    - Use Alpha/Beta at your Own Risk

    • You are developing an app, so you don't want to face these types of issues. So I suggest you use always stable version of every dependency.

    The issue you faced was due to using alpha version of AppCompat library. Use stable version to get rid of this issue now and in future.

    1. Use android.support stable version

    Currently 27.1.1 is latest version of AppComactV7. You can see Maven Repo link to find out latest.

    final def SUPPORT_VERSION = "27.1.1"
    implementation "com.android.support:appcompat-v7:$SUPPORT_VERSION"
    implementation "com.android.support:design:$SUPPORT_VERSION" // use only if already using
    

    I use definitions to have same version for all support versions. Also ignore design library if you are not already using it.

    2. Downgrade compileSdkVersion and targetSdkVersion (Optional)

    You also need to downgrade your compileSdkVersion & targetSdkVersion to remove some gradle warnings.

    so use below versions

    compileSdkVersion 27 
    targetSdkVersion 27
    

    Read about Alpha & Beta releases.

    0 讨论(0)
  • 2020-12-29 10:52

    You can fix it easily.

    Open build.gradle(Module: app) under Gradle Scripts and update the version of appcompat to given below and Sync now

    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
    
    0 讨论(0)
  • 2020-12-29 10:56

    Go to
    Gradle scripts>build.gradle(module app) > change 'com.android.support:appcompat-v7:28.0.0-alpha3' to 'com.android.support:appcompat-v7:28.0.0-alpha1'

    You may have something other than alpha3 after "-v7:28.0.0-" whatever it is just change it to alpha1.

    0 讨论(0)
提交回复
热议问题