1.问题原因分析

在Android SDK更新至23以上时,我们会发现之前在某些地方因计算需要使用到的FloatMath类中的方法如FloatMath.ceil()与FloatMath.sin()等都报错并提示不可用了,FloatMath源码如下:

package android.util;

/**

* Math routines similar to those found in {@link java.lang.Math}.

* 数学例程类似于{@link java.lang.Math}.

*

Historically these methods were faster than the equivalent double-based

* {@link java.lang.Math} methods. On versions of Android with a JIT they

* became slower and have since been re-implemented to wrap calls to

* {@link java.lang.Math}. {@link java.lang.Math} should be used in

* preference.

*

*

All methods were removed from the public API in version 23.

* 所有方法都从版本23的公共API中删除.

* @deprecated Use {@link java.lang.Math} instead.

* 方法过时,应使用java.lang.Math代替.

*/

@Deprecated

public class FloatMath {

/** Prevents instantiation. */

private FloatMath() {}

/**

* Returns the float conversion of the most positive (i.e. closest to

* positive infinity) integer value which is less than the argument.

*

* @param value to be converted

* @return the floor of value

* @removed

*/

public static float floor(float value) {

return (float) Math.floor(value);

}

/**

* Returns the float conversion of the most negative (i.e. closest to

* negative infinity) integer value which is greater than the argument.

*

* @param value to be converted

* @return the ceiling of value

* @removed

*/

public static float ceil(float value) {

return (float) Math.ceil(value);

}

/**

* Returns the closest float approximation of the sine of the argument.

*

* @param angle to compute the cosine of, in radians

* @return the sine of angle

* @removed

*/

public static float sin(float angle) {

return (float) Math.sin(angle);

}

/**

* Returns the closest float approximation of the cosine of the argument.

*

* @param angle to compute the cosine of, in radians

* @return the cosine of angle

* @removed

*/

public static float cos(float angle) {

return (float) Math.cos(angle);

}

/**

* Returns the closest float approximation of the square root of the

* argument.

*

* @param value to compute sqrt of

* @return the square root of value

* @removed

*/

public static float sqrt(float value) {

return (float) Math.sqrt(value);

}

/**

* Returns the closest float approximation of the raising "e" to the power

* of the argument.

*

* @param value to compute the exponential of

* @return the exponential of value

* @removed

*/

public static float exp(float value) {

return (float) Math.exp(value);

}

/**

* Returns the closest float approximation of the result of raising {@code

* x} to the power of {@code y}.

*

* @param x the base of the operation.

* @param y the exponent of the operation.

* @return {@code x} to the power of {@code y}.

* @removed

*/

public static float pow(float x, float y) {

return (float) Math.pow(x, y);

}

/**

* Returns {@code sqrt(}{@code x}{@code 2}{@code +}

* {@code y}{@code 2}{@code )}.

*

* @param x a float number

* @param y a float number

* @return the hypotenuse

* @removed

*/

public static float hypot(float x, float y) {

return (float) Math.hypot(x, y);

}

}

通过观察类说明可知,FloatMath的所有方法都已经从版本23的公共API中删除,官方提示我们可以使用java.lang.Math类来代替使用。

2.解决方法

使用23以下版本的SDK进行编译,即修改gradle.build文件里的compileSdkVersion为23以下版本即可。

使用Math类中的方法进行代替。

