BUG记录之——关于AS的一些红buffer总结(持续更新中)

以下所内容纯属个人开发过程中遇到BUG后查阅相关解决办法所记录的,如有错误之处还望指出吐舌头

1.

在将AdroidStudio升级到版本2.2.2后出现:

Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap问题。
解决的办法是:
在你的project中的gradle下gradle.properties文件中
关于使用AdroidStudio 出现的Error:Unable to start the daemon process. 问题的解决。 - capt_jacks - capt_jacks的博客
 将 org.gradle.jvmargs = -Xmx512m等号右边的值改为-Xmx512m
  关于使用AdroidStudio 出现的Error:Unable to start the daemon process. 问题的解决。 - capt_jacks - capt_jacks的博客
 然后重新build就好了。具体出现这个问题的原因是gradle的问题。


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

出现此错误clean一下项目就可以了: Build -> Clean Project or Build -> Rebuild Project

5.

Error:A problem was found with the configuration of task ':app:packageDebug' 问题解决


导入到AndroidStudio 时,报错:

[html]  view plain  copy
  1. Error:A problem was found with the configuration of task ':app:packageDebug'.  
  2. > File 'E:\AndroidStudio\work\AUWoQu\YingYongShiChang\app\build\intermediates\res\resources-debug-stripped.ap_' specified for property 'resourceFile' does not exist.  

解决办法 :

打开app的build.gradle

将shrinkResources 设置为false


[html]  view plain  copy
  1. buildTypes {  
  2.         release {  
  3.             minifyEnabled true  
  4.             shrinkResources false  
  5.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'  
  6.         }  
  7.         debug {  
  8.             //开启代码混淆  
  9.             minifyEnabled false  
  10.             // 移除无用的resource文件  
  11.             shrinkResources false  
  12.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'  
  13.         }  
  14.     }  

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值