Android Studio 3.1.3 having issues with Constraint layout

*爱你&永不变心* 提交于 2019-12-01 03:55:46
Wynand Lambrechts

Had the same issue - went to SDK manager and installed additional SDK platforms; Oreo 8.1. It seems the issue was that the 'new' API 28 still has issues. It says partially installed, but I basically just checked the boxes for lower API's and it downloaded/installed:

Additionally, I changed my build.gradle file's SDK version, buildTools, appcompat, and design versions as below. It works now and I will move back to API 28 at a later stage when these issues have been resolved.

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
    ...
    minSdkVersion 15
    targetSdkVersion 27
    ...

dependencies {
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.0.0'
}
ILIAS M. DOLAPO

You just need to change the following codes from the dependencies section of your build.gradle file:

From:

implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc02'

To:

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'

And then sync your project.

I had the same issues. For me, the reason is my project "Automatically convert third-party libraries to use AndroidXhas". Check if your problem same as mine? please simply follow the two steps described here.

to make it easy:

1st step: Please check your gradle.properties, if you see the following lines, you might have the exact same issues as mine. You can firstly delete them.

android.useAndroidX=true
android.enableJetifier=true

2nd step: in main activity, I changed

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

into

import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;

Everything works all of sudden!

Try to use this:

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
}

Instead of constraint-layout:1.1.2.

This solved my issue.

Add 'Base.' before 'Theme.AppCompat.Light.DarkActionBar' in styles.xml . Worked for me.

Jeff H
  1. On the left-hand side, click app.
  2. Then, open the res folder.
  3. Open up the values folder.
  4. Click on the 'styles.xml' folder.
  5. Change the parent variable to "Base.Theme.AppCompact.Light.DarkActionBar"
Mbanda

Make sure you unchecked OFF LINE option in settings > gradle, then sync the project again while connected on network

You can try RelativeLayout replace from Constraint Layout in content_main.xml and activity_main.xml

Note: 1.Don't forget to end tag with RelativeLayout

.../RelativeLayout>

  1. Sorry for bad English.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!