Android Studio生成APP运行闪退,小白求救大佬!!!!!!!!!

图片说明
图中说的是什么问题啊,看不懂

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

萌新求助Android Studio工程编译没问题,运行app就闪退,求大佬看看是什么问题

Myview.java//就是给坐标在屏幕上画圆的代码,不知道哪里错了555555 ``` public class MyView extends View { public MyView(Context context, AttributeSet attrs) { super(context, attrs); } private int a; public MyView(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { Paint paint = new Paint(); zuobiao t = new zuobiao(); t.getnumber(10, 0.5); t.amath(); t.showmath(); t.setax(); for (int i = 0; i < t.a; i++) { for (int j = 0; j < t.a; j++) { canvas.drawCircle(Float.valueOf(t.x1.get(i).toString()), Float.valueOf(t.y1.get(j).toString()), 50, paint); paint.setStyle(Style.STROKE); } } } } zuobiao.java ``` public class zuobiao { private double length,round; public double result; public static double agle=(Math.asin(Math.sqrt(3)/3))-Math.PI/6; double a; public ArrayList x1=new ArrayList(); public ArrayList x2=new ArrayList(); public ArrayList y1=new ArrayList(); public ArrayList y2=new ArrayList(); public double c; public void getnumber(double i,double j) {this.length=i; this.round=j; } public void amath() {c=(length-2*round)/(4*round*Math.cos(agle)); } public double showmath() { this.a=Math.floor(c); System.out.println(a); this.result=((length/4*round)*(2*a-1)); return this.result; } public void setax() { double[] x1 = new double [(int) this.a]; double[] y1 = new double[(int) a]; double[] x2 = new double[(int) a]; double[] y2 = new double[(int) a]; double magle=Math.PI/3+agle; double xieb=2*round/Math.sin(magle); x1[0]=0; x2[0]=2*round*Math.cos(magle)-(xieb-2*round)*Math.cos(magle); y1[0]=0; y2[0]=2*round-(xieb-2*round)*Math.sin(magle); for(int i=1;(i<a);i++) { x1[i] = x1[i-1]+(4*round*Math.cos(agle)); y1[i] = y1[i-1]+2*round; x2[i] = x2[i-1]+(4*round*Math.cos(agle)); y2[i] = y2[i-1]+2*round; } for(int j=1;(j<a);j++) { this.x1.add(x1[j]); this.x2.add(x1[j]); this.y1.add(x1[j]); this.y2.add(x1[j]); } } }

Android 测试app时闪退 应该怎么解决

在用 checkboxes 跟 button 点击时它就闪退了,有这两个错误出现 E/MemoryLeakMonitorManager: MemoryLeakMonitor.jar is not exist! E/Minikin: Could not get cmap table size! 还有用的是 华为荣耀10 的真机测试 这要怎么解决的 谢谢

萌新求助Android Studio工程编译没问题,运行app就闪退,我试了别的代码,只要修改了xml文件也会闪退。

不管真机还是模拟机,都会闪退,就是一个很简单的程序修改了xml文件也会闪退,我也不知道是代码的问题还是我的AS的问题。 如果有大神能帮我看看代码也可以(一个基于AS的吉他调音软件)编译都通过了,求帮忙(现金奖励)

使用Android studio编写的程序,写好代码后运行app到模拟器的时候会闪退

