我使用Android Studio将现有的Android项目迁移到Android X,但是我无法导入/解决任何Androidx库 - 我在做什么错?

发布于 2025-01-30 03:00:16 字数 1858 浏览 4 评论 0原文

我最近使用自动化的Android Studio路线将一个旧的Android项目迁移到Android X。我的Gradle依赖性都在那里,但是我无法使用任何Androidx库。您能建议我做错了什么吗?每当我尝试导入Android X库(即导入Androidx.Fragment.App.Fragment),我都会得到无法解决错误

compilesdkversion和targetsdkversion = 32和minsdkversion = 26

i也具有gradle属性

。 android.useandroidx = true

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
    implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'com.squareup.picasso:picasso:2.71828'

}

“在此处输入图像描述”

项目级别gradle:

buildscript {
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.0'
        classpath 'com.google.gms:google-services:4.3.10'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

I recently migrated an old android project to Android X using the automated Android Studio route. My gradle dependencies are all there, but I am unable to use any androidx library. Can you please advise on what I am doing wrong? Every time I try to import an Android X library (i.e. import androidx.fragment.app.Fragment) I get the cannot resolve error

compileSDKVersion and targetSdkVersion =32 and minSdkVersion =26

I also have gradle properties include the following

android.enableJetifier=true
android.useAndroidX=true

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
    implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'com.squareup.picasso:picasso:2.71828'

}

enter image description here

Project Level Gradle:

buildscript {
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.0'
        classpath 'com.google.gms:google-services:4.3.10'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋意浓 2025-02-06 03:00:16

添加

implementation 'androidx.fragment:fragment-ktx:1.4.0'

在build.gradle文件中 和其他任何必要的依赖项。与Gradle同步项目,一切都可以。

Add

implementation 'androidx.fragment:fragment-ktx:1.4.0'

and any other necessary dependencies in your build.gradle file. Sync project with gradle and everything should be fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文