添加 Maven 存储库导致错误 - android.support.v7.widget.AppcompatTextView 无法实例化 [英] Adding Maven repository causes an error - android.support.v7.widget.AppcompatTextView can't be instantiated

查看:33
本文介绍了添加 Maven 存储库导致错误 - android.support.v7.widget.AppcompatTextView 无法实例化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我已经浏览了所有相关的帖子,并完全按照所写的去做,但没有任何效果.

我正在尝试添加 ConstraintLayout 1.1.0-beta1 表示百分比尺寸,但每当我这样做时,下方的底部都会出现一个弹出窗口.


我单击了安装存储库和同步项目";很多次,但什么也没发生.因此,我尝试在 Build.gradle(项目)中添加以下代码,它运行良好,但出现了新错误.

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.


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'
    }
}


新的错误与AppCompatTextView

无法实例化以下类:- 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)

上面所说的任何内容都可以通过将 ConstraintLayout 1.1.0-beta1 替换为 ConstraintLayout 1.0.1 来删除,并且应用程序运行良好.

这是 build.gradle(应用程序).

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'
}


最后,是否有任何解决方案/修复方法,以便我可以使用带有百分比尺寸的 ConstraintLayout 1.1.0-beta1 而不会出现此错误.
此外,将那些 26.+ 版本更改为 26.0.0 或 26.0.1 会显示相同的错误.

编辑 -
我发现的是每当我添加如 Android 支持页面所述,我的项目 gradle 中的 Maven 存储库出现此渲染错误.
此外,我无法在 SDK 管理器中看到任何这些版本 ->这意味着添加这些工具不会影响 repo 的版本,也不会安装.
我在哪里可以找到这些库的 .jar/.aar 文件?

仍然需要帮助,任何帮助将不胜感激.谢谢.


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.

推荐答案

这里查看我的回答.与 AppCompatTextView 相关的 NullPointerException 可以通过将 res/values/styles.xml 中的父主题更改为带有 Base 的父主题来修复,例如

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.