[英]Synthetic of kotlin extensions does not work when I import Android-ktx in gradle
我正在尝试在我的项目中测试一些android jetpack功能,我已经在使用导航功能。 当我尝试导入android-ktx并将依赖项迁移到androidx时,我成功地成功同步了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'
我的片段:
在您的应用程序build.gradle
文件中,您导入了androidx.legacy:legacy-support-v4:1.0.0
并点击Sync Now
。 之后,出现错误,提示Manifest merger failed : Attribute bla bla ...
并评论了com.android.support:support-v4:28.0.0
但未显示“ Sync Now
,也没有将您的项目与gradle文件同步。 这样,您仍然可以使用LoginFragment
android.support.v4.app.Fragment
。 建议:单击Sync Project with Gradle Files
按钮,然后将import android.support.v4.app.Fragment
替换为import androidx.fragment.app.Fragment
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.