天天看点

《报错与问题解决方案》总结v1.0版本

1、(Android)Activity.getWindowManager().getDefaultDisplay().getWidth()已被废弃

2、(Android)Description Resource Path Location Type AndroidManifest.xml file missing!

3、(Android)xxx cannot be resolved to a type

4、(Android)java.lang.RuntimeException: Unable to start activity Activity无法打开

5、(Android)Failed to resolve: com.android.support:appcompat-v7:28.0.0-alpha

6、(Android)java.lang.NullPointerException

7、(ADT)找不到android.support.v4.view.ViewPager

8、(Android)This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView)

9、(Android)Description Resource Path Location Type Call requires API level 9 (current min is 8):

10、(Android)java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.Bu

11、(Android)android.app ClassCastException。SharedPreferencesImpl不能被强制转换为android.content.Shared

12、(Android)android.content.ActivityNotFoundException:activity in yourAndroidManifest.?

13、(Android)Description Resource Path Location Type Unparsed aapt error(s)! Cheheck the console for o

14、(Android)完美解决EditText和ScrollView的滚动冲突

15、(JavaWeb)bug记录

16、(Android)java.lang.ClassCastException: .MainActivity cannot be cast to java.lang.Runnable

17、(Android)unknow host service.gradle.org, proxy settings in gradle

18、(Flutter)No pubspec.yaml file found. This command should be run from the root of your Flutter project. Do not

19、(Flutter)Navigator operation requested with a context that does not include a Navigator.

Navigator operation requested with a context that does not include a Navigator.

20、(Flutter)ListView和GridView嵌套报错?

