build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
buildToolsVersion '27.0.3'
defaultConfig {
multiDexEnabled true
applicationId "tk.megh.myapplication"
minSdkVersion 'P'
targetSdkVersion 'P'
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:+'
testImplementation 'junit:junit:4.12'
}
Well i think i know what's causing the error, if you look at the dependencies there are two redundant packages with different names
com.android.support.constraint:constraint-layout:1.1.0 androidx.constraintlayout:constraintlayout:1.1.0
But i can't remove either of them because they are used by some packages. I'm a novice in android development, so i don't have much idea about any workarounds.
if i remove
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
i get this error while debugging:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{tk.megh.myapplication/tk.megh.myapplication.MainActivity}:
android.view.InflateException: Binary XML file line #2: Binary XML file
line #2: Error inflating class android.support.constraint.ConstraintLayout
and if i remove
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
i get the following error while debugging:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{tk.megh.myapplication/tk.megh.myapplication.DisplayMessageActivity}:
android.view.InflateException: Binary XML file line #2: Binary XML file line #2:
Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Additional Details:
imports of MainActivity.java:
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
imports of DisplayMessageActivity.java:
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
Thanks in advance.