Android Studio 3.1.3 having issues with Constraint layout
Asked Answered
D

7

9

I'm trying to start a new project here but this problem is appearing. I can run the project and deploy it in an emulator but this Render problem and Using private resources is ticking me off. I've already tried all the possible solutions found in the internet but it just can't solve the problem

<?xml version="1.0" encoding="utf

<android.support.constraint.ConstraintLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   tools:context=".MainActivity"
   tools:showIn="@layout/activity_main">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!" />

</android.support.constraint.ConstraintLayout>

Style

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>


</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

Build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.acer.myapplication3"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:28.0.0-alpha3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso- core:3.0.2'
}
Dim answered 15/6, 2018 at 4:1 Comment(11)
send your xml file source code hereCaucus
@LearningAlways added it in the descriptionDim
your issue is not rendering constraint layout right? Then give your build.gradle.Burch
@ShwetaChauhan Yes. I've been receiving Render problem and Using private resources messages every time I create new project. Added it in the description.Dim
clean rebuild and invalidate/restartSublunary
@VishvaDave Already did that. Still not working.Dim
https://mcmap.net/q/159408/-gradle-sync-failed-could-not-find-constraint-layout-1-0-0-alpha2Sublunary
refer the @VishvaDave linkFenrir
@Mr.Roshan Checked it and I got 1.0.2 both installed for Solver and ConstraintLayoutDim
use com.android.support.constraint:constraint-layout:1.0.2-alpha2Sublunary
Synced it and I got a message Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2-alpha2Dim
S
10

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:

screenshot of my API manager

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'
}
Slobbery answered 20/6, 2018 at 5:32 Comment(2)
I think it seems that the release also have problem. I managed to start a problem without a hitch using the latest canary build. Anyway, I'll update you guys with what really is the problem, I created an Issue with Google and brought up the error to them. I got no time to reply to them right now or do the fix they are suggesting because of a hectic schedule. Anyway thanks for the suggestion, I'll try it this coming weekend and update you with the result.Dim
This should be accepted answer! I have changed my gradle build version 8 to 7. and it worked! Happy coding!Worthwhile
O
2

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'

enter image description here

To:

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

enter image description here

And then sync your project.

Old answered 16/9, 2018 at 12:59 Comment(1)
Please do not post code as an image. You should cut and paste the code directly into your answer.Rafi
S
1

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!

Sporophyte answered 15/7, 2019 at 10:44 Comment(1)
First, If you have implemented androidX and then removed, You must have to follow this two steps. Thanks buddy.Aryn
L
0

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

Laborsaving answered 27/6, 2018 at 6:11 Comment(0)
P
0

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.

Pennypennyaliner answered 3/7, 2018 at 15:4 Comment(0)
K
0

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

Keitel answered 3/7, 2018 at 15:17 Comment(0)
T
0
  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"
Tad answered 27/8, 2018 at 23:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.