androidx로 마이그레이션 한 후 androidx.constraintlayout.ConstraintLayout 클래스 확장 오류
방금 Android Studio 메뉴 옵션 Refactor- > Refactor to AndroidX를 통해 androidx로 마이그레이션했습니다.
다음과 같은 오류가 발생합니다.
android.view.InflateException : 이진 XML 파일 줄 # 2 : 이진 XML 파일 줄 # 2 : 클래스 androidx.constraintlayout.ConstraintLayout 확장 오류
어떤 생각?
Stacktrace :
2018-10-19 00:25:58.128 28131-28131/com.midounoo.midounoo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.midounoo.midounoo, PID: 28131
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.midounoo.midounoo/com.midounoo.midounoo.Base.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6255)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.ConstraintLayout" on path: DexPathList[[zip file "/data/app/com.midounoo.midounoo-2/base.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.midounoo.midounoo-2/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.midounoo.midounoo.Base.MainActivity.onCreate(MainActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6666)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6255)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
나는 모든 발생을 변경하여 내 문제를 해결합니다.
androidx.constraintlayout.ConstraintLayout
...에
androidx.constraintlayout.widget.ConstraintLayout
androidx.constraintlayout.ConstraintLayout
종속성에 추가 하십시오.
dependencies {
// https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
저장소는 mavenCentral()
입니다.
만약 추가 한 후 mavenCentral ()을 당신의 Gradle을 파일 저장소로하고 변경 androidx.constraintlayout.ConstraintLayout
하는 androidx.constraintlayout.widget.ConstraintLayout
문제는 다음 일을 시도가 해결되지 않는 무효화 캐시와 다시 시작 파일 메뉴에서. 그것은 나를 위해 일했습니다.
build.gradle => 종속성 버전 확인
implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
바꾸다
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
문제를 해결했다
나는 다음과 같은 문제가 있습니다.
- androidx로 마이그레이션 지원 라이브러리;
- targetSdkVesrsion을 29로 증가시킵니다.
또한 다음을 사용합니다.
implementation "uk.co.chrisjenx:calligraphy:2.3.0"
이 질문의 모든 게시물을 시도했지만 성공하지 못했습니다.
.disableCustomViewInflation()
Calligraphy init에 하나의 문자열 을 추가하여 수정합니다 .
@Override
public void onCreate() {
super.onCreate();
// ...
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Sans-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
.disableCustomViewInflation() // <----- this fix
.build());
// ...
}
나는 다음 캘리 그라피 (크리스토퍼 젠킨스의 훌륭한 일에 감사드립니다)의 릴리스가 그것을 내부에서도 고칠 수 있기를 바랍니다.
를 클릭 한 후 Refactor -> Migrate to AndroidX
build.gradle (Module : app)의 모든 종속성이 최신 버전으로 표시되었는지 확인합니다 .
If its not, dependency will appear in yellow highlighted color and you can change it by hovering the mouse over it.
Secondly, Change the ConstraintLayout tag in all XML layout files to
androidx.constraintlayout.widget.ConstraintLayout
For more safer option, clean your project and sync it again after the above steps.
I had the same problem, I resolved it as follows:
In your dependecies if you have added
implementation 'androidx.constraintlayout:constraintlayout:1.x.x'
that is correct
but in your xml layout file you have to use the widget as
androidx.constraintlayout.widget.ConstraintLayout
yepp. mavenCentral() and correct dependencies solve my same problems
I had a similar error.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2757)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2818)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6393)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:652)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:812)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.myapp.MainActivity.onCreate(MainActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6858)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2710)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2818)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6393)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/constraintlayout/widget/R$styleable;
at androidx.constraintlayout.widget.ConstraintLayout.init(ConstraintLayout.java:590)
at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:567)
... 23 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.widget.R$styleable" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 25
Following the recomendations:
add androidx.constraintlayout.ConstraintLayout to the dependencies:
dependencies {
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
And the repository mavenCentral().
Works for me. I could compile the APK.
for me this problem solved when change the gradle
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
to
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
sync and then clean project
that's so stupid
I updated the dependency, yet it did not resolve the error. Then I did a clean project and build and it is working now.
I copied and pasted an existing ConstraintLayout tag from the xml, which was causing the issue for me. Simply deleting, and re-adding the ConstraintLayout tags in AndroidStudio from scratch fixed the issue for me.
problem in your layout xml file
change this androidx.constraintlayout.ConstraintLayout
to linear layout check your log
'programing tip' 카테고리의 다른 글
AngularJS 지시문 동적 템플릿 (0) | 2020.11.23 |
---|---|
상수의 병적 사용 (0) | 2020.11.23 |
C에서 참조로 배열을 전달합니까? (0) | 2020.11.23 |
언제 RuntimeException을 잡아도 괜찮습니까? (0) | 2020.11.23 |
C / C ++ 프로그램이 main () 전에 충돌 할 수있는 방법이 있습니까? (0) | 2020.11.23 |