希望懂的大佬能帮帮忙,救救我,这个问题困扰我好久了,这个问题没解决就无法进行下一步。 1.最近使用Android studio编写了一个程序,写好代码后运行app到模拟器的时候会闪退(创建时程序版本和模拟器版本相同为5.1)。没有写代码时(也就是刚创建好程序,没添加任何东西时),在模拟器中能正常运行,但是当我写好代码后,运行app到模拟器上就会闪退了。 2.在代码部分,我是根据的SuperMap iMobile 9D(2019) for Android Guide的指导书写的,现在我也配置了许可,但还是会闪退 3.各个部分的代码如下: ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.loadscence"> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation|screenSize" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <supports-screens android:largeScreens="true" android:resizeable="true" android:normalScreens="true" android:anyDensity="true"/> </manifest> ///////////////////////////////////////////////////////////这是mainactivity.java的代码 package com.example.loadscence; import androidx.appcompat.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ZoomControls; import com.supermap.data.Environment; import com.supermap.data.Workspace; import com.supermap.data.WorkspaceConnectionInfo; import com.supermap.data.WorkspaceType; import com.supermap.mapping.MapControl; import com.supermap.mapping.MapView; public class MainActivity extends AppCompatActivity { private MapControl m_mapcontrol = null; private Workspace m_workspace; private MapView m_mapView; private ZoomControls m_zoom; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置一些系统需要用到的路径 String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath(); Environment. setLicensePath (rootPath + "/SuperMap/license/"); Environment. setTemporaryPath (rootPath + "/SuperMap/temp/"); Environment. setWebCacheDirectory (rootPath + "/SuperMap/WebCatch"); //组件功能必须在 Environment 初始化之后才能调用 Environment. initialization (this); //如果机器中默认不包括需要显示的字体,可以把相关字体文件放在参数所代表的路径中。 //例如,如果需要显示阿拉伯文字(若机器中原先不包括相关字体文件),可以把需要的字体文件放在参数所代表的路径中。 Environment. setFontsPath (rootPath + "/SuperMap/fonts/"); setContentView(R.layout. activity_main ); //打开工作空间 m_workspace = new Workspace(); WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(); info.setServer(rootPath + "/SampleData/GeometryInfo/World.smwu"); info.setType(WorkspaceType. SMWU ); m_workspace.open(info); //将地图显示控件和工作空间关联 m_mapView = (MapView)findViewById(R.id. Map_view ); m_mapcontrol = m_mapView.getMapControl(); m_mapcontrol.getMap().setWorkspace(m_workspace); //打开工作空间中的第二幅地图 String mapName = m_workspace.getMaps().get(1); m_mapcontrol.getMap().open(mapName); m_zoom = (ZoomControls)findViewById(R.id. zoomControls1 ); m_mapView = (MapView)findViewById(R.id. Map_view ); m_zoom.setIsZoomInEnabled(true); m_zoom.setIsZoomOutEnabled(true); //放大按钮 m_zoom.setOnZoomInClickListener(new OnClickListener() { public void onClick(View v) { m_mapcontrol.getMap().zoom(2); m_mapcontrol.getMap().refresh(); } }); //缩小按钮 m_zoom.setOnZoomOutClickListener(new OnClickListener(){ public void onClick(View v) { m_mapcontrol.getMap().zoom(0.5); m_mapcontrol.getMap().refresh(); } }); m_mapcontrol.getMap().refresh(); } } ///////////////////////////////////////////////////////////这是activity的代码 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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" tools:context=".MainActivity"> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/main"> <RelativeLayout android:gravity="left" android:layout_width="match_parent" android:layout_height="match_parent"> <com.supermap.mapping.MapView android:id = "@+id/Map_view" android:layout_width="match_parent" android:layout_height = "match_parent"> </com.supermap.mapping.MapView> <ZoomControls android:id="@+id/zoomControls1" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_centerHorizontal="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ZoomControls> </RelativeLayout> </RelativeLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> ///////////////////////////////////////////////////////////报错日志如下: 03-23 22:32:10.438 22856-22856/com.example.loadscence E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.loadscence, PID: 22856 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.loadscence/com.example.loadscence.MainActivity}: java.lang.NullPointerException: Attempt to get length of null array 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:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.NullPointerException: Attempt to get length of null array at com.supermap.data.Environment.checkAndLoadLibrary64(Environment.java:1632) at com.supermap.data.Environment.initialization(Environment.java:576) at com.example.loadscence.MainActivity.onCreate(MainActivity.java:33) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 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:903)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)  ```

[Android Studio ] APP真机调试闪退怎么解决

