添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
安静的斑马  ·  javascript - ...·  1 年前    · 

1、java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.res.AssetManager android.content.res.Resources.getAssets()’ on a null object reference抛出这个错误是在安装apk的时候就黑屏了,刚开始百思不得其解,明明还没有调用getAssets()就一直抛出这个异常,各种加日志加注释没找到问题所在。最后既然提示这个android.content.res.Resources为空,就在Application的onCreate()加判断发现getResource确实为空

RuntimeException: Unable to start activity ComponentInfo{com.../com...activity.SignInActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.content.res.Resources.getAssets()' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
    at android.app.ActivityThread.access$800(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    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:902)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.content.res.Resources.getAssets()' on a null object reference
    at android.app.LoadedApk.getAssets(LoadedApk.java:528)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:584)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2243)
    ... 10 more
//解决方法:在ApplicationonCreate()加判断,getResource()为空的时候杀死当前进程
    if (null == getResources()){
        System.out.println("---********----------killProcess----2----***********---");
        Process.killProcess(Process.myPid());

2、The content of the adapter has changed but ListView did not receive a notification,listview中adapter绑定的数据发生变化的时候UI还没更新就点击item就会抛出这个异常崩溃
这里写图片描述
这里写图片描述
选择类别的时候碰到列表崩溃

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131427470, class android.widget.ListView) with Adapter(class com..adapter.ExportVideoAdapter)]
    at android.widget.ListView.layoutChildren(ListView.java:1562)
    at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4498)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:773)
    at android.view.Choreographer.doCallbacks(Choreographer.java:586)
    at android.view.Choreographer.doFrame(Choreographer.java:555)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:759)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    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:902)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
    at Android.MODEL(msm8909)
    at Android.VERSION(5.1.1)
    at Android.FINGERPRINT(qcom/msm8909/msm8909:5.1.1/LMY47V/icar09111534:userdebug/test-keys)
//解决方法:在list数据改变的时候在主UI线程调用adapter的notifyDataSetChanged()通知数据改变了要更新UI,在
//notifyDataSetChanged()之前调用listview.setVisibility(View.GONE)之后调用 //listview.setVisibility(View.VISIBLE);
//代码如下:
listview.setVisibility(View.GONE);
adapter.notifyDataSetChanged();
listview.setVisibility(View.VISIBLE);

3.在维护一个比较老的项目的时候,发现一个问题,在发出请求的时候去切换网络APP崩溃了,看抛出的异常内容被消耗了,其实是EntityUtils.toString调用了两次,response只能一次消耗完,不能多次读取。

解决方法:直接使用trycacth抛出异常,或者保存response值,每次请求赋值,通过保存的response取值。

java.lang.IllegalStateException: Content has been consumed
    at org.apache.http.entity.BasicHttpEntity.getContent(BasicHttpEntity.java:89)
    at org.apache.http.conn.BasicManagedEntity.getContent(BasicManagedEntity.java:105)
    at org.apache.http.util.EntityUtils.toString(EntityUtils.java:117)
    at org.apache.http.util.EntityUtils.toString(EntityUtils.java:151)
    at net.babelstar.common.http.AbstractAsyncResponseListener.onResponseReceived(AbstractAsyncResponseListener.java:57)
    at net.babelstar.common.http.AsyncHttpSender.onPostExecute(AsyncHttpSender.java:117)
    at net.babelstar.common.http.AsyncHttpSender.onPostExecute(AsyncHttpSender.java:1)
    at android.os.AsyncTask.finish(AsyncTask.java:651)
    at android.os.AsyncTask.access$500(AsyncTask.java:180)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7231)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

4.Android中使用AS有时候会出现xml布局显示不出来,并报如下信息:

