Santiago Bozzi
Santiago Bozzi

Reputation: 139

Problem with design view and import thing after migration to Androidx

Well, today I finally built a project after the migration to Androidx (was stopped since a year ago). With the help of some responses of this page I managed to change all the namespaces but I still have two problems to get my project working 100%.

First one is a problem with the constraint layout on the design view, I cant see anything that I did before. Second problem is some imports that I didn't update yet, and Android Studio still marking the error.

First Problem

First Problem Image

Second Problem

Second Problem Image

I will paste how I have my gradle now just in case:

Project:

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
}

Module:

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-alpha1'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
        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'

Upvotes: 1

Views: 1105

Answers (2)

Ajay Wghe
Ajay Wghe

Reputation: 21

Try To clean project Build-> Clean project This Resolved my issue after i migrated to androidx

Upvotes: 1

chrjs
chrjs

Reputation: 2443

The correct import for the TabLayout is: import com.google.android.material.tabs.TabLayout It comes from:
implementation "com.google.android.material:material:1.0.0"

The correct import for the AppCompatActivity is now import androidx.appcompat.app.AppCompatActivity which comes from implementation "androidx.appcompat:appcompat:1.0.0"

You should also check your layout xml. You need to declare the constraint layout with namespace: androidx.constraintlayout.widget.ConstraintLayout

You should also try to remove the legacy dependency you have here implementation 'androidx.legacy:legacy-support-v4:1.0.0'

Upvotes: 1

Related Questions