迁移到AndroidX后出现一些错误 [英] some Errors after migration to AndroidX

查看:650
本文介绍了迁移到AndroidX后出现一些错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

迁移到AndroidX后出现一些错误

some errors after migration to AndroidX

我下载了LeafPic-master项目(这是Android Studio的图库源代码),并尝试更改minsdkversion和targetSdkVersion(我想要将我的应用程序在android 4.4上安装到最新的android api)。因此,我将 google()存储库添加到存储库解决一些问题,然后迁移到AndroidX。
我的错误列表是:

I downloaded LeafPic-master project( it is a gallery source code for Android studio)and try to change minsdkversion and targetSdkVersion( I want to install my app on android 4.4 to newest android api).So I add the google() repo in the repositories to solve some problems then migrate to AndroidX. the list of my errors is:

ERROR: Failed to resolve: androidx.recyclerview:recyclerview:1.0.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: com.google.android.material:material:1.0.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: androidx.palette:palette:1.0.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: androidx.legacy:legacy-support-v4:1.0.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: androidx.browser:browser:1.0.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: androidx.exifinterface:exifinterface:1.0.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: com.google.android.gms:play-services-iid:[17.0.0]
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: androidx.vectordrawable:vectordrawable-animated:1.0.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: fragment
Affected Modules: app

而我的Build.gradle是:

and my Build.gradle is:

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

}

apply plugin: 'com.android.application'

repositories {
    google()
    jcenter()
    maven  { url "http://repo1.maven.org/maven2" }
    maven {  url  "http://dl.bintray.com/dasar/maven" }
    maven { url 'https://maven.google.com' }
}

android {
    compileSdkVersion 29
    buildToolsVersion '27.0.3'
    defaultConfig {

        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0.0"
        vectorDrawables.useSupportLibrary = true
    }

    lintOptions {
        disable 'MissingTranslation'
        disable 'ExtraTranslation'
    }
    // This is handled for you by the 2.0+ Gradle Plugin
    aaptOptions {
        additionalParameters "--no-version-vectors"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.browser:browser:1.0.0'
    implementation "androidx.exifinterface:exifinterface:1.0.0"
    implementation "androidx.appcompat:appcompat:1.0.0"

    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

    implementation 'com.koushikdutta.ion:ion:2.1.7'
    implementation 'com.mikepenz:iconics-core:3.0.3@aar'
    implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar'
    implementation 'com.mikepenz:community-material-typeface:2.0.46.1@aar'
    implementation 'com.mikepenz:fontawesome-typeface:4.7.0.2@aar'
    implementation "com.mikepenz:iconics-views:3.0.3@aar"
    implementation 'com.github.paolorotolo:appintro:3.4.0'
    implementation 'com.yalantis:ucrop:1.5.0'
    implementation 'uz.shift:colorpicker:0.5@aar'
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation 'com.commit451:PhotoView:1.2.5'
    implementation 'com.google.android.exoplayer:exoplayer:r1.5.7'
    implementation 'de.psdev.licensesdialog:licensesdialog:1.8.3'

    implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.drewnoakes:metadata-extractor:2.11.0'
    implementation 'org.jetbrains:annotations-java5:15.0'
    implementation 'co.ronash.android:pushe-base:1.3.3'
    api 'com.google.android.gms:play-services-gcm:17.0.0'
}

其他错误是:

cannot resolve symbole 'material' 
cannot resolve symbole 'appcompat'
cannot resolve symbole 'cardview'
cannot resolve symbole 'recyclerview'

在以下行中:

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.SwitchCompat;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


推荐答案

尝试更改

sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6

sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

这篇关于迁移到AndroidX后出现一些错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