java floatmath_【Android】解决FloatMath类中方法在API 23以后不存在问题相关推荐

  1. android解决工具类中没有context中的问题

    有时我们需要在一个工具类中用到上下文context.当然有一个做法就是使用传递context的方法,当我们需要用全局context的时候,该怎么办呢? 其实我们应用启动的时候会启动Applicatio ...

  2. Android之TelephonyManager类的方法详解

    林计钦-JAVA java技术群:127834248 博客园   首页   社区   新随笔   联系   订阅   管理 随笔-105  评论-24  文章-0  trackbacks-0 Andr ...

  3. android 实现自定义监听接口,Android在自定义类中实现自定义监听器方式

    Android在自定义类中实现自定义监听器方式 发布时间:2020-08-31 06:19:39 来源:脚本之家 阅读:203 作者:Simon_Qi 监听器可以说是Android开发中最常用的东西之 ...

  4. java 普通类request_[Java教程]spring在普通类中获取session和request

    [Java教程]spring在普通类中获取session和request 0 2014-08-12 08:01:13 在使用spring时,经常需要在普通类中获取session,request等对像. ...

  5. (36)System Verilog类中方法示例

    (36)System Verilog类中方法示例 1.1 目录 1)目录 2)FPGA简介 3)System Verilog简介 4)System Verilog类中方法示例 5)结语 1.2 FPG ...

  6. java异常类中属于非检测异常的是_下列java语言的常用异常类中,属于检测异常的是()_学小易找答案...

    [单选题]在Word 2010的编辑状态,对当前文档中的文字进行"字数统计"操作,应当使用的菜单是( ) [单选题]客运员领带统一,领带夹夹在衬衣的( )钮扣之间. [单选题]文件 ...

  7. Matcher类中方法简介说明

    转自: Matcher类中方法简介说明 Matcher类中索引方法 索引方法的功能: 提供了索引信息, 返回匹配字符串的位置信息 索引方法如下所示: 编号 方法及备注说明 1 public int s ...

  8. java获得服务器路径的几中方法

    2019独角兽企业重金招聘Python工程师标准>>> java获得服务器路径的几中方法 在JavaBean里可以这样: this.getClass().getClassLoader ...

  9. 传智播客python笔记_python传智播客笔记--第十天:隐藏属性,私有属性,私有方法,__del__方法,类的继承,类中方法的重写...

    封装,继承,多态 隐藏属性,私有属性,私有方法,__del__方法,类的继承,类中方法的重写 -**************************************************** ...

最新文章

  1. 什么时候应该在C ++中使用类与结构?
  2. boost::container模块实现检查相等的容器的测试程序
  3. 线性规划 - 用单纯形法解决LP问题 - (Matlab、Lingo建模)
  4. oracle宣传视频下载,1300首 Audiomachine 背景音乐电影宣传预告片配乐合辑(23集)...
  5. 基于matlab的绘图设计,matlab课程设计---利用MATLAB仿真软件进行绘图
  6. leetcode题解179-最大数
  7. python剑指offer替换空格_《剑指Offer》字符串 替换空格
  8. 「代码随想录」关于多重背包,你该了解这些!
  9. 在计算机编程里pi是什么意思,编程中的术语“钩子”是什么意思?
  10. PySpark fold foldByKey用法
  11. 服务器远程连接端口号修改
  12. python2.0下载_【Python for S60V2】Python for S60V2 V2.0官方免费下载_正式版下载-多特软件站...
  13. Ubuntu安装Times NewRoman字体
  14. 【踩坑】Win11 WSL2 中 meld 无法正常使用问题修复
  15. Ps使用旋转扭曲制作图片
  16. 教女朋友学Python是道送命题
  17. ffmpeg截取一段视频中一段视频
  18. 项目添加到服务器报错,基于github+travis自动部署vue项目到远端服务器
  19. STM32F103+SDIO wifi Marvell8801/Marvell88w8801 介绍(九) ---- Marvell 8801/Marvell 88w8801 实现AP功能/实现热点功能
  20. matlab中 spm,使用SPM批处理在MATLAB中运行预处理

热门文章

  1. springboot+多线程简单实现
  2. python爬虫实战:利用scrapy,短短50行代码下载整站短视频
  3. cin,getline用法和不同
  4. .NET url 的编码与解码
  5. 源码编译安装mysql,DDL数据定义语言的使用。
  6. Apache+tomcat+mysql安装步骤
  7. php判断http头还是https头
  8. squid 的配置详解 (转)--SeriesI 收藏
  9. 菜鸟也学DW做ASP
  10. python 安装serial模块