1

Note: I have gone through all the related posts and did exactly what was written but nothing worked.

I am trying to add ConstraintLayout 1.1.0-beta1 for percent dimensions, but whenever I do this, a pop-up comes at the bottom which is below.
enter image description here

I clicked "Install Repositiory and Sync project" many times but nothing happened. So, I tried to add the following code in Build.gradle (Project) and it worked fine but a new error came.

repositories {
    maven {
        url 'https://maven.google.com'
    }
}


The new Error is related to AppCompatTextView

The following class couldn't be instantiated :- android.support.v7.widget.AppCompatTextView

java.lang.NullPointerException
    at android.content.res.Resources_Delegate.getValue(Resources_Delegate.java:788)
    at android.content.res.Resources.getValue(Resources.java:1286)
    at android.support.v4.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:212)
    at android.support.v4.content.res.ResourcesCompat.getFont(ResourcesCompat.java:206)
    at android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:119)
    at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:208)
    at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:152)
    at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)
    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:81)
    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:71)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:475)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:250)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:213)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadClass(LayoutlibCallbackImpl.java:193)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:333)
    at android.view.BridgeInflater.onCreateView(BridgeInflater.java:152)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:222)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at com.android.layoutlib.bridge.bars.CustomBar.<init>(CustomBar.java:95)
    at com.android.layoutlib.bridge.bars.StatusBar.<init>(StatusBar.java:67)
    at com.android.layoutlib.bridge.impl.Layout.createStatusBar(Layout.java:224)
    at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:146)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:301)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:567)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:549)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$1(RenderTask.java:680)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Whatever the above thing says can be removed by replacing ConstraintLayout 1.1.0-beta1 to ConstraintLayout 1.0.1 and the application works fine.

This is the build.gradle (app).

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'    
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "cant.reveal.the.secret"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}    
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })          
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:design:26.0.0-alpha1'
    compile 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
    compile 'com.google.firebase:firebase-ads:11.0.4'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'com.google.android.gms:play-services-location:11.0.4'
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    compile 'com.android.support:support-v4:26.+'
    testCompile 'junit:junit:4.12'
}


So at last, Is there any solution/fix for this so I can use ConstraintLayout 1.1.0-beta1 with percent dimensions without this error.
Also, changing those 26.+ versions to 26.0.0 or 26.0.1 shows the same error.

EDIT -
What I've found out is whenever I add that Maven repo in my project gradle as described on Android support page, this rendering error comes.
Also, I can't see any of these versions I'm trying to add in SDK Mangager -> Tools which means addding these is not affecting the repo's versions and also not installing.
Where I can find .jar/.aar files of these libraries?

Still need help and Any help would be much appreciated. Thank you.

Community
  • 1
  • 1
Hardik sharma
  • 313
  • 2
  • 15

4 Answers4

8

See my answer here. The NullPointerException related to AppCompatTextView can be fixed by changing the parent theme in res/values/styles.xml to one with Base e.g.

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

I just tried it and could use the ConstraintLayout beta attributes without getting an error.

Ruary
  • 471
  • 3
  • 4
1

Try this.

In your Android Studio ,choose Tools --> Android --> SDK Manager

Then install this.

enter image description here

Edited

Could you show your detail of your intall?

enter image description here

And check your whether install 1.1.0-beta1

KeLiuyue
  • 8,149
  • 4
  • 25
  • 42
  • Thanks but I already have these installed and also reinstalled them twice with all the versions but nothing happened. – Hardik sharma Aug 23 '17 at 04:55
  • It doesn't install 1.1.0-beta1 or any of those android.support versions (26.0.0 or 26.0.1). I use 26.+ and 1.0.1 to make it work like it was before but these are not updating. – Hardik sharma Aug 24 '17 at 02:10
  • You can use those you had installed.And change your `build.gradle `.@Hardiksharma – KeLiuyue Aug 24 '17 at 02:13
  • I didn't get what you are trying to say but I'm making it clear. I've set margins all over my app's home which is basically a modified app_bar_home.xml. But because of different screen sizes and resolutions, it looks fine in 1080x1920(5.5 inch) but worse in other resolutions. That's why I need percent dimensions to make it same according to percent height and percent width and this can only be possible by `ConstraintLayout 1.1.0-beta1` but whenever I add this, I must add the Maven repo which causes this error. Do note that If I use old versions, my app works fine. Sorry for wasting your time. – Hardik sharma Aug 24 '17 at 02:25
  • Could you change to use `compile 'com.android.support:percent:22.2.0'`? – KeLiuyue Aug 24 '17 at 02:29
  • it's deprecated in Support library v26. – Hardik sharma Aug 25 '17 at 09:52
1

Try Lowering your build version to 25

compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
    applicationId "com.snake.againimage"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"

 compile 'com.android.support.constraint:constraint-layout:1.+'

Then add the constraint layout

Snehal Gongle
  • 337
  • 3
  • 16
0

Have you tried clean project and rebuilding it after changing the library to ConstraintLayout 1.1.0-beta1?

Milad Moosavi
  • 1,587
  • 10
  • 20