android run app时报如下错

![图片说明](https://img-ask.csdn.net/upload/201608/08/1470666635_918862.png)图片说明
Information:Gradle tasks [:app:assembleDebug]
Error:Library reading phase: file '/Users/kuang/AndroidStudioProjects/Weather/app/build/intermediates/packaged/debug/classes.zip' is an invalid library
Error:com.android.jack.JackAbortException: Library reading phase: file '/Users/kuang/AndroidStudioProjects/Weather/app/build/intermediates/packaged/debug/classes.zip' is an invalid library
Error:com.android.jack.library.LibraryReadingException: Library reading phase: file '/Users/kuang/AndroidStudioProjects/Weather/app/build/intermediates/packaged/debug/classes.zip' is an invalid library
Error:com.android.jack.library.LibraryFormatException: file '/Users/kuang/AndroidStudioProjects/Weather/app/build/intermediates/packaged/debug/classes.zip' is an invalid library
Error:Execution failed for task ':app:transformJackWithJackForDebug'.

com.android.build.api.transform.TransformException: com.android.jack.api.v01.CompilationException: Library reading phase: file '/Users/kuang/AndroidStudioProjects/Weather/app/build/intermediates/packaged/debug/classes.zip' is an invalid library

3个回答

只要是build目录下的报错就rebuild或者clean项目,不行手动删build目录

删除buil 下的文件,解决不了的话,你还是 检查一下 你导入的库吧

请问一下楼主解决了吗 我也遇到这问题了 还不知道怎么办

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Android Studio中run app时报错
Error:Could not create service of type FileCollectionSnapshotterRegistry using TaskExecutionServices.createFileCollectionSnapshotterRegistry(). > Could not create service of type CachingFileHasher using TaskExecutionServices.createFileSnapshotter().![图片说明](https://img-ask.csdn.net/upload/201711/17/1510890359_716178.png)
android真机测试时报错
Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2511Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72511Library UP-TO-DATE :app:prepareComAndroidSupportSupportCompat2511Library UP-TO-DATE :app:prepareComAndroidSupportSupportCoreUi2511Library UP-TO-DATE :app:prepareComAndroidSupportSupportCoreUtils2511Library UP-TO-DATE :app:prepareComAndroidSupportSupportFragment2511Library UP-TO-DATE :app:prepareComAndroidSupportSupportMediaCompat2511Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42511Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2511Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:compileDebugJavaWithJavac 警告: D:\AndroidStudio\sdk\platforms\android-25\android.jar(android/os/Bundle.class): 主版本 52 比 51 新, 此编译器支持最新的主版本。 建议升级此编译器。 警告: D:\AndroidStudio\sdk\platforms\android-25\android.jar(java/util/List.class): 主版本 52 比 51 新, 此编译器支持最新的主版本。 建议升级此编译器。 警告: D:\AndroidStudio\sdk\platforms\android-25\android.jar(java/lang/Boolean.class): 主版本 52 比 51 新, 此编译器支持最新的主版本。 建议升级此编译器。 62 个警告 :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources :app:transformClassesWithDexForDebug java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Exception in thread "main" Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1 Information:BUILD FAILED Information:Total time: 3.553 secs Information:1 error Information:0 warnings Information:See complete output in console
切换Activity时报错Unable to stop activity
请教一下大家,哪些原因可能导致下面出现的问题! 程序有两个Activity,从MainActivity启动到NoteActivity时报错,主要是说`java.lang.RuntimeException: Unable to stop activity {<包名>/<包名>.MainActivity}: java.lang.NullPointerException`和`Caused by: java.lang.NullPointerException`,日志里没有说我的代码哪行有问题,都是些系统自己的类和方法。 两个Activity的声明: ```XML <activity android:name=".activity.MainActivity" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".activity.NoteActivity" android:theme="@style/AppTheme.NoActionBar" /> ``` 启动NoteActivity的代码: ```Java FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_note); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, NoteActivity.class); intent.putExtra("Open_Type", "newNote"); startActivity(intent); } }); ``` 点了fab按钮后直接报错,完整的错误日志如下: ``` E/AndroidRuntime: FATAL EXCEPTION: main Process: zqy.bysj.todo, PID: 2034 java.lang.RuntimeException: Unable to stop activity {zqy.bysj.todo/zqy.bysj.todo.activity.MainActivity}: java.lang.NullPointerException at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3174) at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3220) at android.app.ActivityThread.access$1100(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1223) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.app.Activity.performStop(Activity.java:5388) at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3171) at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3220)  at android.app.ActivityThread.access$1100(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1223)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5001)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)  at dalvik.system.NativeStart.main(Native Method)  ``` 请教一下大家,哪些原因可能导致这个问题?谢谢! 附图,看的清楚点。 ![图片说明](https://img-ask.csdn.net/upload/201703/14/1489458992_581817.png)
Android直接跳转activity报错
每次运行总是报错,能进入软件,但跳转时报错 ``` package com.text.Mark1; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.Window; import android.view.WindowManager; public class welcome extends Activity{ @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//全屏显示 setContentView(R.layout.welcome2); new Handler().postDelayed(new Runnable(){ @Override public void run(){ Intent intent = new Intent (welcome.this,login.class); startActivity(intent); welcome.this.finish(); } }, 1000); } } ``` 12-26 09:09:33.025: E/AndroidRuntime(555): FATAL EXCEPTION: main 12-26 09:09:33.025: E/AndroidRuntime(555): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.text.Mark1/com.text.Mark1.login}; have you declared this activity in your AndroidManifest.xml? 12-26 09:09:33.025: E/AndroidRuntime(555): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508) 12-26 09:09:33.025: E/AndroidRuntime(555): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384) 12-26 09:09:33.025: E/AndroidRuntime(555): at android.app.Activity.startActivityForResult(Activity.java:3190) 12-26 09:09:33.025: E/AndroidRuntime(555): at android.app.Activity.startActivity(Activity.java:3297) 12-26 09:09:33.025: E/AndroidRuntime(555): at com.text.Mark1.welcome$1.run(welcome.java:25) 12-26 09:09:33.025: E/AndroidRuntime(555): at android.os.Handler.handleCallback(Handler.java:605) 12-26 09:09:33.025: E/AndroidRuntime(555): at android.os.Handler.dispatchMessage(Handler.java:92) 12-26 09:09:33.025: E/AndroidRuntime(555): at android.os.Looper.loop(Looper.java:137) 12-26 09:09:33.025: E/AndroidRuntime(555): at android.app.ActivityThread.main(ActivityThread.java:4340) 12-26 09:09:33.025: E/AndroidRuntime(555): at java.lang.reflect.Method.invokeNative(Native Method) 12-26 09:09:33.025: E/AndroidRuntime(555): at java.lang.reflect.Method.invoke(Method.java:511) 12-26 09:09:33.025: E/AndroidRuntime(555): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 12-26 09:09:33.025: E/AndroidRuntime(555): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 12-26 09:09:33.025: E/AndroidRuntime(555): at dalvik.system.NativeStart.main(Native Method)
Android Studio运行项目报错
一下时报错内容 Error running app: This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run (or updating either the IDE or the Gradle plugin to the latest version)
同步LinkedList时报错
代码: private List<String> requests = Collections.synchronizedList(new LinkedList<String>()); 和 private List<String> requests = Collections.synchronizedList(new LinkedList<String>()); 运行报错: FATAL EXCEPTION: main java.lang.IllegalStateException: Could not execute method of the activity at android.view.View$1.onClick(View.java:2144) at android.view.View.performClick(View.java:2485) at android.view.View$PerformClick.run(View.java:9080) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at android.view.View$1.onClick(View.java:2139) ... 11 more Caused by: java.lang.ClassCastException: java.util.Collections$SynchronizedList at com.countryst.nabard.turnbased.client.networking.ClientNetworking.login(ClientNetworking.java:72) at com.countryst.nabard.turnbased.client.MainActivity.loginToServer(MainActivity.java:87) at com.countryst.nabard.turnbased.client.MainActivity.onButtonClicked(MainActivity.java:217) ... 14 more
安卓-导入项目-编译时报错
这是log: 07-20 20:00:00.490: E/AndroidRuntime(1641): FATAL EXCEPTION: main 07-20 20:00:00.490: E/AndroidRuntime(1641): Process: com.cyl.online, PID: 1641 07-20 20:00:00.490: E/AndroidRuntime(1641): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.cyl.online/com.cyl.online.activity.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.cyl.online.activity.MainActivity" on path: DexPathList[[zip file "/data/app/com.cyl.online-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.cyl.online-2, /system/lib]] 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110) 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.app.ActivityThread.access$800(ActivityThread.java:135) 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.os.Handler.dispatchMessage(Handler.java:102) 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.os.Looper.loop(Looper.java:136) 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.app.ActivityThread.main(ActivityThread.java:5001) 07-20 20:00:00.490: E/AndroidRuntime(1641): at java.lang.reflect.Method.invokeNative(Native Method) 07-20 20:00:00.490: E/AndroidRuntime(1641): at java.lang.reflect.Method.invoke(Method.java:515) 07-20 20:00:00.490: E/AndroidRuntime(1641): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 07-20 20:00:00.490: E/AndroidRuntime(1641): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 07-20 20:00:00.490: E/AndroidRuntime(1641): at dalvik.system.NativeStart.main(Native Method) 07-20 20:00:00.490: E/AndroidRuntime(1641): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.cyl.online.activity.MainActivity" on path: DexPathList[[zip file "/data/app/com.cyl.online-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.cyl.online-2, /system/lib]] 07-20 20:00:00.490: E/AndroidRuntime(1641): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 07-20 20:00:00.490: E/AndroidRuntime(1641): at java.lang.ClassLoader.loadClass(ClassLoader.java:497) 07-20 20:00:00.490: E/AndroidRuntime(1641): at java.lang.ClassLoader.loadClass(ClassLoader.java:457) 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.app.Instrumentation.newActivity(Instrumentation.java:1061) 07-20 20:00:00.490: E/AndroidRuntime(1641): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101) 07-20 20:00:00.490: E/AndroidRuntime(1641): ... 11 more 07-20 20:00:04.090: I/Process(1641): Sending signal. PID: 1641 SIG: 9 这是截图: ![图片说明](https://img-ask.csdn.net/upload/201507/21/1437437670_157074.png) ![图片说明](https://img-ask.csdn.net/upload/201507/21/1437437698_12314.png) ![图片说明](https://img-ask.csdn.net/upload/201507/21/1437437706_972558.png) ![图片说明](https://img-ask.csdn.net/upload/201507/21/1437437701_936199.png) 期间各种办法都试过,重新导包,clean工程 重新编译,调整jar包先后顺序,这个项目在别人的eclipse上就能运行,到我机器上就不行了 ,就是提示类找不着,这个activity在配置文件中也已经注册过了,真心着急啊,求各位大牛指导,感激不尽!!
oncreateDialog时报了空指针异常,求大神指导一下,我也找不到原因所在
报这个异常,我也搜了相关资料,很多人代码里最后default也返回null,为什么我报错呀?求大神知道,代码在最下面 java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2378) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2430) at android.app.ActivityThread.access$600(ActivityThread.java:166) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5400) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.netschool.mock.MockListActivity.onCreateDialog(Unknown Source) at android.app.Activity.onCreateDialog(Activity.java:3089) at android.app.Activity.createDialog(Activity.java:1072) at android.app.Activity.restoreManagedDialogs(Activity.java:1061) at android.app.Activity.performRestoreInstanceState(Activity.java:1007) at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1202) at com.lbe.security.service.core.client.internal.InstrumentationDelegate.callActivityOnRestoreInstanceState(InstrumentationDelegate.java:130) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2356) ... 11 more 代码 ``` @Override protected Dialog onCreateDialog(int id) { m_pickerDialog = null; switch (id) { case 0: m_pickerDialog = new DatePickerDialog_WithoutDate(this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Message msg = Message.obtain(); msg.arg1 = year; msg.arg2 = monthOfYear + 1; msg.what = MsgWhat.MSG_ANSW_RECO_ACTI_15; m_handlerPostExecute.sendMessage(msg); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); break; } m_pickerDialog.setTitle(calendar.get(Calendar.YEAR) + " 年 " + (calendar.get(Calendar.MONTH) + 1) + " 月"); return m_pickerDialog; } ```
Android中Camera拍照时报takePicture failed错误。
Log日志 07-12 09:01:59.238: E/AndroidRuntime(5780): Process: cyyz.cn, PID: 5780 07-12 09:01:59.238: E/AndroidRuntime(5780): java.lang.RuntimeException: takePicture failed 07-12 09:01:59.238: E/AndroidRuntime(5780): at android.hardware.Camera.native_takePicture(Native Method) 07-12 09:01:59.238: E/AndroidRuntime(5780): at android.hardware.Camera.takePicture(Camera.java:1363) 07-12 09:01:59.238: E/AndroidRuntime(5780): at android.hardware.Camera.takePicture(Camera.java:1289) 07-12 09:01:59.238: E/AndroidRuntime(5780): at cyyz.cn.jy.activity.TakePhotoActivity.onAutoFocus(TakePhotoActivity.java:671) 07-12 09:01:59.238: E/AndroidRuntime(5780): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1018) 07-12 09:01:59.238: E/AndroidRuntime(5780): at android.os.Handler.dispatchMessage(Handler.java:102) 07-12 09:01:59.238: E/AndroidRuntime(5780): at android.os.Looper.loop(Looper.java:136) 07-12 09:01:59.238: E/AndroidRuntime(5780): at android.app.ActivityThread.main(ActivityThread.java:5336) 07-12 09:01:59.238: E/AndroidRuntime(5780): at java.lang.reflect.Method.invokeNative(Native Method) 07-12 09:01:59.238: E/AndroidRuntime(5780): at java.lang.reflect.Method.invoke(Method.java:515) 07-12 09:01:59.238: E/AndroidRuntime(5780): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871) 07-12 09:01:59.238: E/AndroidRuntime(5780): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 07-12 09:01:59.238: E/AndroidRuntime(5780): at dalvik.system.NativeStart.main(Native Method) 我的onAutoFocus方法是: @Override public void onAutoFocus(boolean success, Camera camera) { // TODO Auto-generated method stub Log.d("onAutoFocus", "onAutoFocus="+success); setImg(); if (success) { myCamera.takePicture(shutter, raw, jpeg); } else { System.out.println("failer"); } isClicked = false; }
android中解析text文件
在应用中,创建了一个text文件保存数据,值大致如下: 98, 97, 98, ...... 需要从text文件中获取然后保存在一个数组列表中,想实现时报出异常。 **代码:** package com.example.meme; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.widget.TextView; public class test extends Activity{ private static ArrayList<String> LIST=new ArrayList<String>(); private static ArrayList<String> LIST2=new ArrayList<String>(); TextView index; String[] inputArray; String delimiter = ", "; String input; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); index = (TextView) findViewById(R.id.textView1); setContentView(R.layout.activity_main); //reading the values line by line and save them in the arraylist :"LIST" try { File sdcard = Environment.getExternalStorageDirectory(); File file = new File(sdcard,"Oximeter.txt"); BufferedReader br = new BufferedReader(new FileReader(file)); String line; while ((line = br.readLine()) != null) { LIST.add(line); } } catch (IOException e) { e.printStackTrace(); } //parsing each line saved in the arraylist "LIST", and save the result in a new arraylist called LIST2 for(int i=0; i<LIST.size(); i++) { input=LIST.get(i);// this will take the line inputArray = input.split(delimiter);//inputArray will include the readings for(int j=0;i<inputArray.length;j++) { LIST2.add(inputArray[j]);//readings are added to an arraylist } } index.setText("mamoun"); } } catlog: 02-17 03:31:51.296: D/AndroidRuntime(5538): Shutting down VM 02-17 03:31:51.296: W/dalvikvm(5538): threadid=1: thread exiting with uncaught exception (group=0x40c501f8) 02-17 03:31:51.304: E/AndroidRuntime(5538): FATAL EXCEPTION: main 02-17 03:31:51.304: E/AndroidRuntime(5538): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.meme/com.example.meme.MainActivity}: java.lang.NullPointerException 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.app.ActivityThread.access$600(ActivityThread.java:127) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.os.Handler.dispatchMessage(Handler.java:99) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.os.Looper.loop(Looper.java:137) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.app.ActivityThread.main(ActivityThread.java:4512) 02-17 03:31:51.304: E/AndroidRuntime(5538): at java.lang.reflect.Method.invokeNative(Native Method) 02-17 03:31:51.304: E/AndroidRuntime(5538): at java.lang.reflect.Method.invoke(Method.java:511) 02-17 03:31:51.304: E/AndroidRuntime(5538): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984) 02-17 03:31:51.304: E/AndroidRuntime(5538): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751) 02-17 03:31:51.304: E/AndroidRuntime(5538): at dalvik.system.NativeStart.main(Native Method) 02-17 03:31:51.304: E/AndroidRuntime(5538): Caused by: java.lang.NullPointerException 02-17 03:31:51.304: E/AndroidRuntime(5538): at com.example.meme.MainActivity.onCreate(MainActivity.java:73) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.app.Activity.performCreate(Activity.java:4465) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052) 02-17 03:31:51.304: E/AndroidRuntime(5538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934) 02-17 03:31:51.304: E/AndroidRuntime(5538): ... 11 more 02-17 03:33:00.507: I/Process(5673): Sending signal. PID: 5673 SIG: 9 请多多帮忙。
as中(kotlin)返回空指针
android 得到另一个Activity的返回值时报错 # activity1.kt ``` override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) button.setOnClickListener() { val username: String = editText.text.toString() val intent = Intent("WZC.activity1") startActivity(intent) intent.putExtra("username", username) //startActivity(intent) startActivityForResult(intent, 0) } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) val result = data!!.extras.get("result").toString() textView2.text = result } ``` ## activity2.kt ``` override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main2) val username = intent.extras.get("username") as String textView.text = "Welcome," + username button5.setOnClickListener(){ val intent = Intent("MainActivity") intent.putExtra("result","Result from Main2Activity.") setResult(0,intent) finish() } } } ``` ## 错误日志 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ruaaaaaaaa.myapplication/com.example.ruaaaaaaaa.myapplication.Main2Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.os.Bundle.get(java.lang.String)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) 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:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.os.Bundle.get(java.lang.String)' on a null object reference at com.example.ruaaaaaaaa.myapplication.Main2Activity.onCreate(Main2Activity.kt:14) at android.app.Activity.performCreate(Activity.java:5937) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)  at android.app.ActivityThread.access$800(ActivityThread.java:144)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5221)  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:899)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)  Application terminated.
代码设置RelativeLayout宽度时报错?
[code="xml"] <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout_parent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal" android:orientation="vertical" > <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent"> 。。。。。 [/code] 代码中需要对RelativeLayout的宽度进行设定: [code="java"] RelativeLayout relativeLayout = (RelativeLayout)this.findViewById(R.id.relativeLayout1); RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(cell_Width, LayoutParams.MATCH_PARENT); param.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); relativeLayout.setLayoutParams(param); [/code] 但是报错: [code="java"] 04-01 23:49:13.572: E/AndroidRuntime(1246): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.widget.LinearLayout.measureVertical(LinearLayout.java:587) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.widget.LinearLayout.onMeasure(LinearLayout.java:519) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.view.View.measure(View.java:10828) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.widget.FrameLayout.onMeasure(FrameLayout.java:267) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.view.View.measure(View.java:10828) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.widget.LinearLayout.measureVertical(LinearLayout.java:764) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.widget.LinearLayout.onMeasure(LinearLayout.java:519) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.view.View.measure(View.java:10828) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.widget.FrameLayout.onMeasure(FrameLayout.java:267) 04-01 23:49:13.572: E/AndroidRuntime(1246): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:1889) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.view.View.measure(View.java:10828) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.view.ViewRoot.performTraversals(ViewRoot.java:938) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.view.ViewRoot.handleMessage(ViewRoot.java:2040) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.os.Looper.loop(Looper.java:132) 04-01 23:49:13.572: E/AndroidRuntime(1246): at android.app.ActivityThread.main(ActivityThread.java:4123) 04-01 23:49:13.572: E/AndroidRuntime(1246): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 23:49:13.572: E/AndroidRuntime(1246): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 23:49:13.572: E/AndroidRuntime(1246): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 23:49:13.572: E/AndroidRuntime(1246): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 23:49:13.572: E/AndroidRuntime(1246): at dalvik.system.NativeStart.main(Native Method) [/code] 查了些资料,比如:http://blog.csdn.net/id19870510/article/details/6398049 说是需要设置父layout,但是试了后依然报错,请问到底如何更改? 谢谢
应用报错fatal错误,强制关闭
LOGCAT 错误: 05-16 07:16:24.503: E/AndroidRuntime(17625): FATAL EXCEPTION: main 05-16 07:16:24.503: E/AndroidRuntime(17625): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fdc/com.example.fdc.Medical_Record}: java.lang.NullPointerException 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.os.Handler.dispatchMessage(Handler.java:99) 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.os.Looper.loop(Looper.java:123) 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.app.ActivityThread.main(ActivityThread.java:3687) 05-16 07:16:24.503: E/AndroidRuntime(17625): at java.lang.reflect.Method.invokeNative(Native Method) 05-16 07:16:24.503: E/AndroidRuntime(17625): at java.lang.reflect.Method.invoke(Method.java:507) 05-16 07:16:24.503: E/AndroidRuntime(17625): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 05-16 07:16:24.503: E/AndroidRuntime(17625): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 05-16 07:16:24.503: E/AndroidRuntime(17625): at dalvik.system.NativeStart.main(Native Method) 05-16 07:16:24.503: E/AndroidRuntime(17625): Caused by: java.lang.NullPointerException 05-16 07:16:24.503: E/AndroidRuntime(17625): at com.example.fdc.Medical_Record.onCreate(Medical_Record.java:84) 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-16 07:16:24.503: E/AndroidRuntime(17625): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 05-16 07:16:24.503: E/AndroidRuntime(17625): ... 11 more 代码: package com.example.fdc; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.util.Log; import android.view.Menu; import android.widget.TextView; public class Medical_Record extends Activity{ TextView Record1, Record2,Record3, Record4,Record5,Record6 ,Record7,Record8,Record9, Record10,Record11; String array_record []; String username =""; String id=""; String pname=""; String prel=""; String paddress=""; String pno=""; String poffice=""; String pmobile=""; String pbirth=""; String pcomment=""; String pcomplain = ""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_medical__record); Record1 = (TextView) findViewById(R.id.precord1); Record2 = (TextView) findViewById(R.id.precord2); Record3 = (TextView) findViewById(R.id.precord3); Record4 = (TextView) findViewById(R.id.precord4); Record5 = (TextView) findViewById(R.id.precord5); Record6 = (TextView) findViewById(R.id.precord6); Record7 = (TextView) findViewById(R.id.precord7); Record8 = (TextView) findViewById(R.id.precord8); Record9 = (TextView) findViewById(R.id.precord9); Record10 = (TextView) findViewById(R.id.precord10); Intent intent=getIntent(); String message =intent.getStringExtra("values"); if(message.contains(",")) { array_record=message.split(","); username =array_record[0]; id=array_record[1]; pname=array_record[2]; prel=array_record[3]; paddress=array_record[4]; pno=array_record[5]; poffice=array_record[6]; pmobile=array_record[7]; pbirth=array_record[8]; pcomment=array_record[9]; pcomplain = array_record[10]; Log.d("ijazzzz", prel); Record1.setText(username); Record2.setText(id); Record3.setText(pname); Record4.setText(prel); Record5.setText(paddress); Record6.setText(pno); Record7.setText(poffice); Record8.setText(pmobile); Record9.setText(pbirth); Record10.setText(pcomment); Record11.setText(pcomplain); } else { Log.d("ijazzzz", "sssssssssssssssss"); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.medical__record, menu); return true; } } 调试代码并没有错误,获取数据来自HttpPost,并且将长数据分割后存储在字符串中。 最后在Textview中设置时报错了。
Android Socket服务器线程问题
急!急!急!我是搞java得由于公司有个项目没有android人手,让我做了一个app。马上就要交付测试了,现在遇到这样的问题:启动Android Socket服务端时报错说不让在主线程启动,找了一下相关资料说将线程启动到后台可是不知道怎么改,这是我的代码。 ServerSocket server; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Button bt_action = (Button) findViewById(R.id.bt_action); bt_action.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { ServerSocket server = new ServerSocket(); while (true) { // 未连通前线程阻塞,连通后开启一个socket通道线程后继续监听9999端口 Socket socket = server.accept(); System.out.println(socket.getInetAddress() .getHostAddress() + "连接进入"); new SocketThread(socket).start(); } } catch (IOException e) { e.printStackTrace(); } } }); } // 一个服务器端口中监听多个客服端通道线程 class SocketThread extends Thread { // 所有通道写入流的集合 private final List<PrintWriter> list = new ArrayList<PrintWriter>(); private BufferedReader bufferedReader; private PrintWriter printWriter; InputStream in = null; public SocketThread(Socket socket) throws IOException { this.bufferedReader = new BufferedReader(new InputStreamReader( socket.getInputStream())); this.printWriter = new PrintWriter(socket.getOutputStream()); this.in = socket.getInputStream(); list.add(printWriter); } @Override public void run() { String string = null; while (true) { try { // 服务器在通道中读到的信息回显给客服端 string = bufferedReader.readLine(); System.out.println("客服端信息:" + string); for (PrintWriter printWriter : list) { // printWriter.write("服务器显示:" + string + "\r\n"); printWriter.flush(); } } catch (IOException e) { } } } }
Android实现简单的账号注册功能时JSON报错?
最近在做一个对接融云的聊天界面,在实现注册功能时报错。具体如下: 通过Android客户端注册账号,服务器和数据库用Apache+php+Mysql+phpmyadmin。 Android主要代码 final String username = et_username.getText().toString(); String password = et_password.getText().toString(); if (username.equals("") || password.equals("")) { Toast.makeText(RegActivity.this, "用户名或密码不能为空", Toast.LENGTH_LONG).show(); } else { AsyncHttpClient client = new AsyncHttpClient(); RequestParams params = new RequestParams(); params.add("username", username); params.add("password", password); client.post("http://192.168.1.101/chat/reg.php", params, new AsyncHttpResponseHandler() { @Override public void onSuccess(int i, Header[] headers, byte[] bytes) { String response = new String(bytes); Log.e("debug", response); JSONObject object = null; try { object = new JSONObject(response); String status = object.getString("status"); if (status.equals("exists")) { Toast.makeText(RegActivity.this, "用户名已存在,请更换", Toast.LENGTH_LONG).show(); } else if (status.equals("error")) { Toast.makeText(RegActivity.this, "出现错误,请稍后重试", Toast.LENGTH_LONG).show(); } else if (status.equals("success")) { String token = object.getString("token"); App.token = token; App.username = username; App.isLogin = true; Intent intent = new Intent(RegActivity.this, MainActivity.class); startActivity(intent); RegActivity.this.finish(); } } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { Toast.makeText(RegActivity.this, "网络错误,请稍后重试", Toast.LENGTH_LONG).show(); } }); ** D:\wamp\Apache22\htdocs\chat中reg.php代码** <?php require_once('./conn.php'); require_once('./api.php'); if(isset($_POST['username']) && isset($_POST["password"])) { $password = md5($_POST['password']); $sql = "select * from `user` where username='$_POST[username]'"; $query = mysqli_query($connect, $sql); $row = mysqli_num_rows($query); if($row == 0) { $p = new ServerAPI("vnroth0krcc8o", "77S067I5vYC"); $r = $p->getToken($_POST['username'], "", ""); $obj = json_decode($r); if($obj->code != 200) { $result = array("status" => "error"); echo json_encode($result); } else { $token = $obj->token; $sql2 = "insert into `user` (username, password, token) values('$_POST[username]', '$password', '$token')"; $query = mysqli_query($connect, $sql2); $result = array("status"=>"success", "token"=>$token); echo json_encode($result); } } else { $result = array("status"=>"exists"); echo json_encode($result); } } ?> 点击注册填写账号密码后报错信息是 04-30 02:25:16.236 6715-6801/com.gzs.jike_chat D/OpenGLRenderer: endAllStagingAnimators on 0xa46aad00 (RippleDrawable) with handle 0xa44ae3a0 04-30 02:25:27.004 6715-6728/com.gzs.jike_chat I/art: Background sticky concurrent mark sweep GC freed 1590(58KB) AllocSpace objects, 0(0B) LOS objects, 6% free, 2MB/2MB, paused 12.793ms total 27.808ms 04-30 02:25:36.852 6715-6715/com.gzs.jike_chat V/AsyncHttpResponseHandler: Progress 174 from 174 (100%) 04-30 02:25:36.852 6715-6715/com.gzs.jike_chat E/debug: 用户名称 不能为空<br /> <b>Notice</b>: Trying to get property of non-object in <b>D:\wamp\Apache22\htdocs\chat\reg.php</b> on line <b>16</b><br /> {"status":"error"} 04-30 02:25:36.852 6715-6715/com.gzs.jike_chat W/System.err: org.json.JSONException: Value 用户名称 of type java.lang.String cannot be converted to JSONObject 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at org.json.JSON.typeMismatch(JSON.java:111) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at com.gzs.jike_chat.RegActivity$1$1.onSuccess(RegActivity.java:54) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:311) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:138) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at android.os.Looper.loop(Looper.java:135) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5254) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at java.lang.reflect.Method.invoke(Native Method) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at java.lang.reflect.Method.invoke(Method.java:372) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 04-30 02:25:36.853 6715-6715/com.gzs.jike_chat W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 04-30 02:25:48.368 6715-6723/com.gzs.jike_chat W/art: Suspending all threads took: 6.184ms 在网上没找到解决方案,有的说是jar包版本问题,我在lib只导入一个android-async-http-1.4.6.jar,请大神指导下,该如何解决这个问题?谢谢!
安卓的录音程序,运行时闪退求解
按照教程写了个安卓的录音程序,在点击结束录音时闪退,求大神帮看看代码,感谢 闪退时报错日志 04-08 19:47:29.702: D/ViewRootImpl(11731): ViewPostImeInputStage processPointer 0 04-08 19:47:29.802: D/ViewRootImpl(11731): ViewPostImeInputStage processPointer 1 04-08 19:47:29.802: E/MediaRecorder(11731): stop called in an invalid state: 4 04-08 19:47:29.802: D/AndroidRuntime(11731): Shutting down VM 04-08 19:47:29.802: E/AndroidRuntime(11731): FATAL EXCEPTION: main 04-08 19:47:29.802: E/AndroidRuntime(11731): Process: com.example.recorder, PID: 11731 04-08 19:47:29.802: E/AndroidRuntime(11731): java.lang.IllegalStateException 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.media.MediaRecorder._stop(Native Method) 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.media.MediaRecorder.stop(MediaRecorder.java:976) 04-08 19:47:29.802: E/AndroidRuntime(11731): at com.example.recorder.MainActivity.stop(MainActivity.java:102) 04-08 19:47:29.802: E/AndroidRuntime(11731): at com.example.recorder.MainActivity$2.onClick(MainActivity.java:61) 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.view.View.performClick(View.java:5698) 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.widget.TextView.performClick(TextView.java:10896) 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.view.View$PerformClick.run(View.java:22565) 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.os.Handler.handleCallback(Handler.java:739) 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.os.Handler.dispatchMessage(Handler.java:95) 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.os.Looper.loop(Looper.java:148) 04-08 19:47:29.802: E/AndroidRuntime(11731): at android.app.ActivityThread.main(ActivityThread.java:7224) 04-08 19:47:29.802: E/AndroidRuntime(11731): at java.lang.reflect.Method.invoke(Native Method) 04-08 19:47:29.802: E/AndroidRuntime(11731): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 04-08 19:47:29.802: E/AndroidRuntime(11731): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 04-08 19:47:32.042: I/Process(11731): Sending signal. PID: 11731 SIG: 9 DEBUG 线程 [main](已暂挂(异常 IllegalStateException)) MediaRecorder._stop() 行: 不可用 [本机方法] MediaRecorder.stop() 行: 976 MainActivity.stop() 行: 102 MainActivity$2.onClick(View) 行: 61 Button(View).performClick() 行: 5698 Button(TextView).performClick() 行: 10896 View$PerformClick.run() 行: 22565 Handler.handleCallback(Message) 行: 739 ViewRootImpl$ViewRootHandler(Handler).dispatchMessage(Message) 行: 95 Looper.loop() 行: 148 ActivityThread.main(String[]) 行: 7224 Method.invoke(Object, Object...) 行: 不可用 [本机方法] ZygoteInit$MethodAndArgsCaller.run() 行: 1230 ZygoteInit.main(String[]) 行: 1120 主程序 package com.example.recorder; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import java.io.IOException; import android.media.MediaRecorder; import android.media.AudioFormat; import android.media.AudioRecord; import android.os.Bundle; import android.os.Environment; import android.app.Activity; import android.util.Log; import android.widget.Button; import java.io.BufferedOutputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class MainActivity extends Activity { MediaRecorder audioRecorder; Button START; Button END; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //creat START=(Button)findViewById(R.id.start); END=(Button)findViewById(R.id.end); START.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { record(); } }); END.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { stop(); } }); } public void record() { if(audioRecorder==null) { audioRecorder=new MediaRecorder(); } String path=Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.mp4"; File file=new File(path); if(file.exists()) file.delete(); try { file.createNewFile(); audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); audioRecorder.setAudioEncodingBitRate(MediaRecorder.AudioEncoder.AMR_NB); audioRecorder.setOutputFile(path); audioRecorder.prepare(); audioRecorder.start(); } catch(IOException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } START.setText("recording"); } public void stop() { if(audioRecorder!=null) { audioRecorder.stop(); audioRecorder.release(); audioRecorder=null; } START.setText("录音"); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } MANIFEXT: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.recorder" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
在我更新UI时报了这个错?是没有在主线程更新导致的吗?
``` 07-27 09:35:10.699: E/AndroidRuntime(25937): FATAL EXCEPTION: main 07-27 09:35:10.699: E/AndroidRuntime(25937): android.content.res.Resources$NotFoundException: String resource ID #0x0 07-27 09:35:10.699: E/AndroidRuntime(25937): at android.content.res.Resources.getText(Resources.java:237) 07-27 09:35:10.699: E/AndroidRuntime(25937): at android.widget.TextView.setText(TextView.java:3718) 07-27 09:35:10.699: E/AndroidRuntime(25937): at com.example.myweathertest.activities.WeatherActivity.showWeather(WeatherActivity.java:92) 07-27 09:35:10.699: E/AndroidRuntime(25937): at com.example.myweathertest.activities.WeatherActivity.access$0(WeatherActivity.java:67) 07-27 09:35:10.699: E/AndroidRuntime(25937): at com.example.myweathertest.activities.WeatherActivity$1.onSuccess(WeatherActivity.java:109) 07-27 09:35:10.699: E/AndroidRuntime(25937): at com.baidu.apistore.sdk.network.c.onPostExecute(Unknown Source) 07-27 09:35:10.699: E/AndroidRuntime(25937): at android.os.AsyncTask.finish(AsyncTask.java:631) 07-27 09:35:10.699: E/AndroidRuntime(25937): at android.os.AsyncTask.access$600(AsyncTask.java:177) 07-27 09:35:10.699: E/AndroidRuntime(25937): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644) 07-27 09:35:10.699: E/AndroidRuntime(25937): at android.os.Handler.dispatchMessage(Handler.java:99) 07-27 09:35:10.699: E/AndroidRuntime(25937): at android.os.Looper.loop(Looper.java:153) 07-27 09:35:10.699: E/AndroidRuntime(25937): at android.app.ActivityThread.main(ActivityThread.java:5297) 07-27 09:35:10.699: E/AndroidRuntime(25937): at java.lang.reflect.Method.invokeNative(Native Method) 07-27 09:35:10.699: E/AndroidRuntime(25937): at java.lang.reflect.Method.invoke(Method.java:511) 07-27 09:35:10.699: E/AndroidRuntime(25937): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 07-27 09:35:10.699: E/AndroidRuntime(25937): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 07-27 09:35:10.699: E/AndroidRuntime(25937): at dalvik.system.NativeStart.main(Native Method) ```
利用bmob加载数据到listview上,出现问题,求解决啊
使用bmob的菜鸟,写了一个利用bmob把图文数据加载到listview的代码,图片文件是用的bmobfile,我是通过获取它的URL然后进行网络图片下载来加载图片的,但是运行出错了,求解决啊 adapter的代码: public class ClassListAdapter extends BaseAdapter { private Context mContext; private LayoutInflater mInflater = null;// LayoutInflater作用是将layout的xml布局文件实例化为View类对象 private ArrayList<ClassInfo> mClassList = null; // 所选分类下的所有列表 public ClassListAdapter(Context context, ArrayList<ClassInfo> classList) { setmContext(context); mClassList = classList; mInflater = LayoutInflater.from(context); } @Override public int getCount() { return mClassList.size(); } @Override public Object getItem(int position) { return mClassList.get(position); } @Override public long getItemId(int position) { return position; } public void refresh(ArrayList<ClassInfo> list) { mClassList = list; notifyDataSetChanged(); } @Override public View getView(int position, View convertView, ViewGroup parent) { ClassHolder classHodler; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_class_item, null); classHodler = new ClassHolder(); classHodler.tvClassName = (TextView) convertView .findViewById(R.id.tv_cn); classHodler.tvDate = (TextView) convertView .findViewById(R.id.tv_date); classHodler.ivClassPic = (ImageView) convertView .findViewById(R.id.class_pic); convertView.setTag(classHodler); } else { classHodler = (ClassHolder) convertView.getTag(); } classHodler.tvClassName.setText(mClassList.get(position).getCname()); classHodler.tvDate.setText(mClassList.get(position).getDate()); String url = mClassList.get(position).getCpic().getFileUrl(); classHodler.ivClassPic.setTag(url); new ImageLoader().showImageByThread(classHodler.ivClassPic, url); return convertView; } public Context getmContext() { return mContext; } public void setmContext(Context mContext) { this.mContext = mContext; } } listactivity的代码: public class ClassActivity extends Activity implements OnItemClickListener { private static final String TAG = "ClassActivity"; private ListView classListView; private ArrayList<ClassInfo> classList = new ArrayList<ClassInfo>(); private ClassListAdapter mClassListAdapter; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_class_all); initView(); initEvent(); } private void initEvent() { // TODO Auto-generated method stub mClassListAdapter = new ClassListAdapter(this, classList); classListView.setAdapter(mClassListAdapter); classListView.setOnItemClickListener(this); getClassData(); } private void initView() { // TODO Auto-generated method stub classListView = (ListView) findViewById(R.id.lv_class_all); } private void getClassData() { // TODO Auto-generated method stub BmobQuery<ClassInfo> query = new BmobQuery<ClassInfo>(); query.order("-updatedAt"); query.findObjects(this, new FindListener<ClassInfo>() { @Override public void onSuccess(final List<ClassInfo> object) { classList = (ArrayList<ClassInfo>) object; mClassListAdapter.refresh((ArrayList<ClassInfo>) classList); mClassListAdapter.notifyDataSetChanged(); } @Override public void onError(String arg0) { toast("获取数据失败了"); } }); } @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent toClassDetail = new Intent(ClassActivity.this, ClassDetailActivity.class); toClassDetail.putExtra("ClassName", classList.get(position).getCname()); toClassDetail.putExtra("ClassTeacherObjectId", classList.get(position) .getTobjectid()); toClassDetail.putExtra("ClassDate", classList.get(position).getDate()); toClassDetail.putExtra("ClassTime", classList.get(position).getTime()); toClassDetail.putExtra("ClassInfo", classList.get(position).getCinfo()); toClassDetail.putExtra("ClassPic", classList.get(position).getCpic() .getFileUrl()); startActivity(toClassDetail); } public void toast(String toast) { Toast.makeText(this, toast, Toast.LENGTH_SHORT); } } 这是运行时报的错 05-19 04:26:48.082: W/Zygote(25337): mz_is_rooted false 05-19 04:26:48.088: I/art(25337): Late-enabling -Xcheck:jni 05-19 04:26:48.153: E/art(25337): Failed sending reply to debugger: Broken pipe 05-19 04:26:48.153: I/art(25337): Debugger is no longer active 05-19 04:26:48.386: I/art(25337): Background sticky concurrent mark sweep GC freed 1718(102KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 41MB/41MB, paused 8.769ms total 20.573ms 05-19 04:26:48.835: E/GED(25337): Failed to get GED Log Buf, err(0) 05-19 04:26:48.837: I/art(25337): Background partial concurrent mark sweep GC freed 36(1912B) AllocSpace objects, 0(0B) LOS objects, 7% free, 50MB/54MB, paused 6.827ms total 24.126ms 05-19 04:26:48.851: I/OpenGLRenderer(25337): Initialized EGL, version 1.4 05-19 04:26:48.851: W/OpenGLRenderer(25337): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 05-19 04:26:48.867: I/OpenGLRenderer(25337): Initializing program atlas... 05-19 04:26:53.154: W/IInputConnectionWrapper(25337): clearMetaKeyStates on inactive InputConnection 05-19 04:26:56.365: E/MPlugin(25337): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport 05-19 04:26:56.379: E/WifiManager(25337): mWifiServiceMessenger == null 05-19 04:26:56.409: I/System.out(25337): url:http://open.bmob.cn/7/login 05-19 04:26:56.415: D/libc-netbsd(25337): [getaddrinfo]: hostname=open.bmob.cn; servname=(null); cache_mode=(null), netid=0; mark=0 05-19 04:26:56.415: D/libc-netbsd(25337): [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 05-19 04:26:56.416: D/libc-netbsd(25337): [getaddrinfo]: hostname=open.bmob.cn; servname=(null); cache_mode=(null), netid=0; mark=0 05-19 04:26:56.416: D/libc-netbsd(25337): [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0 05-19 04:26:56.476: D/libc-netbsd(25337): getaddrinfo: open.bmob.cn get result from proxy >> 05-19 04:26:56.476: I/System.out(25337): propertyValue:true 05-19 04:26:56.478: I/System.out(25337): [CDS]connect[open.bmob.cn/123.59.85.59:80] tm:2 05-19 04:26:56.545: I/System.out(25337): [OkHttp] sendRequest>> 05-19 04:26:56.545: I/System.out(25337): [OkHttp] sendRequest<< 05-19 04:26:56.609: I/NetworkManagementSocketTagger(25337): untagSocket(39) 05-19 04:26:56.799: E/MPlugin(25337): Unsupported class: com.mediatek.common.telephony.IOnlyOwnerSimSupport 05-19 04:26:56.806: E/WifiManager(25337): mWifiServiceMessenger == null 05-19 04:26:56.820: I/System.out(25337): url:http://open.bmob.cn/7/find 05-19 04:26:56.849: I/System.out(25337): [CDS]EAGAIN in Recvfrom 05-19 04:26:56.849: I/System.out(25337): [CDS]read byte is 0 05-19 04:26:56.849: I/System.out(25337): [OkHttp] sendRequest>> 05-19 04:26:56.850: I/System.out(25337): [OkHttp] sendRequest<< 05-19 04:26:56.921: I/NetworkManagementSocketTagger(25337): untagSocket(39) 05-19 04:26:56.994: E/AndroidRuntime(25337): FATAL EXCEPTION: main 05-19 04:26:56.994: E/AndroidRuntime(25337): Process: com.keke.doexercise, PID: 25337 05-19 04:26:56.994: E/AndroidRuntime(25337): g.Hamlet: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 176 05-19 04:26:56.994: E/AndroidRuntime(25337): at j.Though$This.Code(SourceFile:176) 05-19 04:26:56.994: E/AndroidRuntime(25337): at g.Tempest.Code(SourceFile:803) 05-19 04:26:56.994: E/AndroidRuntime(25337): at g.Tempest.Code(SourceFile:717) 05-19 04:26:56.994: E/AndroidRuntime(25337): at cn.bmob.v3.requestmanager.thing$3.Code(SourceFile:1) 05-19 04:26:56.994: E/AndroidRuntime(25337): at cn.bmob.v3.requestmanager.This.V(SourceFile:1) 05-19 04:26:56.994: E/AndroidRuntime(25337): at e.I.run(SourceFile:99) 05-19 04:26:56.994: E/AndroidRuntime(25337): at android.os.Handler.handleCallback(Handler.java:815) 05-19 04:26:56.994: E/AndroidRuntime(25337): at android.os.Handler.dispatchMessage(Handler.java:104) 05-19 04:26:56.994: E/AndroidRuntime(25337): at android.os.Looper.loop(Looper.java:194) 05-19 04:26:56.994: E/AndroidRuntime(25337): at android.app.ActivityThread.main(ActivityThread.java:5779) 05-19 04:26:56.994: E/AndroidRuntime(25337): at java.lang.reflect.Method.invoke(Native Method) 05-19 04:26:56.994: E/AndroidRuntime(25337): at java.lang.reflect.Method.invoke(Method.java:372) 05-19 04:26:56.994: E/AndroidRuntime(25337): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1005) 05-19 04:26:56.994: E/AndroidRuntime(25337): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:800) 05-19 04:26:56.994: E/AndroidRuntime(25337): Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 176 05-19 04:26:56.994: E/AndroidRuntime(25337): at l.This.beginArray(SourceFile:338) 05-19 04:26:56.994: E/AndroidRuntime(25337): at j.of$This.Code(SourceFile:1) 05-19 04:26:56.994: E/AndroidRuntime(25337): at j.Though$1.Code(SourceFile:93) 05-19 04:26:56.994: E/AndroidRuntime(25337): at j.Though$This.Code(SourceFile:172) 05-19 04:26:56.994: E/AndroidRuntime(25337): ... 13 more 05-19 04:26:57.004: I/Process(25337): Sending signal. PID: 25337 SIG: 9 05-19 04:26:58.048: I/art(25443): Background sticky concurrent mark sweep GC freed 701(46KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 50MB/50MB, paused 5.901ms total 15.544ms 05-19 04:26:58.051: E/GED(25443): Failed to get GED Log Buf, err(0) 05-19 04:26:58.068: I/OpenGLRenderer(25443): Initialized EGL, version 1.4 05-19 04:26:58.069: W/OpenGLRenderer(25443): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 05-19 04:26:58.084: I/OpenGLRenderer(25443): Initializing program atlas... 05-19 04:27:29.607: W/IInputConnectionWrapper(25443): showStatusIcon on inactive InputConnection
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
Elastic:菜鸟上手指南
您们好,我是Elastic的刘晓国。如果大家想开始学习Elastic的话,那么这里将是你理想的学习园地。在我的博客几乎涵盖了你想学习的许多方面。在这里,我来讲述一下作为一个菜鸟该如何阅读我的这些博客文章。 我们可以按照如下的步骤来学习: 1) Elasticsearch简介:对Elasticsearch做了一个简单的介绍 2) Elasticsearch中的一些重要概念:cluster, n
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、PDF搜索网站推荐 对于大部
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
Java知识体系最强总结(2020版)
更新于2020-01-05 18:08:00 本人从事Java开发已多年,平时有记录问题解决方案和总结知识点的习惯,整理了一些有关Java的知识体系,这不是最终版,会不定期的更新。也算是记录自己在从事编程工作的成长足迹,通过博客可以促进博主与阅读者的共同进步,结交更多志同道合的朋友。特此分享给大家,本人见识有限,写的博客难免有错误或者疏忽的地方,还望各位大佬指点,在此表示感激不尽。 整理的Ja
计算机专业的书普遍都这么贵,你们都是怎么获取资源的?
介绍几个可以下载编程电子书籍的网站。 1.Github Github上编程书资源很多,你可以根据类型和语言去搜索。推荐几个热门的: free-programming-books-zh_CN:58K 星的GitHub,编程语言、WEB、函数、大数据、操作系统、在线课程、数据库相关书籍应有尽有,共有几百本。 Go语言高级编程:涵盖CGO,Go汇编语言,RPC实现,Protobuf插件实现,Web框架实
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我
复习一周,京东+百度一面,不小心都拿了Offer
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前言 还记得我上周说的重庆邮电研二的读者么? 、 知道他拿了Offer之后我也很开心,我就想把它的面试经历和面试题分享出来
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前言 很多次小伙伴问到学习方法,我也很想写这样的一篇文章来跟大家讨论下关于学习方法这件事情。 其实学习方法这个事情,我没啥发言权
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了......,这可都是提升你幸福感的高效率生产力工具哦! 走起!...... NO、1 ScreenToGif 屏幕,摄像头和
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦......,嗯,我们导员是所有导员中最帅的一个,真的...... 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强......,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧?
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每
史上最全的IDEA快捷键总结
写在前面: 我是 扬帆向海,这个昵称来源于我的名字以及女朋友的名字。我热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。 这博客是对自己学习的一点点总结及记录,如果您对 Java、算法 感兴趣,可以关注我的动态,我们一起学习。 用知识改变命运,让我们的家人过上更好的生活。 相关文章: Idea 中最常用的10款插件,提高开发效率 Eclipse 最牛逼的 10 组快捷键,提高开发效率
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前前言 为啥今天有个前前言呢? 因为你们的丙丙啊,昨天有牌面了哟,直接被微信官方推荐,知乎推荐,也就仅仅是还行吧(心里乐开花)
一文带你看清 HTTP 所有概念
上一篇文章我们大致讲解了一下 HTTP 的基本特征和使用,大家反响很不错,那么本篇文章我们就来深究一下 HTTP 的特性。我们接着上篇文章没有说完的 HTTP 标头继续来介绍(此篇文章会介绍所有标头的概念,但没有深入底层) HTTP 标头 先来回顾一下 HTTP1.1 标头都有哪几种 HTTP 1.1 的标头主要分为四种,通用标头、实体标头、请求标头、响应标头,现在我们来对这几种标头进行介绍 通用
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东
【综合篇】浏览器的工作原理:浏览器幕后揭秘
web(给达达前端加星标,提升前端技能) 了解浏览器是如何工作的,能够让你站在更高的角度去理解前端 浏览器的发展历程的三大路线,第一是应用程序web化,第二是web应用移动化,第三是web操作系统化。是不是有点不直白。 应用程序web化就是随着现在技术的发展,现在越来越多的应用转向了浏览器与服务器,就是B/S架构;web应用移动化,就是在移动设备应用,什么是移动设备呢。 “移动设备:
破14亿,Python分析我国存在哪些人口危机!
2020年1月17日,国家统计局发布了2019年国民经济报告,报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏,但是很多人并没有看到我国复杂的人口问题:老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧! 更多有趣分析教程,扫描下方二维码关注vx公号「裸睡的猪」 即可查看! 一、背景 1.人口突破14亿 2020年1月17日,国家统计局发布
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。 再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。 下文是原回答,希望能对你能有所启发。 如果我说,这个世界上人真的分三六九等,...
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合...
死磕Lambda表达式(二):Lambda的使用
在哪使用Lambda表达式?怎么样正确的使用Lambda表达式?
史上最牛逼的 Eclipse 快捷键,提高开发效率!
如果你在使用IDEA,请参考博主另外的一篇idea快捷键的博客。
在三线城市工作爽吗?
我是一名程序员,从正值青春年华的 24 岁回到三线城市洛阳工作,至今已经 6 年有余。一不小心又暴露了自己的实际年龄,但老读者都知道,我驻颜有术,上次去看房子,业务员肯定地说:“小哥肯定比我小,我今年还不到 24。”我只好强颜欢笑:“你说得对。” 从我拥有记忆到现在进入而立之年,我觉得,我做过最明智的选择有下面三个: 1)高中三年,和一位女同学保持着算不上朋友的冷淡关系;大学半年,把这位女同学追到...
CSS操作之你不得不知的一些小技巧(一)ヾ(Ő∀Ő๑)ノ太棒了!!
目录 CSS单行/多行文本,超出隐藏并显示省略号 1. CSS单行/多行文本,超出隐藏并显示省略号 方法一:使用CSS属性 单行文本溢出显示省略号 width: 100px; overflow: hidden; text-overflow:ellipsis; //文本溢出显示省略号 white-space: nowrap; //文本不会换...
强烈推荐 10 款珍藏的 Chrome 浏览器插件
Firebug 的年代,我是火狐(Mozilla Firefox)浏览器的死忠;但后来不知道为什么,该插件停止了开发,导致我不得不寻求一个新的网页开发工具。那段时间,不少人开始推荐 Chrome 浏览器,我想那就试试吧,期初我觉得用起来很别扭,毕竟我不是一个“喜新厌旧”的人。但用的次数越来越多,也就习惯了。 Chrome 浏览器有一个好处,就是插件极其丰富,只有你想不到的,没有你找不到的,这恐怕是...
我以为我对数据库索引十分了解,直到我遇到了阿里面试官。
索引的数据结构分析,数据库面试到索引最常见的问题分析,我总结了一下。
Java程序员都需要懂的「反射」
前言 只有光头才能变强。 文本已收录至我的GitHub精选文章,欢迎Star:https://github.com/ZhongFuCheng3y/3y 今天来简单写一下Java的反射。本来没打算写反射这个知识点的,只是不少的读者都问过我:“你的知识点好像缺了反射阿。能不能补一下?” 这周末也有点空了,所以来写写我对反射的简单理解。这篇是入门文章,没有高深的知识点,希望能对新人有帮助。如果...
相关热词 c#判断数字不得为负数 c#帧和帧协议 c#算偏移值 c# 在枚举中 c#6 字符串 插值 c#程序中的占位符标签 c#监听数组变化 c# vlc c#索引实现 c# 局域网广播通信
立即提问