gpt4 book ai didi

java - 将 appcompat-v7 和设计库更新到 v24.2.0 会导致错误

转载 作者:太空狗 更新时间:2023-10-29 14:46:47 26 4
gpt4 key购买 nike

我使用了 appcompat-v7 并使用 v24.1.1 设计库,项目按预期工作,没有任何问题或错误。但是当我将这两个库更新到 v24.2.0 时,出现了一些错误。

1. appcompat-v7 库的第一个错误,在我更新此库后,工具栏和 FAB 在设计屏幕中消失了。此外,当我运行该项目时,我的 Android 应用程序会在立即启动应用程序后停止(强制关闭)。 日志:

09-03 14:02:56.543 14932-14932/com.twitter.i_droidi.notah E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.twitter.i_droidi.notah, PID: 14932
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.twitter.i_droidi.notah/net.alhazmy13.catcho.library.CatchoReportActivity}: android.view.InflateException: Binary XML file line #100: Binary XML file line #100: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #100: Binary XML file line #100: Error inflating class android.support.design.widget.FloatingActionButton
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at net.alhazmy13.catcho.library.CatchoReportActivity.onCreate(CatchoReportActivity.java:32)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: android.view.InflateException: Binary XML file line #100: Error inflating class android.support.design.widget.FloatingActionButton
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at net.alhazmy13.catcho.library.CatchoReportActivity.onCreate(CatchoReportActivity.java:32) 
at android.app.Activity.performCreate(Activity.java:6237) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at net.alhazmy13.catcho.library.CatchoReportActivity.onCreate(CatchoReportActivity.java:32) 
at android.app.Activity.performCreate(Activity.java:6237) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.NoSuchMethodError: No direct method <init>(Landroid/widget/ImageView;Landroid/support/v7/widget/AppCompatDrawableManager;)V in class Landroid/support/v7/widget/AppCompatImageHelper; or its super classes (declaration of 'android.support.v7.widget.AppCompatImageHelper' appears in /data/data/com.twitter.i_droidi.notah/files/instant-run/dex/slice-com.android.support-appcompat-v7-24.2.0_6745dad81260adbd6a3e5cd1e754bd0f70ca1f25-classes.dex)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:170)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:147)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at net.alhazmy13.catcho.library.CatchoReportActivity.onCreate(CatchoReportActivity.java:32) 
at android.app.Activity.performCreate(Activity.java:6237) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

2. 设计库的第二个错误,在我更新这个库后,整个 TextInputLayout 和 EditText 都消失了,我无法在 EditText 区域写任何东西。

* 更新:XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:fitsSystemWindows="true"
tools:context=".CreateNote"
android:id="@+id/coordinatorlayout_create_note">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical"
android:id="@+id/rl1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<LinearLayout
android:id="@+id/llmain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/colorPrimary"
android:elevation="6dp"
android:fitsSystemWindows="true" >

<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">

</android.support.v7.widget.Toolbar>

<LinearLayout
android:id="@+id/ll1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical"
android:fitsSystemWindows="true">

<android.support.design.widget.TextInputLayout
android:id="@+id/inputlayoutTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp">

<EditText
android:id="@+id/create_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/note_title"
android:paddingLeft="10dp"
android:textSize="19.5sp"
android:textStyle="bold"
android:textColor="#212121"
android:typeface="serif"
android:fontFamily="serif"
android:inputType="text"
android:layout_marginLeft="15dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:tag="text_color|primary_text_inverse,text_size|title"
android:singleLine="true" />

</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/save"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:layout_gravity="right"
android:layout_marginTop="-30dp"
android:adjustViewBounds="false"
android:tag="bg_tint_accent_color_selector_lighter"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />

<ScrollView
android:id="@+id/scroll_view"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:layout_marginTop="-25dp"
android:paddingTop="15dp"
android:animateLayoutChanges="true">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.design.widget.TextInputLayout
android:id="@+id/inputlayoutContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="17dp"
android:layout_marginTop="-20dp"
android:paddingBottom="5dp"
app:counterEnabled="true"
app:counterTextAppearance="@style/MyCounterTextStyle" >

<EditText
android:id="@+id/create_body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:hint="@string/note_content"
android:textSize="15sp"
android:gravity="top"
android:background="@android:color/transparent"
android:layout_marginLeft="7dp"
android:tag="tint_accent_color,text_primary,textsize_subheading"
android:layout_marginRight="3dp"
android:inputType="textMultiLine"
android:textColor="#727272"
android:typeface="serif"
android:fontFamily="serif" />

</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

最佳答案

将光标移动到这些库上时,将库更新为您在 .gradle 文件中看到的最新版本。

始终保持设计库版本大于等于应用程序兼容库,就像我为解决相同问题所做的那样。编译 'com.android.support:appcompat-v7:24.2.1'编译 'com.android.support:design:24.2.1'从编译 'com.android.support:appcompat-v7:24.2.1'编译 'com.android.support:design:24.0.0'

关于java - 将 appcompat-v7 和设计库更新到 v24.2.0 会导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39306266/

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