when i run my app on android 9, android 10, and android 11. my app runs fine without a hitch. when i run it on android 6, the app experiences force close on the way to the main fragment.
when i try to see error in logcat, shows error in mainFragment, in inflater. Why did it happen?
Logcat
Caused by: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class ImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.hp.ali.ecomerceapp.fragments.MainFragment.onCreateView(MainFragment.java:47)
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.hp.ali.ecomerceapp">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="replace" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.EcomerceApp"
android:usesCleartextTraffic="true">
<activity android:name=".activities.TentangAplikasi"></activity>
<activity android:name=".activities.KebijakanPrivasi" />
<activity android:name=".activities.VerifikasiPesanan" />
<activity android:name=".activities.StatusPesanan" />
<activity android:name=".activities.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.SwipeActivity" />
<activity android:name=".activities.SwipeUkaki" />
<activity android:name=".login.InputOTPActivity" />
<activity android:name=".login.OTPAuthActivity" />
<activity android:name=".activities.EditAlamat" />
<activity android:name=".activities.EditProfile" />
<activity android:name=".activities.Other"/>
<activity android:name=".activities.CartActivity" />
<activity android:name=".activities.CheckoutActivity" />
<activity android:name=".activities.ProductDetail" />
<activity android:name=".login.RegisterActivity" />
<activity
android:name=".activities.MainActivity"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".login.LogInActivity" />
<meta-data
android:name="com.snapchat.kit.sdk.clientId"
android:value="f4cad14a-c276-4d02-9d2e-683e038d044d" />
<meta-data
android:name="com.snapchat.kit.sdk.redirectUrl"
android:value="ecomerceapp://snap-kit/oauth2" />
<meta-data
android:name="com.snapchat.kit.sdk.scopes"
android:resource="@array/snap_connect_scopes" />
<activity
android:name="com.snapchat.kit.sdk.SnapKitActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="snap-kit"
android:path="/oauth2"
android:scheme="ecomerceapp" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
<queries>
<package android:name="com.whatsapp" />
<package android:name="com.snapchat.android" />
</queries>
</manifest>
Gradle
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.1"
ndkVersion "21.3.6528147"
defaultConfig {
applicationId "com.hp.ali.ecomerceapp"
minSdkVersion 20
targetSdkVersion 30
versionCode 18
versionName "1.8"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
ndk{
debugSymbolLevel 'SYMBOL_TABLE'
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
checkReleaseBuilds false
}
}
ext {
snapKitSdkVersion = '1.4.0'
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
//For Google Log-in
implementation 'com.shobhitpuri.custombuttons:google-signin:1.1.0'
//Allert
implementation 'com.github.TutorialsAndroid:KAlertDialog:v14.0.19'
implementation platform('com.google.firebase:firebase-bom:28.2.1')
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.firebase:firebase-auth'
implementation 'androidx.browser:browser:1.3.0'
implementation 'com.airbnb.android:lottie:3.4.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.yarolegovich:sliding-root-nav:1.1.1'
implementation 'com.github.hajiyevelnur92:intentanimation:1.0'
implementation 'com.google.android.material:material:1.2.0-alpha02'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.mig35:carousellayoutmanager:+'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation "androidx.core:core-ktx:+"
implementation([
'com.snapchat.kit.sdk:creative:1.10.0',
'com.snapchat.kit.sdk:core:1.10.0'
])
//Country Code Picker
implementation 'com.hbb20:ccp:2.4.0'
implementation "com.snapchat.kit.sdk:login:$snapKitSdkVersion"
implementation "com.snapchat.kit.sdk:core:$snapKitSdkVersion"
//Page Indicator View
implementation 'com.romandanylyk:pageindicatorview:1.0.3'
//carouselview
compile 'com.synnapps:carouselview:0.1.5'
}
repositories {
mavenCentral()
google()
}
Use
AppCompatImageViewinsteadImageView, andapp:srcCompatinsteadandroid:srcin the XML.But, according to AppCompatImageView documentation, it should be replaced automatically if you use
AppCompatActivity:So, please make your activity inherits from
AppCompatActivity.