The following classes could not be instantiated:
- android.support.v7.widget.RecyclerView (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)
- android.support.v7.internal.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache)
- android.support.v7.internal.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)
- android.support.v7.internal.widget.ActionBarOverlayLayout (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  Exception Details java.lang.ClassNotFoundException: android.support.v4.view.ViewPropertyAnimatorListener Copy stack to clipboard
**解决方法:**在style.xml中的<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> Theme前加Base.就可以了
                    1、java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.res.AssetManager android.content.res.Resources.getAssets()’ on a null object reference抛出这个错误是在安装apk的时候就黑屏了,刚开始百思不得其解,
				
1.双击无法打开 cas 或者路径出现乱码; 2.读入网格时,error:File haswrong dimensions(2) 3.the use of axis boundary conditions is not appropriate for 2D/3D flow problem. 4.error:divergence detected in AMG solver 5.error:temperature divergence detected in AMG solver 6.turbulent viscosity limited to viscosity ratio of 1.000000e+5 in 7.error:floating point error:invalid number. 8.Reverse flow infaces on pressure-outlet-X 9.temperature limited to 1.0000e+00 10.fluent received a fatal signal (SEGMENTATION VIOLATION) 11.……
异常信息: java.lang.RuntimeException: Unable to start activity ComponentInfo{***.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.co...
Failed to load resource Error: getaddrinfo ENOENT 毕设做的是部署到服务器上的uwsgi+nginx+django,出现了以上的问题。 最后发觉可能是看起来和这些提示毫无关系的问题: 例如数据库出现了脏数据,我使用python3 manage.py shell之后,手动加入了一条数据,我以为没问题,实际上是有问题的,肯定有些属性之类的没加入,或者没考虑到表之间的关系,总之我把这条数据删了。 s = Employees.objects.get(real_name
int a = 10; int b = 0; // 实际上JVM在执行到此处的时候,会new异常对象:new ArithmeticException("/ by zero"); // 并且JVM将new的异常对象抛出,打印输出信息到控制台了。 int c = a / b; System.out.println(a + "/" + b + "=" + c); // 此处运行也会创建一个:ArithmeticException类型的异常对象。
问题背景:在没有网络的情况下调试4个插页的导航栏的时候,多次快速的来回切换插页,就会崩溃,定位日志发现: Toast.makeText(getActivity(), "当前无网络", Toast.LENGTH_LONG).show(); 这个context出了问题,后来查阅资料,大概的意思就是,当前这个界面已经被延迟执行了,再想getactivity()是不行了,所以要加一个判断“isadd(...
有关问题:java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context cn.bmob.v3 适用于bmob登录或注册板块 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.myapplication2, PID: 27279 java.lang.NullPointerException: Attempt to invo
PackageManage隐藏接口 public abstract void installPackage(Uri packageURI,IPackageInstallObserver observer, int flags,String installerPackageName); packageURI:要安装apk的位置,可以是file或者url observer:当apk安装完成...
android报错提示: java.lang.NullPointerException: Attempt to invoke virtual methodandroid.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)’ on a null object reference 在Andr
super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); //开始运行时就把库先建好 //我在这边一开始犯了个错,把创建DBHelper和DTBase代码放上面去了 // 这导致报错Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null obj
这里写目录标题一、java.lang.OutOfMemoryError: PermGen space 一、java.lang.OutOfMemoryError: PermGen space 发生原因及问题复现 使用Tomcat 6 启动项目,控制台报错 问题分析 Tomcat 6 经过查询,此问题是堆内存不足,调整JVM参数即可解决。 PermGen(永久代)的默认尺寸比较小,64M,进行大量操作变量时,会经常发生 解决原因 项目启动时设置合适JVM参数 -Xms1024m -Xmx1024
问题就是直接运行没什么问题,但是打包给测试测就会出现json解析错误。 由此可见应该是打包混淆的时候出了问题。 检查了一下实体类,都在一个文件下下,都保持了,应该没什么问题 最后检查log看到,com.alibaba.fastjson.JSONException: default constructor not found 定位到对应的类, 查看报错信息 android.system.ErrnoException: open failed: EACCES (Permission denied) at libcore.io.Linux.open(Native Method) java.io.FileNotFoundException: /system/build.prop: open failed: EACCES (Permission
本来是想做一个取色器,但是运行时总是会报一个错误: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference 在网上找了半天
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference at android.content.ComponentName.&lt...
eclipse导入项目报 Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder FileNotFoundException: /storage/emulated/0/Pictures/1582: open failed: EACCES (Permission denied)