Android Studio 错误Error:(16, 13) Failed to resolve: com.android.support:support-v4:15.+ android.vi

错误1:
Error:(16, 13) Failed to resolve: com.android.support:support-v4:15.+
<a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile:D:/UserData/scxh/Desktop/call/call/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>


解决办法:
方法一:
打开build.gradle文件,看dependencies{   }里面是不是有compile 'com.android.support:support-v4:15.+'和compile files('libs/android-support-v4.jar')两个,如果有就删除没找到的那个,比如上面的例子就该删除compile 'com.android.support:support-v4:15.+'
方法二:在android sdk manager上把 android library support的库也都装上,重新build。


错误2:
android.view.InflateException: Binary XML file line #7: Error inflating class fragment
关键log:
Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
Caused by: java.lang.IllegalArgumentException: Binary XML file line #7: Must specify unique android:id, android:tag, or have a parent with an id for fragment_demo.fragment.FragmentTwo

解决办法:看报错类对应布局里的Fragment 是否定义了id属性。把id属性加上。XML布局文件中Fragment标签必须设置id属性。




注意事项:
Android SDK 6.0的Fragment回调方法中的android.view.InflateException:参数为Content很有可能不会执行的哟。其他都没错的话就看看这个方法执行没有吧。
    @Override
    public void onAttach(Content content) {
        super.onAttach(content);
        Log.d("test", "onAttach:00000000000000000000000 ");
        Mylog.d("onAttach-------------------------");
    }


若没执行还是用SDK6.0之前用的onAttach(Activity activity)参数为Activity回调方法吧。
 @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        Log.d("test", "onAttach:00000000000000000000000 ");
        Mylog.d("onAttach-------------------------");
    }

你可能感兴趣的:(TO,failed,resolve,co)