新しいアプリを作成してUse Android X artifacts
何も変更せずに、私の電話とエミュレータでアプリがクラッシュします。
私は私の友人に、アプリを作成する方法を繰り返すように頼みました。
Android Xを使用するのは初めてです。X、何か問題がありますか?Android Studio 3.3.0.20をスナップで実行しています(Linux))。
2019-02-08 17:54:44.477 5487-5487/worshifter.com.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: worshifter.com.myapplication, PID: 5487
Java.lang.RuntimeException: Unable to start activity ComponentInfo{worshifter.com.myapplication/worshifter.com.myapplication.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:2913)
at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:3048)
at Android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.Java:78)
at Android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.Java:108)
at Android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.Java:68)
at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1808)
at Android.os.Handler.dispatchMessage(Handler.Java:106)
at Android.os.Looper.loop(Looper.Java:193)
at Android.app.ActivityThread.main(ActivityThread.Java:6669)
at Java.lang.reflect.Method.invoke(Native Method)
at com.Android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.Java:493)
at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:858)
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:343)
at Android.view.LayoutInflater.createView(LayoutInflater.Java:647)
at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:790)
at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:730)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:492)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:423)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.Java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.Java:140)
at worshifter.com.myapplication.MainActivity.onCreate(MainActivity.Java:12)
at Android.app.Activity.performCreate(Activity.Java:7136)
at Android.app.Activity.performCreate(Activity.Java:7127)
at Android.app.Instrumentation.callActivityOnCreate(Instrumentation.Java:1271)
at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2893)
at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:3048)
at Android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.Java:78)
at Android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.Java:108)
at Android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.Java:68)
at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1808)
at Android.os.Handler.dispatchMessage(Handler.Java:106)
at Android.os.Looper.loop(Looper.Java:193)
at Android.app.ActivityThread.main(ActivityThread.Java:6669)
at Java.lang.reflect.Method.invoke(Native Method)
at com.Android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.Java:493)
at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:858)
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)
at Java.lang.reflect.Constructor.newInstance0(Native Method)
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:343)
at Android.view.LayoutInflater.createView(LayoutInflater.Java:647)
at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:790)
at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:730)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:492)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:423)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.Java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.Java:140)
at worshifter.com.myapplication.MainActivity.onCreate(MainActivity.Java:12)
at Android.app.Activity.performCreate(Activity.Java:7136)
at Android.app.Activity.performCreate(Activity.Java:7127)
at Android.app.Instrumentation.callActivityOnCreate(Instrumentation.Java:1271)
at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2893)
at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:3048)
at Android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.Java:78)
at Android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.Java:108)
at Android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.Java:68)
at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1808)
at Android.os.Handler.dispatchMessage(Handler.Java:106)
at Android.os.Looper.loop(Looper.Java:193)
at Android.app.ActivityThread.main(ActivityThread.Java:6669)
at Java.lang.reflect.Method.invoke(Native Method)
at com.Android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.Java:493)
at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:858)
2019-02-08 17:54:44.478 5487-5487/worshifter.com.myapplication E/AndroidRuntime: Caused by: Java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.widget.R$styleable" on path: DexPathList[[Zip file "/data/app/worshifter.com.myapplication-gnuqp7fLCQHjhJ5ZKGKRAQ==/base.apk"],nativeLibraryDirectories=[/data/app/worshifter.com.myapplication-gnuqp7fLCQHjhJ5ZKGKRAQ==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.Java:134)
at Java.lang.ClassLoader.loadClass(ClassLoader.Java:379)
at Java.lang.ClassLoader.loadClass(ClassLoader.Java:312)
... 28 more
EditがAndroid.enableJetifier=true
アプリが動作します。
同じ問題があります。ご覧のとおり、ログに表示されます:Error inflating class androidx.constraintlayout.widget.ConstraintLayout at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2913)
プロジェクトレベルに移動する必要がありますbuild.gradle
およびConstraintLayoutを最新バージョンに更新します(ベータ版から他のすべての依存関係も更新することをお勧めします)。
デフォルトの依存関係:
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.core:core-ktx:1.1.0-alpha04'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
実際のバージョン:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
また、この問題に関するバグレポートを作成しました: https://issuetracker.google.com/issues/122892917
解決策は、build.gradle
ファイルでライブラリを最新バージョンにアップグレードするのと同じくらい簡単です。
ヒント:Android Studioのリンティング機能を使用して、ライブラリを最新バージョンに更新します(Left Alt+Enter Windows)