I'm trying to test some android jetpack features in my project, I already have the navigation working. When I tried to import android-ktx and migrate my dependencies to androidx I managed to synchronize the gradle successfully, but I lost access to my button through synthetic.
Anyone have any idea what it can be?
My Gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.qmakercorp.qmaker"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.support.test.runner.AndroidJUnitRunner"
}
androidExtensions {
experimental = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// implementation 'com.android.support:appcompat-v7:28.0.0'
// implementation 'com.android.support:design:28.0.0'
// implementation 'com.android.support.constraint:constraint-layout:1.1.3'
// implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-beta01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-beta01'
implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha06"
implementation "android.arch.navigation:navigation-ui-ktx:1.0.0-alpha06"
androidTestImplementation 'androidx.test:rules:1.1.0-beta01'
implementation 'androidx.core:core-ktx:1.0.0'
My Fragment:
In your app build.gradle
file you imported androidx.legacy:legacy-support-v4:1.0.0
and clicked Sync Now
. After that you had error saying Manifest merger failed : Attribute bla bla ...
and commented com.android.support:support-v4:28.0.0
but there wasn't shown Sync Now
and you didn't sync your project with gradle files. That's way you still able to use android.support.v4.app.Fragment
from LoginFragment
. Suggestion: click Sync Project with Gradle Files
button and replace import android.support.v4.app.Fragment
with import androidx.fragment.app.Fragment
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.