当前位置: 首页 > article >正文

【安卓开发】【Android Studio】项目构建(Build)时报错:Integer Overflow

一、问题描述

在安卓项目中,构建(Build)失败并报错:xxxxx Integer Overflow(整型溢出)。

二、相关代码

刚开始以为是某个整数(例如控件、java类)不匹配造成的,检查如下代码:
Java类:

public class Video_Activity10 extends AppCompatActivity {
    private MediaPlayer mPlayer = null;
    private SurfaceView sfv_show;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video10);
        @SuppressLint({"MissingInflatedId", "LocalSuppress"}) SurfaceView sfv_show = findViewById(R.id.surface);
        SurfaceHolder surfaceHolder = sfv_show.getHolder();
        @SuppressLint({"MissingInflatedId", "LocalSuppress"}) Button btn_start = findViewById(R.id.btn1);
        @SuppressLint({"MissingInflatedId", "LocalSuppress"}) Button btn_pause = findViewById(R.id.btn2);
        @SuppressLint({"MissingInflatedId", "LocalSuppress"}) Button btn_stop = findViewById(R.id.btn3);
        mPlayer = MediaPlayer.create(Video_Activity10.this, R.raw.video_10);
        mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                Toast.makeText(Video_Activity10.this,"视频播放完毕",Toast.LENGTH_LONG).show();
            }
        });
        btn_start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPlayer.setDisplay(sfv_show.getHolder());
                mPlayer.start();
            }
        });
        btn_pause.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPlayer.pause();
            }
        });
        btn_stop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPlayer.stop();
            }
        });

    }
}

xml布局文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".Video_Activity10">

    <!--    视 频 主 体    -->
    <SurfaceView
        android:id="@+id/surface"
        android:layout_width="wrap_content"
        android:layout_height="480dp"
        android:layout_gravity="center_horizontal"
        android:keepScreenOn="true"/>

    <!--    播 放 按 钮    -->
    <Button
        android:id="@+id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/play"/>

    <!--    暂 停 按 钮    -->
    <Button
        android:id="@+id/btn2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/pause"/>

    <!--    停 止 按 钮    -->
    <Button
        android:id="@+id/btn3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/stop"/>

</LinearLayout>

没有问题。

之后,以为是内存限制过小导致,修改gradle.properties文件:
将这里的8000上调至10000:

org.gradle.jvmargs=-Xmx8000m -Dfile.encoding=UTF-8

报错消失。

三、后续思考

However……之后,将上述的10000再改回8000,依旧没有报错。
可能是运行时出现的随机报错?


http://www.kler.cn/a/421889.html

相关文章:

  • GoReplay工具middlware使用(python版本)
  • 云原生和数据库哪个好一些?
  • case判断年份是否为闰年
  • redis 从16db块 加到32db块
  • Goland2024.3 发布,有点东西
  • 开发一套ERP 第十弹 图片作为配置文件,本地读取图片,定时更新图片类型
  • [高等数学学习记录] 泰勒公式
  • 【Linux】vim编辑器
  • ORB-SLAM2 ----- LocalMapping::ComputeF12和ORBmatcher::CheckDistEpipolarLine
  • C++ 封闭函数局部变量不能在 lambda 体中引用,除非其位于捕获列表中
  • Golang教程第25篇(并发)
  • G0、G1、G2连续在曲线和曲面的设计和制造中重要性体现在哪里
  • 工业智能网关在该企业中的应用实践
  • 【Leetcode 每日一题】LCR 190. 加密运算
  • 3D姿势和跟踪的人体行为识别
  • Linux条件变量线程池详解
  • 网络安全漏洞原理利用与渗透
  • 类和对象下
  • Kubernetes 01
  • pytorch中model.eval的理解