我对这个错误感到非常沮丧。我完成了我的项目,并在我的Android 4.4.2版设备上运行,它成功运行,然后我成功上传到Playstore,并再次从Playstore安装,但它仍然运行良好。。。。。
但后来我收到了很多朋友的车祸报告。然后我借用了我朋友的Android6.0.1版设备,从Android Studio运行应用程序,在Splashactivity启动后,应用程序突然崩溃。Splashactivity成功启动,然后在打开Mainactivity之前,我使用片段容器加载了5-6个片段。。。它坠毁了。
下面是我的错误日志报告
Caused by: android.view.InflateException: Binary XML file line #69: Binary XML file line #69: Error inflating class android.support.v7.widget.CardView
at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at com.nepalpolice.cdp.main.onCreateView(main.java:69)
以下是布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".main">
<LinearLayout
android:orientation="vertical"
android:background="@drawable/bg"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:src="@drawable/main"
/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="15dp"
android:background="#f7f6f3"/>
<View
android:id="@+id/SplitLine_hor1"
android:layout_width="match_parent"
android:layout_height= "2dp"
android:background="#C0C0C0" />
<android.support.v7.widget.GridLayout
android:id="@+id/mainGrid"
app:orientation="horizontal"
app:columnCount="2"
android:background="#FEFEFE"
app:rowCount="3"
app:columnOrderPreserved="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="1dp"
>
<!-- Row 1 -->
<!-- Column 1 -->
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
app:cardElevation="8dp"
app:cardCornerRadius="8dp"
android:backgroundTint="@drawable/megaphone"
>
<LinearLayout
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/notices"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id='@+id/news'/>
<TextView
android:text="News "
android:textAlignment="center"
android:textColor="#0f539c"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
app:cardElevation="8dp"
app:cardCornerRadius="8dp"
>
<LinearLayout
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id='@+id/feeds'
android:src="@drawable/feeds"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="Blog"
android:textAlignment="center"
android:textColor="#0f539c"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
我的构建gradle文件是
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.nepalpolice.cdp"
minSdkVersion 15
targetSdkVersion 26
versionCode 5
versionName "5.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation("com.github.bumptech.glide:glide:4.6.1") {
exclude group: "com.android.support"
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:support-v4:26.+'
implementation 'com.android.support:cardview-v7:26.+'
implementation 'com.android.support:recyclerview-v7:26.+'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.gms:google-services:3.1.0'
implementation 'com.android.support:design:26.+'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.5.1'
implementation 'com.android.support:gridlayout-v7:26.+'
implementation 'com.github.clans:fab:1.6.2'
testCompile 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'id.zelory:compressor:2.1.0'
implementation files('libs/libGoogleAnalyticsServices.jar')
}
apply plugin: 'com.google.gms.google-services'
}
我的主要片段是
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
news = (ImageView) view.findViewById(R.id.news);
notice = (ImageView) view.findViewById(R.id.notice);
我该如何解决这个问题......我也关注了许多其他的帖子,但也没有帮助。提前感谢
在查看了您的xml
代码后,我发现您忘记声明idnews
和通知
,这导致了InflateExc0019android.view.。
解决方案:将这些字段声明为所需的ImageView
您已经在glide中实现了所有依赖项。试试下面的渐变
Gradle:
dependencies {
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation("com.github.bumptech.glide:glide:4.6.1") {
exclude group: "com.android.support"
}
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:support-v4:26.+'
implementation 'com.android.support:cardview-v7:26.+'
implementation 'com.android.support:recyclerview-v7:26.+'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.gms:google-services:3.1.0'
implementation 'com.android.support:design:26.+'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.5.1'
implementation 'com.android.support:gridlayout-v7:26.+'
implementation 'com.github.clans:fab:1.6.2'
testCompile 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'id.zelory:compressor:2.1.0'
implementation files('libs/libGoogleAnalyticsServices.jar')
apply plugin: 'com.google.gms.google-services'
}
使用
app:backgroundTint="@drawable/megaphone"
而不是这个
android:backgroundTint="@drawable/megaphone"
试试这个
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
app:cardElevation="8dp"
app:cardCornerRadius="8dp"
app:backgroundTint="@drawable/megaphone"
>
在尝试运行我的应用程序时,我意外地遇到了以下错误: 以下是日志目录: 下面是java代码: 以下是布局代码: 提前谢谢
我试图实现方法底部导航视图,但当我运行代码时,我得到了这个错误 build.gradle(模块应用程序)
我试图在工具栏上添加一个阴影,下面是这个例子https://stackoverflow.com/a/26904102/4273056 活动中的我的工具栏 这是我添加工具栏的xml文件 我在logcat java中得到了这个。ClassCastException:android。小装置。LinearLayout无法转换为android。支持v7。小装置。工具栏 我怎样才能摆脱这个错误?
我按照http://developer.android.com/tools/support-library/setup.html的指示将支持库添加到我的android项目中,但遇到了这样的构建错误 Gradle:评估项目时出现问题:“projectname”。 没有方法的签名:org。格拉德尔。应用程序编程接口。内部的人工制品dsl。依赖项。DefaultDependencyHandler。com
我在Play Store上发布了我的应用程序,在我的测试中没有任何错误,但是我从Firebase收到的报告显示我的适配器存在一些问题,跟踪错误和代码: 我感谢任何能帮助我的人