gpt4 book ai didi

java - android studio 中无法实例化一个或多个类错误,因此设计未显示

转载 作者:行者123 更新时间:2023-12-02 02:49:10 27 4
gpt4 key购买 nike

我在 android studio 中遇到布局问题,由于名为“无法实例化一个或多个类”的错误,该布局未显示。我的 build.gradle 应用程序模块文件中也遇到错误,其错误消息如下所示。

我是 android studio 的新手,我尽了一切努力,但似乎一事无成。如果您有解决方案,请告诉我。

  • 我尝试将 build.gradle 应用程序模块中的compileSdkVersion 和targetSdkVersion 更改为较低版本,即从28 更改为26,但这不起作用。

  • 我还尝试过清理项目,然后使其失效/重新启动。

  • 我也尝试过重建项目。

我的 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 28
defaultConfig {
applicationId "naik.dattaraj.meme2"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
//exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0' // This line shows the below mentioned error message
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'com.firebaseui:firebase-ui-database:2.1.0'
implementation 'com.google.firebase:firebase-auth:18.1.0'
implementation 'com.google.firebase:firebase-storage:18.1.0'
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'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation files('libs/CircleImageView-master/gradle/wrapper/gradle-wrapper.jar')
implementation 'com.shitij.goyal:slide-button:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.github.shts:StoriesProgressView:3.0.0'
implementation 'com.github.pwittchen:swipe-rx2:0.3.0'
implementation 'com.tomer:fadingtextview:2.5'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.andkulikov:transitionseverywhere:1.8.1'

implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.support:support-v13:28.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'androidx.mediarouter:mediarouter:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.android.support:palette-v7:28.0.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'com.android.support:leanback-v17:28.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha09'
implementation 'androidx.navigation:navigation-fragment:2.0.0-rc02'
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha09'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha09'
implementation 'androidx.navigation:navigation-ui:2.0.0-rc02'
implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0-rc02'
implementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha09'
implementation 'androidx.navigation:navigation-ui-ktx:2.0.0-rc02'
implementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
implementation 'androidx.navigation:navigation-runtime:2.0.0-rc02'
implementation 'androidx.test.espresso:espresso-contrib:3.1.1'
implementation 'com.android.support.test:rules:1.0.2'
implementation 'androidx.test:rules:1.1.1'
implementation 'com.android.databinding:library:3.3.0'
implementation 'androidx.databinding:databinding-runtime:3.3.0'
implementation 'com.android.databinding:baseLibrary:3.3.0'
implementation 'androidx.databinding:databinding-common:3.3.0'
implementation 'com.android.databinding:compiler:3.1.4'
implementation 'androidx.databinding:databinding-compiler:3.3.0'
implementation 'com.android.databinding:adapters:3.3.0'
implementation 'androidx.databinding:databinding-adapters:3.3.0'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
implementation 'com.google.android.gms:play-services-wearable:16.0.1'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
compileOnly 'com.google.android.wearable:wearable:2.4.0'
implementation 'com.google.android.support:wearable:2.4.0'
annotationProcessor 'com.android.databinding:compiler:3.1.4'
annotationProcessor 'androidx.databinding:databinding-compiler:3.3.0'

}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

我在设计 View 中收到以下错误消息:

The following classes could not be instantiated: - de.hdodenhof.circleimageview.CircleImageView (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details java.lang.IllegalArgumentException: ScaleType FIT_XY not supported.   at de.hdodenhof.circleimageview.CircleImageView.setScaleType(CircleImageView.java:134)   at android.widget.ImageView.(ImageView.java:203)   at android.widget.ImageView.(ImageView.java:172)   at de.hdodenhof.circleimageview.CircleImageView.(CircleImageView.java:98)   at de.hdodenhof.circleimageview.CircleImageView.(CircleImageView.java:94)   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)   at android.view.LayoutInflater.inflate(LayoutInflater.java:515)   at android.view.LayoutInflater.inflate(LayoutInflater.java:394)

我在 build.gradle 应用模块文件中收到此错误消息:

Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='support-v4', myVersion='26.1.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.documentfile', myArtifactId='documentfile', myVersion='1.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies less... (Ctrl+F1) Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible

最佳答案

您同时拥有 AndroidX 库和支持库

您需要迁移到AndroidX

转到重构 -> 迁移到AndroidX -> 迁移

您的build.gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 28
defaultConfig {
applicationId "naik.dattaraj.meme2"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//AndroidX libraries
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.mediarouter:mediarouter:1.0.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.test.espresso:espresso-core:3.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.material:material:1.0.0'
//Navigation
implementation 'androidx.navigation:navigation-fragment:2.0.0-rc02'
implementation 'androidx.navigation:navigation-ui:2.0.0-rc02'
implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0-rc02'
implementation 'androidx.navigation:navigation-ui-ktx:2.0.0-rc02'
implementation 'androidx.navigation:navigation-runtime:2.0.0-rc02'
implementation 'androidx.test.espresso:espresso-contrib:3.1.1'
implementation 'androidx.test:rules:1.1.1'
//firebase
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'com.firebaseui:firebase-ui-database:2.1.0'
implementation 'com.google.firebase:firebase-auth:18.1.0'
implementation 'com.google.firebase:firebase-storage:18.1.0'
//databinding
implementation 'androidx.databinding:databinding-runtime:3.3.0'
implementation 'androidx.databinding:databinding-common:3.3.0'
implementation 'androidx.databinding:databinding-compiler:3.3.0'
implementation 'com.android.databinding:adapters:3.3.0'
implementation 'androidx.databinding:databinding-adapters:3.3.0'
annotationProcessor 'androidx.databinding:databinding-compiler:3.3.0'
//Google play services
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
implementation 'com.google.android.gms:play-services-wearable:16.0.1'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
//Other libraries
implementation 'com.shitij.goyal:slide-button:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.github.shts:StoriesProgressView:3.0.0'
implementation 'com.github.pwittchen:swipe-rx2:0.3.0'
implementation 'com.tomer:fadingtextview:2.5'
implementation 'com.andkulikov:transitionseverywhere:1.8.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
//compileOnly 'com.google.android.wearable:wearable:2.4.0'
//implementation 'com.google.android.support:wearable:2.4.0'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

这应该有效......

关于java - android studio 中无法实例化一个或多个类错误,因此设计未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57122191/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com