安装 Android SDK Build-Tools 26 后无法启动 activity ComponentInfo{...}
Unable to start activity ComponentInfo{...} after installing Android SDK Build-Tools 26
我将 Android Studio 升级到 2.3.3
然后我安装了Android SDK Build-Tools 26
和Android 8.0 (O)
并设置 compileSdkVersion 和 targetSdkVersion 为 26
和“26.0.0”上的 buildToolsVersion
然后我将所有库版本从 25.3.1 更改为 26.0.0-alpha1
现在我有以下运行时异常:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mysite.myapp/com.mysite.myapp.MainActivity}: android.view.InflateException: Binary XML file line #35: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2480)
at android.app.ActivityThread.access0(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1377)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5725)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1030)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825)
Caused by: android.view.InflateException: Binary XML file line #35: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.mysite.myapp.MainActivity.onCreate(MainActivity.java:65)
at android.app.Activity.performCreate(Activity.java:6018)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2480)
at android.app.ActivityThread.access0(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1377)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5725)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1030)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825)
Caused by: java.lang.IllegalArgumentException: Setting FragmentDrawer{28990c1 #0 id=0x7f0f0095} as the target of FragmentDrawer{28990c1 #0 id=0x7f0f0095} would create a target cycle
at android.support.v4.app.Fragment.setTargetFragment(Fragment.java:636)
at com.mysite.myapp.Fragments.FragmentDrawer.onCreate(FragmentDrawer.java:83)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2226)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1502)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1737)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3512)
at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:330)
at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:75)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.mysite.myapp.MainActivity.onCreate(MainActivity.java:65)
at android.app.Activity.performCreate(Activity.java:6018)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2480)
at android.app.ActivityThread.access0(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1377)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5725)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1030)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825)
(MainActivity.java:65) 和 (FragmentDrawer.java:83) 显示为 link.
MainActivity.java:65 内容:
setContentView(R.layout.activity_main);
FragmentDrawer.java:83 内容:
setTargetFragment(FragmentDrawer.this, 100);
在 MainActivity 之前有一个 SplashActivity,它 运行 没有任何问题!
我刚刚将 SDK Build-Tools、compileSdkVersion、targetSdkVersion、buildToolsVersion 和库版本再次降级到 运行 并进行测试。使用预览版没有问题。
谁能帮帮我?我如何 运行 我的应用程序使用新的 SDK 版本?
问题在这里:
java.lang.IllegalArgumentException:
Setting FragmentDrawer{28990c1 #0 id=0x7f0f0095} as the target of
FragmentDrawer{28990c1 #0 id=0x7f0f0095} would create a target cycle
at android.support.v4.app.Fragment.setTargetFragment(Fragment.java:636)
setTargetFragment
已在 26.0.0
中更改。之前,它只是简单地设置目标片段加上请求代码。从 26.0.0
开始,它在执行此操作之前包含两个检查:
- 检查当前片段和目标片段是否属于同一个片段管理器
- 它通过扫描此片段中的目标片段列表并查看目标片段是否已经存在,检查设置目标片段是否会创建循环。
因此,您以某种方式设置了之前设置的目标片段。不再允许了。
我将 Android Studio 升级到 2.3.3
然后我安装了Android SDK Build-Tools 26
和Android 8.0 (O)
并设置 compileSdkVersion 和 targetSdkVersion 为 26
和“26.0.0”上的 buildToolsVersion
然后我将所有库版本从 25.3.1 更改为 26.0.0-alpha1
现在我有以下运行时异常:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mysite.myapp/com.mysite.myapp.MainActivity}: android.view.InflateException: Binary XML file line #35: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2480) at android.app.ActivityThread.access0(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1377) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:155) at android.app.ActivityThread.main(ActivityThread.java:5725) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1030) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825) Caused by: android.view.InflateException: Binary XML file line #35: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.mysite.myapp.MainActivity.onCreate(MainActivity.java:65) at android.app.Activity.performCreate(Activity.java:6018) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2480) at android.app.ActivityThread.access0(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1377) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:155) at android.app.ActivityThread.main(ActivityThread.java:5725) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1030) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825) Caused by: java.lang.IllegalArgumentException: Setting FragmentDrawer{28990c1 #0 id=0x7f0f0095} as the target of FragmentDrawer{28990c1 #0 id=0x7f0f0095} would create a target cycle at android.support.v4.app.Fragment.setTargetFragment(Fragment.java:636) at com.mysite.myapp.Fragments.FragmentDrawer.onCreate(FragmentDrawer.java:83) at android.support.v4.app.Fragment.performCreate(Fragment.java:2226) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1502) at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1737) at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3512) at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120) at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:330) at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39) at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:75) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.mysite.myapp.MainActivity.onCreate(MainActivity.java:65) at android.app.Activity.performCreate(Activity.java:6018) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2480) at android.app.ActivityThread.access0(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1377) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:155) at android.app.ActivityThread.main(ActivityThread.java:5725) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1030) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825)
(MainActivity.java:65) 和 (FragmentDrawer.java:83) 显示为 link.
MainActivity.java:65 内容:
setContentView(R.layout.activity_main);
FragmentDrawer.java:83 内容:
setTargetFragment(FragmentDrawer.this, 100);
在 MainActivity 之前有一个 SplashActivity,它 运行 没有任何问题!
我刚刚将 SDK Build-Tools、compileSdkVersion、targetSdkVersion、buildToolsVersion 和库版本再次降级到 运行 并进行测试。使用预览版没有问题。
谁能帮帮我?我如何 运行 我的应用程序使用新的 SDK 版本?
问题在这里:
java.lang.IllegalArgumentException:
Setting FragmentDrawer{28990c1 #0 id=0x7f0f0095} as the target of
FragmentDrawer{28990c1 #0 id=0x7f0f0095} would create a target cycle
at android.support.v4.app.Fragment.setTargetFragment(Fragment.java:636)
setTargetFragment
已在 26.0.0
中更改。之前,它只是简单地设置目标片段加上请求代码。从 26.0.0
开始,它在执行此操作之前包含两个检查:
- 检查当前片段和目标片段是否属于同一个片段管理器
- 它通过扫描此片段中的目标片段列表并查看目标片段是否已经存在,检查设置目标片段是否会创建循环。
因此,您以某种方式设置了之前设置的目标片段。不再允许了。