21、(Android)table burner has no column named USER (code 1): , while compiling: INSERT INTO burner(USER,YELL

22、(Android)android.database.sqlite.SQLiteException: no such column: id (code 1): , while compiling: select

23、(Android)Error inserting GREEM=30 YELLOW=4 RED=5 android.database.sqlite.SQLiteException: no such tab

24、(Flutter)ListView不能直接嵌套ListView

25、(Flutter)Expanded组件不能直接嵌套LitView

26、(Android)setOnPageChangeListener 过时了怎么办?

27、(Android)java.lang.ClassCastException: com.github.mikephil.charting.charts.PieChart cannot be cast

28、(Android) Caused by: java.lang.ClassCastException: com.github.mikephil.charting.charts.PieChart can

29、(Android)IllegalStateException: The specified child already has a parent问题解决办法

30、(Android)setBackgroundResource无反应?

31、(Java)利用SimpleDateFormat格式化时间不准确

32、(Git)git push报错error: failed to push some refs to

33、(gitee)在码云上如何创建仓库

34、(Android)ImageView报错:不是可绘制对象(颜色或路径)

35、(MySQL)MySQL Server 安装失败

36、(SSL)无法建立SSL连接

37、(Ubuntu)python3.6升级到python3.7

38、(Ubuntu)su root无法切换到root用户

39、(Ubuntu)source ~/.bashrc 无法执行

40、(Ubuntu)安装Python版本出现No module named ‘apt_pkg‘

41、(Ubuntu)Running pip as root will break packages and permissions. You should install packages reliably by usi

42、(Ubuntu)安装并配置好 hb后,hb -h检测不对

43、(OpenHarmony)[OHOS ERROR] clang not found, install it please

44、(OpenHarmony)FAILED: libcjson_shared.so unstripped/usr/lib/libcjson_shared.so

45、(Ubuntu)Could not start AVD

46、(Git)fatal: Not a git repository (or any parent up to mount point /home)

47、(DevEco Studio) Could not install Gradle distribution

48、(HarmonyOS)Gradle在哪里下载

59、(Android)metalava was unable to determine the package name

50、(Android)Toast不显示的解决方案

51、(Ubuntu)terminal同一窗口多开

52、(Android)开发里跳过的坑-电源锁WakeLock不起作用

53、(ADB)如何退出adb logcat

解决办法:

方法一:

// 通过WindowManager获取

DisplayMetrics dm = new DisplayMetrics();

getWindowManager().getDefaultDisplay().getMetrics(dm);

System.out.println(“width-display :” + dm.widthPixels);

System.out.println(“heigth-display :” + dm.heightPixels);

方法二:

// 通过Resources获取

DisplayMetrics dm2 = getResources().getDisplayMetrics();

System.out.println(“width-display :” + dm2.widthPixels);

System.out.println(“heigth-display :” + dm2.heightPixels);

点击工具栏上面的Project:

顺序为:

Project>clean then Project>Build All

右键自己的Project → Properties → Resource → Other → UTF-8

亲测可行~!

解决java.lang.RuntimeException: Unable to start activity Activity无法打开的问题

原文链接:javascript:void(0)

出现这个错误是因为我们的依赖库中,报的错误

打个比方,我之前有一个依赖不小心改成了:

《报错与问题解决方案》总结v1.0版本

改正后

《报错与问题解决方案》总结v1.0版本

即可解决问题

原文:java.lang.NullPointerException - 如何处理空指针异常

我的思路是:

首先先导入.v4包:具体步骤

导入v4包步骤

然后再在界面中直接这么写即可:无需关心快捷键中是否有

android.support.v4.view.ViewPager

菜单栏window ——>Preferences——>Android——>Lint error Checking——>在issues搜索:Instantiatable

《报错与问题解决方案》总结v1.0版本

翻译错误:描述资源路径位置类型

调用需要API级别9(当前最小值为8):android.content.SharedPreferences。应用shezhifragment.java /JiaoTong_Textc/com/example/jiaotong_text行127 android Lint问题

java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.Button.

翻译:. lang。android.widget ClassCastException。无法将TextView转换为android.widget.Button

意思就是说:代码中有按钮成员变量,却绑定的文本框组件,所以发生了异常

. lang。android.app ClassCastException。SharedPreferencesImpl不能被强制转换为android.content.SharedPreferences$Editor

极有可能是因为:

所以类型不匹配无法强制转换

这种错误很奇葩,有时候是因为工程自身出了问题,新建项目即可解决该问题

还有种情况,是我们把AndroidManifest.XML,删掉保存,再返回,保存,重新运行下项目,又可以对了

Description Resource Path Location Type

Unparsed aapt error(s)! Check the console for output. JiaoTong_Text line 1 Android ADT Problem

翻译:描述资源路径位置类型

未解析aapt错误(s) !检查控制台的输出。android ADT问题

《报错与问题解决方案》总结v1.0版本

在网上搜了一下EditText和ScrollView的滚动冲突,发现几乎所有的解决方案都是触摸EditText的时候就将事件交由EditText处理,否则才将事件交由ScrollView处理。这样确实初步解决了两者之间的滚动冲突,但并不是最好的解决方案。比如,EditText本来可以显示6行文本,但是目前只显示了5行文本,此时我们在EditText区域进行滑动并期望整个页面能够滚动,但由于我们将事件交给了EditText进行处理,所以页面并不能滚动,这样的体验是极差的。其实我们更希望当EditText出现滚动条的时才将滚动事件交由它本身处理,其他情况下应当让ScrollView来处理。那么该如何进行实现呢?接下来咱们就做一个小Demo来实现这种方案。

1.布局文件

首先编写布局文件,可以看出这是非常简单的一个布局:一个ScrollView包裹着一个垂直方向的LinearLayout,LinearLayout中有两个TextView和一个EditText,其中为了区分EditText的范围,给其设置了一个背景rectangle_shape。

2.rectangle_shape

背景rectangle_shape的代码,更没有什么技术含量。。。。。。

3.MainActivity中的代码

这里就是主要的代码逻辑了。先给EditText设置OnTouchListener,然后先在OnTouch方法中判断当前点击的区域是否为EditText,如果为EditText区域则再判断是否可以在垂直方向上进行滚动,如果可以滚动则将事件交由EditText处理,否则将事件交由ScrollView处理。

此处最重要的就是如何判断EditText区域在垂直方向上可以滚动,此处的代码已经封装成了一个方法,大家可以直接使用。那么为什么要这样判断呢?如果大家仍有兴趣,请继续阅读完美解决EditText和ScrollView的滚动冲突(下)。

————————————————

今天来跟大家谈一下一个,我在做一个新闻项目的时候,遇到的一个很有意思的小Bug

报错的信息如下:

《报错与问题解决方案》总结v1.0版本

原因分析:

《报错与问题解决方案》总结v1.0版本

解决方法:

《报错与问题解决方案》总结v1.0版本

像这种情况肯定是:

我们将其他项目导入到android studio 中的时候,如果gradle版本不对,经常会出现:

《报错与问题解决方案》总结v1.0版本

解决办法很简单,只需要在工程的build.gradle 文件中 将 classpath 修改为当前的gradle版本即可。

《报错与问题解决方案》总结v1.0版本

什么?你不知道当前gradle 版本号是多少?

最简单无脑的方法:新建一个项目,然后看看里面的工程build.gradle中的 classpath是多少,ctrl c —ctrl v。

结束 ,就是这么简单!

Error: No pubspec.yaml file found.

This command should be run from the root of your Flutter project.

Do not run this command from the root of your git clone of Flutter.

翻译:

错误:找不到pubspec.yaml文件。

此命令应从Flutter项目的根目录运行。

不要从Flutter的git克隆的根目录运行此命令

解决:

只需要将根目录切换到当前工程文件即可:如下

cd flutter_app02,切换到当前工程

然后在flutter run运行项目即可!

flutter 最容易报的一个错误就是does not include,因为其思想是组合

这种情况即使是外面包裹了materialapp也是无效的,因为flutter会根据这个context一直上溯,一直到根节点的widget,注意,上溯是根据context的,会上溯到这个context相关的widget的最根节点

14down vote

This error is unrelated to the destination. It happens because you used a context that doesn’t contain a Navigator instance as parent.

How do I create a Navigator instance then ?

This is usually done by inserting in your widget tree a MaterialApp or WidgetApp. Although you can do it manually by using Navigator directly but less recommended. Then, all children of such widget can access NavigatorState using Navigator.of(context).

Wait, I already have a MaterialApp/WidgetApp !

That’s most likely the case. But this error can still happens when you use a context that is a parent of MaterialApp/WidgetApp.

This happens because when you do Navigator.of(context), it will start from the widget associated to the context used. And then go upward in the widget tree until it either find a Navigator or there’s no more widget.

In the first case, everything is fine. In the second, it throws a

So, how do I fix it ?

First, let’s reproduce this error :

This example creates a button that attempts to go to ‘/’ on click but will instead throw an exception.

Notice here that in the

onPressed: () => Navigator.pushNamed(context, “/”),

we used context passed by to build of MyApp.

The problem is, MyApp is actually a parent of MaterialApp. As it’s the widget who instantiate MaterialApp! Therefore MyApp’s BuildContext doesn’t have a MaterialApp as parent!

To solve this problem, we need to use a different context.

In this situation, the easiest solution is to introduce a new widget as child of MaterialApp. And then use that widget’s context to do the Navigator call.

There are a few ways to achieve this. You can extract home into a custom class :

Or you can use Builder :

直接在GridView布局里,加上这两句代码,即可解决问题!

physics: new NeverScrollableScrollPhysics(),//增加

shrinkWrap: true,//增加

例子如下:

谷歌翻译:

表刻录机没有名为USER(代码1)的列:,正在编译:INSERT INTO Burner(USER,YELLOW,TIME)值(?,?,?)

在android.database.sqlite.SQLiteConnection.nativePrepareStatement(本机方法)

简单理解:

意思就是说,数据库中没有该列,但在插入时,多了这么一项

android.database.sqlite.SQLiteException:无此类列:id(代码1):,而在编译时:通过id desc从刻录机顺序中选择*

id的名字写错了,导致操作数据库时,找不到id这一列

谷歌翻译

插入GREEM = 30 YELLOW = 4 RED = 5时出错

android.database.sqlite.SQLiteException:没有这样的表:Burner(代码1):,而在编译时:INSERT INTO Burner(GREEM,YELLOW,RED)值(?,?,?)

简单理解

表没有创建成功,不存在这张表导致插入数据时报错

直接套一个Container即可解决问题

这样写,即可解决问题!

看这篇博客就明白了:

javascript:void(0)

《报错与问题解决方案》总结v1.0版本
《报错与问题解决方案》总结v1.0版本
《报错与问题解决方案》总结v1.0版本
《报错与问题解决方案》总结v1.0版本

如果在布局里已经设置了图片,在Java代码里修改就不会生效,所以我们直接在Java代码里动态修改,以后需要逻辑变更时,

再继续在Java代码里修改就不会再有这种问题了!

原因:

《报错与问题解决方案》总结v1.0版本

将drawable-v24下的文件全部剪帖到drawable里即可。

MySQL Server 安装失败

安装MySQL

官方包 mysql-installer-community-5.7.20.0.msi 安装过程中, MySQL Server安装未成功并且报错:The action ‘Install’ for product ‘MySQL Server 5.7.20’ failed.

原因是缺少所需插件:

Visual C++ 2013 and Visual C++ Redistributable Package

把https改成http

(1)安装

△踩过的坑:

我在装python升级的时候不小心把python环境弄坏了,导致

bash: /home/bsp/perl5/perlbrew/etc/bashrc: No such file or directory

解决:此时,如果还想使用命令

需要切换用户到root

执行:<code>su root</code>

第一步:https:

第二步:sudo -s

第三步:su root

https://www.itbulu.com/py-apt-pkg.html

意思是:不要以root的身份去执行

Ctrl + d 退出root模式

重新执行你的命令就行

(1)

切换到 root 账户下,source ~/.bashrc

(2)

Ctrl + d 切换回普通用户

(3)

hb -h,即可显示

(1)首先要确定自己是否按照官网下载了llvm

(2)一般Ubuntu都会自带llvm和clang,所以我们要更改系统指定llvm和clang的版本。llvm 一定要制定官网下载的,clang要制定llvm里bin目录下的clang

解决办法: llvm10 换成 llvm9

sudo chmod 777 /dev/kvm

参考:javascript:void(0)

(1)、到官网上下载Gradle

https://services.gradle.org/distributions/

(2)、配置

https://harmonyos.51cto.com/posts/1184

原因:PowerManager.java路径写错,导致第一次覆盖到framework层的时候报错

从项目根目录进入framework层,然后找一下PowerManager.java的路径

(1)cd frameworks/

(2)find -name PowerManager.java

此时出现:

./base/core/java/android/os/PowerManager.java

./base/core/java/android/PowerManager.java

我们需要删除下面那个错误的路径

(3)rm ./base/core/java/android/PowerManager.java

(4)git diff ./base/core/java/android/os/PowerManager.java(查看更新)

(5)git status .(检查一下)

OK,重新编译即可!

没有调用show方法

例如:Toast.makeText(MainActivity.this,“休眠”,Toast.LENGTH_SHORT).show();

Ctrl+C

继续阅读