gpt4 book ai didi

android - 迁移到 AndroidX

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:00:06 29 4
gpt4 key购买 nike

好吧,我从一年前的项目开始迁移到 AndroidX(从那时起就没有动过),我在资源和 gradle 构建方面遇到了问题。我完全迷失了新的命名空间,我改变了其中的一些,我升级了 AndroidStudio 告诉我的所有东西,但仍然无法识别我项目中的东西。我将在此处粘贴两个 gradle,并将错误放在下方。

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

模块

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.example.usuario.tm"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test:runner:1.1.0-alpha3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha3', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.gms:google-services:4.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
testImplementation 'junit:junit:4.12'
}
}

apply plugin: 'com.android.application'
apply plugin: 'maven'

错误

Android resource linking failed
Output: C:\Users\Xrless\Desktop\Programing\TN\TM\app\src\main\res\layout\activity_principal.xml:34: error: attribute android:style not found.
error: failed linking file resources.

Command: C:\Users\Xrless\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\cf456f090f0725907522fb6d2bec3322\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
C:\Users\Xrless\AppData\Local\Android\Sdk\platforms\android-28\android.jar\
--manifest\
C:\Users\Xrless\Desktop\Programing\TN\TM\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
C:\Users\Xrless\Desktop\Programing\TN\TM\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@C:\Users\Xrless\Desktop\Programing\TN\TM\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
C:\Users\Xrless\Desktop\Programing\TN\TM\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.example.usuario.tm\
-0\
apk\
--output-text-symbols\
C:\Users\Xrless\Desktop\Programing\TN\TM\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

最佳答案

您的 activity_principal.xml 中存在错误。尝试改变:

android:style

style

还需要添加

android.useAndroidX=true

如果您想使用 androidX 库而不是支持库,请添加到您的 gradle.properties 文件。

关于android - 迁移到 AndroidX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52960640/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com