Having an issue as I work through a tutorial on using constraint layout in Android Studio.
In the tutorial android.support.constraint.ConstraintLayout is used but that is now deprecated. As recommended I am attempting the transition to AndroidX.
This is the project level build.gradle.kts:
buildscript {
repositories {
google()
mavenCentral()
}
}
plugins {
// alias(libs.plugins.android.application) apply false
id("com.android.application") version "8.4.0" apply false
id("com.chaquo.python") version "15.0.1" apply false
id("com.android.library") version "7.3.1" apply false
}
This is the module level build.gradle.kts:
// alias(libs.plugins.android.application)
id("com.android.application")
id("com.chaquo.python")
}
android {
namespace = "com.example.pythontestwithjavafix"
defaultConfig {
applicationId = "com.example.pythontestwithjavafix"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
compileSdk = 34
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
ndk{
abiFilters += listOf("arm64-v8a","x86_64")
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding = true
}
}
chaquopy{
defaultConfig{
version = "3.10"
pip{
install("scipy")
install("requests==2.24.0")
}
}
}
dependencies {
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.constraintlayout)
implementation(libs.navigation.fragment)
implementation(libs.navigation.ui)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
// implementation("com.android.support.constraint:constraint-layout:2.0.4")
implementation(libs.constraint.layout)
}
This is the activity_main.xml:
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:background="#8E9CED"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:id="@+id/text"
android:textColor="#F8E115"
android:textSize="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
On my first build attempt this error occurs:
Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.13.0] AndroidManifest.xml:28:18-86
is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-25:19 to override
So I then implemented the recommendation above and a new error occurs:
/Users/me/AndroidStudioProjects/PythonTestWithJavaFix/app/src/main/AndroidManifest.xml:5:5-26:19 Error:
tools:replace specified at line:5 for attribute tools:android.appComponentFactory, but no new value specified
/Users/me/AndroidStudioProjects/PythonTestWithJavaFix/app/src/main/AndroidManifest.xml Error:
Validation failed, exiting
A search has turned up little other than the recommendation to move away from the android.support.* used in the tutorial and move to androidx which I did in activity_main.xml. Interestingly, I checked the project tree and still see a reference to android.support.constraint.* in gradle/libs.versions.toml as follows:
[libraries]
constraint-layout = { module = "com.android.support.constraint:constraint-layout", version.ref = "constraintLayoutVersion" }
Could this be the problem? If so, let me know how to fix. I do not see a lot of discussion regarding the *.toml file but I may have missed it. Please advise. TIA.
So I am at a loss as to how to proceed.