日志如下 05-14 16:48:07.304 4611-4611/? E/HAL: load: couldn't find symbol HMI 05-14 16:48:07.305 4611-4611/? E/memtrack: Couldn't load memtrack module (Invalid argument) 05-14 16:48:07.305 4611-4611/? E/android.os.Debug: failed to load memtrack module: -22 05-14 16:48:07.347 4611-4611/? E/HAL: load: id=fm != hmi->id=fm 05-14 16:48:07.347 4611-4611/? E/fm_if.c: find the id:fm and begins to open the devices 05-14 16:48:08.007 4349-4658/? E/WifiConfigStore: updateConfiguration freq=2462 BSSID=74:c3:30:40:b8:8c RSSI=-33 "eternity"WPA_PSK 05-14 16:48:09.006 4349-4658/? E/WifiConfigStore: updateConfiguration freq=2462 BSSID=74:c3:30:40:b8:8c RSSI=-31 "eternity"WPA_PSK 05-14 16:48:10.009 4349-4658/? E/WifiConfigStore: updateConfiguration freq=2462 BSSID=74:c3:30:40:b8:8c RSSI=-31 "eternity"WPA_PSK 05-14 16:48:11.010 4349-4658/? E/WifiConfigStore: updateConfiguration freq=2462 BSSID=74:c3:30:40:b8:8c RSSI=-31 "eternity"WPA_PSK

android studio打包生成apk文件闪退问题

as生成apk文件可以安装但是会闪退,不知道为啥 求大神告诉原因和解决方法 ,先谢过大神们。。

Android Studio代码哪儿有错吗?为什么运行APP老是闪退

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="180dp" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginStart="150dp" android:layout_marginLeft="150dp" android:layout_marginTop="100dp" android:text="用户登陆" android:textColor="@android:color/holo_blue_dark" android:textSize="30sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="90dp" android:orientation="horizontal"> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@+id/editText1" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="35dp" android:layout_marginStart="35dp" android:text="用户名" android:textSize="25sp" /> <EditText android:id="@+id/editText1" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="40dp" android:layout_marginStart="40dp" android:text="" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="90dp" android:orientation="horizontal"> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@+id/editText2" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="35dp" android:layout_marginStart="35dp" android:text="密码" android:textSize="25sp" /> <EditText android:id="@+id/editText2" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="66dp" android:layout_marginStart="66dp" android:text="" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="90dp" android:orientation="horizontal"> <Button android:id="@+id/button5" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="80dp" android:layout_marginStart="80dp" android:text="登陆" /> <Button android:id="@+id/button4" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="45dp" android:layout_marginStart="45dp" android:text="注册" /> </LinearLayout> </LinearLayout>

android activity 跳转闪退问题

