Android Studio XML布局自动提示异常 求Gradle配置排查方案
Android Studio XML布局自动提示异常排查请求
问题描述
- 输入
<TextView>时,android:layout_width和android:layout_height属性的自动提示未提供match_parent或wrap_content选项 android:id属性无任何自动提示,需手动完整输入才能添加- 其他项目中该自动提示功能正常,推测是修改当前项目Gradle配置导致的问题,已对比配置但未定位到原因
项目级Gradle配置
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.7.10' ext.hilt_version = '2.43.2' repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version" classpath 'com.google.gms:google-services:4.3.13' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() mavenCentral() } } task clean(type: Delete) { delete rootProject.buildDir } ext { // Sdk and tools // Support library and architecture components support minSdk 14 and above. minSdkVersion = 21 targetSdkVersion = 30 compileSdkVersion = 33 // App dependencies }
模块级Gradle配置
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: "dagger.hilt.android.plugin" apply plugin: 'com.google.gms.google-services' android { compileSdk rootProject.compileSdkVersion defaultConfig { applicationId "com.mostafan3ma.android.menupro10" minSdk rootProject.minSdkVersion targetSdk rootProject.targetSdkVersion versionCode 1 versionName "1.0" testInstrumentationRunner "com.mostafan3ma.android.hilttesting.MyHiltTestRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } buildFeatures { viewBinding true dataBinding true } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.core:core-ktx:1.8.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.google.firebase:firebase-firestore-ktx:24.3.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' def hilt_version = "2.43.2" implementation "com.google.dagger:hilt-android:$hilt_version" kapt "com.google.dagger:hilt-android-compiler:$hilt_version" def hilt_view_models = "1.0.0-alpha03" kapt "androidx.hilt:hilt-compiler:$hilt_view_models" def fragment_ktx = "1.6.0-alpha01" implementation "androidx.fragment:fragment-ktx:$fragment_ktx" def liveData_ktx="2.5.1" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$liveData_ktx" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.0" def room = "2.4.3" implementation "androidx.room:room-runtime:$room" implementation "androidx.room:room-ktx:$room" kapt "androidx.room:room-compiler:$room" implementation 'com.google.code.gson:gson:2.8.9' def navigation_version="2.5.1" implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version" implementation "androidx.navigation:navigation-ui-ktx:$navigation_version" /* Tests */ // Hilt androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_version" kaptAndroidTest "com.google.dagger:hilt-android-compiler:$hilt_version" def fragmentTest_version = "1.3.0-alpha08" debugImplementation "androidx.fragment:fragment-testing:$fragmentTest_version" def activityTest_version = "1.4.0" androidTestImplementation "androidx.test:core-ktx:$activityTest_version" } kapt { correctErrorTypes true }
Gradle-wrapper.properties
#Sun Sep 11 04:08:59 AST 2022 distributionBase=GRADLE_USER_HOME distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME
gradle.properties
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app"s APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.enableJetifier=true warning-mode=all android.nonTransitiveRClass=true
settings.gradle
include ':app' rootProject.name = "MenuPro1.0"
内容的提问来源于stack exchange,提问作者مصطفى نعمه
相关产品推荐
相关产品推荐

