gpt4 book ai didi

java - 二进制 XML 文件行 #52 : Binary XML file line #52: Error inflating class com. Askira.loopingviewpager.LoopingViewPager

转载 作者:行者123 更新时间:2023-12-02 09:22:26 24 4
gpt4 key购买 nike

我正在尝试使用askira.loopingViewPager 设置菜单。但是,当我运行该应用程序时,它崩溃了,因为它无法从登录 Activity 转到 HomeActivity;​显示我粘贴在下面的错误...我想我的 XML 文件中可能仍然有一些来自旧布局的元素,但我找不到一些?!我仍然认为问题出在 XML 文件中。我可以做什么来解决这个问题?代码编译良好且没有错误,Gradle 已更新到最新版本。如果您需要更多信息,请告诉我。谢谢。

Process: com.example.login, PID: 24891
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.login/com.example.login.HomeActivity}: android.view.InflateException: Binary XML file line #52: Binary XML file line #52: Error inflating class com.askira.loopingviewpager.LoopingViewPager
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:234)
at android.app.ActivityThread.main(ActivityThread.java:5526)
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 #52: Binary XML file line #52: Error inflating class com.askira.loopingviewpager.LoopingViewPager
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.example.login.ui.home.HomeFragment.onCreateView(HomeFragment.java:42)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2646)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2416)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2466)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1483)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1238)
at android.app.Activity.performStart(Activity.java:6302)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2427)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) 
at android.app.ActivityThread.access$900(ActivityThread.java:154) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:234) 
at android.app.ActivityThread.main(ActivityThread.java:5526) 
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 #52: Error inflating class com.askira.loopingviewpager.LoopingViewPager
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
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.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 com.example.login.ui.home.HomeFragment.onCreateView(HomeFragment.java:42) 
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439) 
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) 
at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2646) 
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2416) 
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372) 
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) 
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273) 
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229) 
at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2466) 
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1483) 
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) 
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) 
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269) 
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229) 
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201) 
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620) 
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178) 
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1238) 
at android.app.Activity.performStart(Activity.java:6302) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2427) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) 
at android.app.ActivityThread.access$900(ActivityThread.java:154) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:234) 
at android.app.ActivityThread.main(ActivityThread.java:5526) 
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.ClassNotFoundException: Didn't find class "com.askira.loopingviewpager.LoopingViewPager" on path: DexPathList[[zip file "/data/app/com.exampl

XML-Home fragment

<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/white"
android:weightSum="5">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="vertical"
android:background="@android:color/white"
android:padding="8dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/popular_categories"
android:textSize="24sp"/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_popular"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:orientation="vertical"
android:background="@android:color/white"
android:padding="8dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/best_deals"
android:textSize="24sp"
android:layout_marginTop="10dp"
android:layout_marginLeft="8dp"/>

<com.askira.loopingviewpager.LoopingViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:isInfinite="true"
app:autoScroll="true"
app:scrollInterval="5000"
app:viewpagerAspectRatio="1.33"/>
</LinearLayout>
</LinearLayout>

</RelativeLayout>

主页 fragment

public class HomeFragment extends Fragment {

private HomeViewModel homeViewModel;

Unbinder unbinder;

@BindView(R.id.recycler_popular)
RecyclerView recycler_popular;
@BindView(R.id.viewpager)
LoopingViewPager viewPager;

public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
homeViewModel = ViewModelProviders.of(this).get(HomeViewModel.class);
View root =inflater.inflate(R.layout.fragment_home,container,false);
unbinder= ButterKnife.bind(this,root);
init();
homeViewModel.getPopularList().observe(this,popularCategoryModels ->{
//Create Adapter
MyPopularCategoriesAdapter adapter=new MyPopularCategoriesAdapter(getContext(),popularCategoryModels);
recycler_popular.setAdapter(adapter);
});

homeViewModel.getBestDealList().observe(this,bestDealModels -> {
MyBestDealsAdapter adapter = new MyBestDealsAdapter(getContext(),bestDealModels,true);
viewPager.setAdapter(adapter);
});
return root;
}

private void init() {
recycler_popular.setHasFixedSize(true);
recycler_popular.setLayoutManager(new LinearLayoutManager(getContext(),RecyclerView.HORIZONTAL,false));

}
@Override
public void onResume(){
super.onResume();
viewPager.resumeAutoScroll();
}
@Override
public void onPause(){
viewPager.pauseAutoScroll();
super.onPause();

}

GradleAPP 的一部分

implementation 'com.asksira.android:loopingviewpager:1.1.4'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'de.hdodenhof:circleimageview:3.0.1'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

最佳答案

您拼错了软件包名称:它是 com.askira,而不是 com.askira - 您缺少一个 s

<com.asksira.loopingviewpager.LoopingViewPager
android:id="@+id/viewpager"

关于java - 二进制 XML 文件行 #52 : Binary XML file line #52: Error inflating class com. Askira.loopingviewpager.LoopingViewPager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58598946/

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