![图片说明](https://img-ask.csdn.net/upload/202004/19/1587295781_814511.png)![图片说明](https://img-ask.csdn.net/upload/202004/19/1587295786_764947.png)![图片说明](https://img-ask.csdn.net/upload/202004/19/1587295896_95770.png) 第二个跳转页面已经在AndroidManifest注册,运行之后按BUTTON,![图片说明 会直接闪退求大佬解释!

android studio为什么程序运行时会闪退,自己找不出错误,寻求帮忙

为什么运行的时候这两张图片按钮时会闪退,找不到是哪里错了,我把所有代码都放到压缩包里了,请大神们帮我看解答一下,谢谢。 哪位大神可以教我一下android,想要拜师一下,我的qq是1070672265 ![图片说明](https://img-ask.csdn.net/upload/201910/09/1570617881_767688.png)![图片说明](https://img-ask.csdn.net/upload/201910/09/1570617907_501688.png) ![图片说明](https://img-ask.csdn.net/upload/201910/09/1570618099_624444.png)![图片说明](https://img-ask.csdn.net/upload/201910/09/1570618110_109302.png)![图片说明](https://img-ask.csdn.net/upload/201910/09/1570618124_143505.png)

使用Linux编译android APP 运行闪退,在AS编译可以运行

log信息: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.zhaoll.hsetupwizard/com.example.zhaoll.hsetupwizard.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.zhaoll.hsetupwizard.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.zhaoll.hsetupwizard-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 有人说是项目的v4库和工程引用的v4库不一致导致的,初学者不知道该怎么让他们一致,求大神说具体点

Android studio 百度地图导航闪退

求大佬帮忙,定位和路线规划已经实现,但是导航部分的代码一敲进去的运行就会闪退,目前找到了导致闪退的代码是下面代码中的initstart()、initsuccess()和initfailed()部分,但是注释掉这三个部分的话IBaiduNaviManager.INaviInitListener()就会报错,不知道到底怎么改才能运行成功ORZ ``` `BaiduNaviManagerFactory.getBaiduNaviManager().init(this, mSDCardPath, APP_FOLDER_NAME, new IBaiduNaviManager.INaviInitListener() { @Override public void onAuthResult(int status, String msg) { String result; if (0 == status) { result = "key校验成功!"; } else { result = "key校验失败, " + msg; } Toast.makeText(MainActivity.this, result, Toast.LENGTH_LONG).show(); } @Override public void initStart() { Toast.makeText(MainActivity.this, "导航引擎初始化开始", Toast.LENGTH_SHORT).show(); } @Override public void initSuccess() { Toast.makeText(MainActivity.this, "导航引擎初始化成功", Toast.LENGTH_SHORT).show(); hasInitSuccess = true; // 初始化tts initTTS(); } @Override public void initFailed() { Toast.makeText(MainActivity.this, "导航引擎初始化失败", Toast.LENGTH_SHORT).show(); }` ``` 报错是 E/MPlugin: Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport

自学Android开发 在模拟器运行闪退

初学者自写的程序 ,但是在模拟器下运行闪退!!该怎么改呀?? package com.example.work3; import java.util.ArrayList; import java.util.List; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.TabActivity; import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.StrictMode; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.Spinner; import android.widget.TabHost; import android.widget.TextView; import android.os.Build; public class MainActivity extends TabActivity { private TabHost tabhost; private ListView listview; private ArrayAdapter<String> arr_adapter; private Spinner spinner; private List<String>list; private ArrayAdapter<String> adapter; private EditText et1,et2; private Button bt; String name; String value; String style; @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); et1=(EditText) findViewById(R.id.editText1); et2=(EditText) findViewById(R.id.editText2); bt=(Button) findViewById(R.id.button1); setContentView(R.layout.activity_main); tabhost=getTabHost(); tabhost.addTab(tabhost.newTabSpec("菜单一").setIndicator("首页").setContent(R.id.tab1)); tabhost.addTab(tabhost.newTabSpec("菜单二").setIndicator("新增").setContent(R.id.tab2)); tabhost.addTab(tabhost.newTabSpec("菜单三").setIndicator("账单").setContent(R.id.tab3)); //按钮监听 提取信息 bt.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub name = et1.getText().toString(); value = et2.getText().toString(); style = spinner.getSelectedItem().toString(); } }); listview = (ListView) findViewById(R.id.listview); //新建适配器 String[]arr_data={"数据1","数据2","数据3","数据4","数据5"}; //ArrayAdapter(上下文,当前ListView加载的每一个列表项所对应的布局文件,数据源) arr_adapter =new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,arr_data); listview.setAdapter(arr_adapter); spinner=(Spinner) findViewById(R.id.spinner); //数据源 String[]list = {"1.日常食品支出","2.人情世故支出","3.出差旅游支出","4.服饰鞋帽支出","5.生活用品支出","6.其他支出"}; //新建适配器 adapter=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list); //设置下拉样式 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //加载适配器 spinner.setAdapter(adapter); } //退出对话框 @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK ) { // 创建退出对话框 AlertDialog isExit = new AlertDialog.Builder(this).create(); // 设置对话框标题 isExit.setTitle("系统提示"); // 设置对话框消息 isExit.setMessage("确定要退出吗"); // 添加选择按钮并注册监听 isExit.setButton("确定", listener); isExit.setButton2("取消", listener); // 显示对话框 isExit.show(); } return false; } /**监听对话框里面的button点击事件*/ DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case AlertDialog.BUTTON_POSITIVE:// "确认"按钮退出程序 finish(); break; case AlertDialog.BUTTON_NEGATIVE:// "取消"第二个按钮取消对话框 break; default: break; } } }; }

android studio 真机调试闪退怎么解决

使用相对布局写的hello world但是真机调试的时候手机以上而退了,报错信息如下![图片说明](https://img-ask.csdn.net/upload/201711/08/1510123728_521039.png) android小萌新麻烦各位大神帮忙解决一下

Android Studio自动闪退

![图片说明](https://img-ask.csdn.net/upload/202003/12/1583977388_855766.png)![图片说明](https://img-ask.csdn.net/upload/202003/12/1583977397_676226.png) ![图片说明](https://img-ask.csdn.net/upload/202003/11/1583921961_548849.png) ![图片说明](https://img-ask.csdn.net/upload/202003/12/1583979725_957449.png) as 经常用着用着就自动闪退 没有任何提示 有人知道是什么原因吗?

使用AndroidStudio做真机测试可以正常运行,安装到其他手机闪退

用AndroidStudio做的app,我直接用真机测试,发送到其他手机不能运行,一运行就闪退

android中使用模拟器闪退问题

运行模拟器后,点击界面的任意控件都会弹出 很抱歉,”caihongpai“已停止运行 不知道这是为什么,求各位大神帮忙 logcat代码: ``` 03-09 07:50:14.924 3687-3687/? I/art: Late-enabling -Xcheck:jni 03-09 07:50:15.063 3687-3687/com.example.caihongpai W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 03-09 07:50:15.087 3687-3687/com.example.caihongpai I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper> 03-09 07:50:15.087 3687-3687/com.example.caihongpai I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper> 03-09 07:50:15.134 3687-3687/com.example.caihongpai D/AndroidRuntime: Shutting down VM 03-09 07:50:15.134 3687-3687/com.example.caihongpai E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.caihongpai, PID: 3687 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.caihongpai/com.example.caihongpai.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageButton.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392) at android.app.ActivityThread.access$800(ActivityThread.java:153) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5305) 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:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageButton.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at com.example.caihongpai.MainActivity.onCreate(MainActivity.java:121) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)  at android.app.ActivityThread.access$800(ActivityThread.java:153)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5305)  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:903)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)  下面的是.java代码: package com.example.caihongpai; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; public class MainActivity extends AppCompatActivity { Button b1; ImageButton ib1,ib2,ib3; ImageView i1,i2,i3; TextView t1; static int[] s1={R.drawable.fangpian,R.drawable.heitao,R.drawable.hongtao}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); b1=(Button)findViewById(R.id.button); ib1=(ImageButton) findViewById(R.id.ib1); ib2=(ImageButton) findViewById(R.id.ib2); ib2=(ImageButton) findViewById(R.id.ib2); i1=(ImageView) findViewById(R.id.i1); i2=(ImageView) findViewById(R.id.i2); i3=(ImageView) findViewById(R.id.i3); ib1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ib1.setImageResource(s1[0]); ib2.setImageResource(s1[1]); ib3.setImageResource(s1[2]); if(s1[0]==R.drawable.hongtao){ new AlertDialog.Builder(MainActivity.this) .setTitle("奥利给") .setMessage("小伙子,你答对了,真是个天才!!") .setPositiveButton("确认",null) .show(); i3.setVisibility(View.VISIBLE); ib1.setVisibility(View.INVISIBLE); ib2.setVisibility(View.INVISIBLE); ib3.setVisibility(View.INVISIBLE); }else{ new AlertDialog.Builder(MainActivity.this) .setTitle("向我开炮") .setMessage("小傻瓜,你答错了,真是个小笨蛋!!") .setPositiveButton("确认",new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialogInterface, int which) { return; } }) .setNegativeButton("再试一次", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { xp(); } }) .show(); i3.setVisibility(View.VISIBLE); ib1.setVisibility(View.INVISIBLE); ib2.setVisibility(View.INVISIBLE); ib3.setVisibility(View.INVISIBLE); } } }); ib2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ib1.setImageResource(s1[0]); ib2.setImageResource(s1[1]); ib3.setImageResource(s1[2]); if(s1[1]==R.drawable.hongtao){ new AlertDialog.Builder(MainActivity.this) .setTitle("奥利给") .setMessage("小伙子,你答对了,真是个天才!!") .setPositiveButton("确认",null) .show(); i3.setVisibility(View.VISIBLE); ib1.setVisibility(View.INVISIBLE); ib2.setVisibility(View.INVISIBLE); ib3.setVisibility(View.INVISIBLE); }else{ new AlertDialog.Builder(MainActivity.this) .setTitle("向我开炮") .setMessage("小傻瓜,你答错了,真是个小笨蛋!!") .setPositiveButton("确认",new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialogInterface, int which) { return; } }) .setNegativeButton("再试一次", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { xp(); } }) .show(); i3.setVisibility(View.VISIBLE); ib1.setVisibility(View.INVISIBLE); ib2.setVisibility(View.INVISIBLE); ib3.setVisibility(View.INVISIBLE); } } }); ib3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ib1.setImageResource(s1[0]); ib2.setImageResource(s1[1]); ib3.setImageResource(s1[2]); if(s1[2]==R.drawable.hongtao){ new AlertDialog.Builder(MainActivity.this) .setTitle("奥利给") .setMessage("小伙子,你答对了,真是个天才!!") .setPositiveButton("确认",null) .show(); i3.setVisibility(View.VISIBLE); ib1.setVisibility(View.INVISIBLE); ib2.setVisibility(View.INVISIBLE); ib3.setVisibility(View.INVISIBLE); }else{ new AlertDialog.Builder(MainActivity.this) .setTitle("向我开炮") .setMessage("小傻瓜,你答错了,真是个小笨蛋!!") .setPositiveButton("确认",new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialogInterface, int which) { return; } }) .setNegativeButton("再试一次", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { xp(); } }) .show(); i3.setVisibility(View.VISIBLE); ib1.setVisibility(View.INVISIBLE); ib2.setVisibility(View.INVISIBLE); ib3.setVisibility(View.INVISIBLE); } } }); } private void xp() { for (int i = 0; i < 3; i++) { int tmp = s1[i]; int s = (int) (Math.random() * 2); s1[i] = s1[s]; s1[s] = tmp; } } } 下面的是xml代码: <?xml version="1.0" encoding="utf-8"?> <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" android:background="#0CC6BB" tools:context=".MainActivity"> <TextView android:id="@+id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="猜猜红桃A在哪" android:textSize="30dp" android:gravity="center" android:layout_marginTop="50dp" /> <FrameLayout android:layout_width="match_parent" android:layout_height="180dp" android:layout_margin="10dp" android:orientation="horizontal"> <LinearLayout android:layout_width="match_parent" android:layout_height="180dp" android:orientation="horizontal"> <ImageButton android:id="@+id/ib1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" android:foregroundGravity="top" app:srcCompat="@drawable/beimian" /> <ImageButton android:id="@+id/ib2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" android:foregroundGravity="top" app:srcCompat="@drawable/beimian" /> <ImageButton android:id="@+id/ib3" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" android:foregroundGravity="top" app:srcCompat="@drawable/beimian" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="180dp" android:orientation="horizontal"> <ImageView android:id="@+id/i1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" app:srcCompat="@drawable/heitao" android:visibility="invisible"/> <ImageView android:id="@+id/i2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" app:srcCompat="@drawable/fangpian" android:visibility="invisible"/> <ImageView android:id="@+id/i3" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" app:srcCompat="@drawable/hongtao" android:visibility="invisible" /> </LinearLayout> </FrameLayout> <Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:text="让我再玩一次噻" android:textSize="20dp" /> </LinearLayout> ```

Android stuido程序在真机上运行时直接闪退

![图片说明](https://img-ask.csdn.net/upload/201706/14/1497444525_972366.png)真机用的4.3版本的安卓

Android Studio闪退问题

近几天android studio动不动就闪退了,弄的我现在项目都开发不了,郁闷至极!求大神帮忙解决!

编译能通过,为什么在手机上运行会直接闪退呢

package com.example.mylove; import android.app.Dialog; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity { private int num ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button go = (Button) super.findViewById(R.id.go); EditText et = (EditText) super.findViewById(R.id.et); this.num = Integer.parseInt(et.getText().toString()); go.setOnClickListener(new OnClickListener1());} private class OnClickListener1 implements View.OnClickListener { @Override public void onClick(View view){ if(forgive(num)==1){ Dialog dialog= new AlertDialog.Builder(MainActivity.this) .setTitle("you win yourself") .setMessage("我还能说什么呢?当然是选择原谅她!") .setIcon(R.drawable.forgive) .create(); dialog.show();} else{ Dialog dialog2 = new AlertDialog.Builder(MainActivity.this) .setTitle("you lose her").setMessage("天涯何处无芳草,请大侠重新来过!") .setIcon(R.drawable.saybyebye) .create(); dialog2.show();} } } ``` ```<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.mylove.MainActivity" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ff00ff00" > <TextView android:gravity="center" android:textSize="25sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/word1" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <TextView android:text="@string/word2" android:textSize="15sp" android:gravity="center" android:layout_above="@+id/et" android:layout_height="wrap_content" android:layout_width="fill_parent"/> <EditText android:id="@+id/et" android:gravity="center" android:hint="@string/forgive" android:inputType="number" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/go" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <Button android:id="@+id/go" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_centerInParent="true" android:hint="@string/go" /> </RelativeLayout>

2019 Python开发者日-培训

2019 Python开发者日-培训

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

设计模式(JAVA语言实现)--20种设计模式附带源码

设计模式(JAVA语言实现)--20种设计模式附带源码

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

java后台+微信小程序 实现完整的点餐系统

java后台+微信小程序 实现完整的点餐系统

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

2019 AI开发者大会

2019 AI开发者大会

玩转Linux:常用命令实例指南

玩转Linux:常用命令实例指南

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

4小时玩转微信小程序——基础入门与微信支付实战

4小时玩转微信小程序——基础入门与微信支付实战

Git 实用技巧

Git 实用技巧

Python数据清洗实战入门

Python数据清洗实战入门

使用TensorFlow+keras快速构建图像分类模型

使用TensorFlow+keras快速构建图像分类模型

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

程序员的算法通关课:知己知彼(第一季)

程序员的算法通关课:知己知彼(第一季)

MySQL数据库从入门到实战应用

MySQL数据库从入门到实战应用

机器学习初学者必会的案例精讲

机器学习初学者必会的案例精讲

手把手实现Java图书管理系统(附源码)

手把手实现Java图书管理系统(附源码)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

.net core快速开发框架

.net core快速开发框架

玩转Python-Python3基础入门

玩转Python-Python3基础入门

Python数据挖掘简易入门

Python数据挖掘简易入门

微信公众平台开发入门

微信公众平台开发入门

程序员的兼职技能课

程序员的兼职技能课

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

HoloLens2开发入门教程

HoloLens2开发入门教程

微信小程序开发实战

微信小程序开发实战

Java8零基础入门视频教程

Java8零基础入门视频教程

相关热词 c#跨线程停止timer c#批量写入sql数据库 c# 自动安装浏览器 c#语言基础考试题 c# 偏移量打印是什么 c# 绘制曲线图 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行
立即提问