添加Maven存储库会导致错误-无法实例化android.support.v7.widget.AppcompatTextView
作者:互联网
注意:我已经阅读了所有相关文章,并完全按照所写的内容工作,但没有任何效果.我试图为百分比尺寸添加ConstraintLayout 1.1.0-beta1,但是每当执行此操作时,底部都会弹出一个窗口低于.
我多次单击“安装存储库和同步项目”,但没有任何反应.因此,我尝试在Build.gradle(Project)中添加以下代码,它工作正常,但出现了新错误.
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(应用程序).
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 repo时,就会出现此渲染错误.另外,我在SDK Mangager中看不到要添加的所有这些版本->意味着添加这些工具不会影响存储库的版本,也不会安装.
在哪里可以找到这些库的.jar / .aar文件?
仍然需要帮助,任何帮助将不胜感激.谢谢.
解决方法:
请参阅我的答案here.与AppCompatTextView相关的NullPointerException可以通过将res / values / styles.xml中的父主题更改为Base来解决.
< style name =“ AppTheme” parent =“ Base.Theme.AppCompat.Light.DarkActionBar”>
我刚刚尝试过,可以使用ConstraintLayout beta属性而不会出现错误.
标签:android,android-studio,android-appcompat 来源: https://codeday.me/bug/20191011/1892764.html