以下所内容纯属个人开发过程中遇到BUG后查阅相关解决办法所记录的,如有错误之处还望指出
1.
在将AdroidStudio升级到版本2.2.2后出现:
![关于使用AdroidStudio 出现的Error:Unable to start the daemon process. 问题的解决。 - capt_jacks - capt_jacks的博客](http://img2.ph.126.net/ioNkG7SJqDOSv0Jckn3Qlg==/6631727472678611192.png)
![关于使用AdroidStudio 出现的Error:Unable to start the daemon process. 问题的解决。 - capt_jacks - capt_jacks的博客](http://img2.ph.126.net/EGzUayhQ4MAq8qxnhwXLAQ==/6632167277326631354.png)
2.
使用Android studio rebuild项目时报错:Error:(1, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Invalid revision: 12.0.2753695 beta 1
这是因为项目的配置由于工具更新或其他原因更改了。
具体配置文件:项目目录下的 build.gradle 文件
文件中有这样一段代码:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
你需要将classpath 的版本改回原来的样子我之前版本是2.1.0。之后同步即可
3.
导入eclipse项目,可能会出现lib png not file,原因是图片不是png格式,改成jpg试试
4.java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
根据提示来使用AppCompat的theme
<activity
android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:label="@string/app_name" >
4.
Error:Execution failed for task ':app:processDebugResources'. > java.io.IOException: Could not delete folder “” in android studio
Error:A problem was found with the configuration of task ':app:packageDebug' 问题解决
导入到AndroidStudio 时,报错:
解决办法 :
打开app的build.gradle
将shrinkResources 设置为false
6.
activity往fragment传值,大家都知道不能通过fragment的带参数的构造函数来传值,为什么呢,原因如下:
Avoid non-default constructors in fragments: use a default constructor plusFragment#setArguments(Bundle)
instead
From the Fragment documentation:
Every fragment must have an empty constructor, so it can be instantiated when restoring its activity's state. It is strongly recommended that subclasses do not have other constructors with parameters, since these constructors will not be called when the fragment is re-instantiated; instead, arguments can be supplied by the caller with setArguments(Bundle)
and later retrieved by the Fragment with getArguments()
.
通常我们会先给fragment写一个单例模式,
public static TestFragment getInstance(String arg1,int arg2){
Bundle bundle = new Bundle();
bundle.putString("String",arg1);
bundle.putInt("int",arg2);
TestFragment fragment = new TestFragment();
fragment.setArguments(bundle);
returen fragment
}
然后在Fragment的oncreate()方法中直接getArguments()就能得到bundle对象了,通过bundle就能获取到传递过来的参数了。
fragment往activity传值,通过接口回调来传值,把fragment和activity联系到一起的方法是onAttach(Activity activity)方法,具体做法如下:
先在fragmen中onattach(Activity activity)方法中得到activity的对象,然后赋值给你自己定义的接口,具体做法如下:
private CallBack callBack;
interface CallBack{
void test(String str);
}
@override
public void onAttach(Activity activity){
callBack = (CallBack)getActivity();
}
然后在你需要传递参数的地方调用callBack.test("haha");到此在fragment中要做的工作就做完了,然后就是在需要获得fragment中的参数的activity中,先实现CallBack接口,然后实现这个接口的方法就ok了,这个时候就能获取到fragment中传过来的参数了。
7.Android studio突然蓝屏 然后开启之后无法使用svn的解决办法
解决办法:找到C:\Users\Administrator\.AndroidStudio2.3\config文件夹下的disabled_plugins.txt,删除disabled_plugins.txt文件中的subversion,保存并重启Android studio即可重新使用svn.
感谢:http://blog.163.com/capt_jacks/blog/static/259351015201692952733257?ignoreua