Welcome to
w3study.github.io
Debugging the Android app in hindi
Android App Debugging -
Debugging का मतलब है bugs को ढूँढना और Fix करना। Android Studio हमें कई tools देता है जिससे हम Errors, Crashes, और Unexpected Behaviors को ठीक कर सकते हैं।
1. Debug Mode में App run करना
- Android Studio में अपना project खोलें।
- "Run" के पास वाले "Debug" buttom पर click करें या Shift + F9 (Windows/Linux) | ⌘ + Option + D (Mac) दबाएं।
- Emulator या Physical Device चुनें।
- App Debug Mode में start होगा, जिससे आप Code Execution को step-by-step ट्रैक कर सकते हैं।
2. Breakpoints सेट करना (Step-by-Step Debugging)
Breakpoints ऐसे points होते हैं, जहाँ पर Code Execution रुक जाती है ताकि आप Variable Values को Analyze कर सकें।
Breakpoint कैसे लगाएं?
- Java/Kotlin Code Editor में किसी भी line के left side पर क्लिक करें।
- वहाँ लाल गोला (🔴) दिखेगा, इसका मतलब Breakpoint सेट हो गया।
- अब Debug Mode में रन करें और Execution वहाँ रुक जाएगी।
Step-by-Step Execution
- Step Over (F8): अगली line पर जाने के लिए।
- Step Into (F7): किसी function के अंदर जाने के लिए।
- Step Out (Shift + F8): Function से बाहर आने के लिए।
- Resume (F9): Debugging को continue करने के लिए।
3. Logcat का इस्तेमाल (Errors & Logs track करें)
Logcat Android Studio में एक Console है, जहाँ आप Error Messages, Debug Logs, और System Logs देख सकते हैं।
Log Messages print करने के लिए:
import android.util.Log;
Log.d("DEBUG_TAG", "यह एक Debug Message है");
Log.e("ERROR_TAG", "यह एक Error Message है");
- Logcat को खोलने के लिए: Alt + 6 (Windows/Linux) | Cmd + 6 (Mac) दबाएं।
- Filter लगाएं: सिर्फ Errors या Debug Logs देखने के लिए "Error" या "Debug" से Filter करें।
4. Exception और Crash को Debug करना
अगर App Crash हो रहा है, तो Logcat में Red Color में Error Message दिखेगा।
Common Errors:
- NullPointerException: किसी Object को बिना Initialize किए इस्तेमाल करना।
- ArrayIndexOutOfBoundsException: Array के बाहर Index Access करना।
- NetworkOnMainThreadException: Main Thread पर Network Call करना।
Solution:
Logcat में Exact Error Message और Stack Trace देखें।
Try-Catch Block का इस्तेमाल करें:
try {
int a = 5 / 0; // Error
} catch (Exception e) {
Log.e("ERROR_TAG", "Exception: " + e.getMessage());
}
5. Debugging Using Toast & Snackbar
अगर आपको सिर्फ Debugging के लिए छोटे Messages दिखाने हैं, तो:
- Toast Message (Short Debugging Messages)
Toast.makeText(getApplicationContext(), "This is Debug Message", Toast.LENGTH_SHORT).show();
- Snackbar (Better UI Debugging Message)
Snackbar.make(view, "This is Debugging Snackbar", Snackbar.LENGTH_LONG).show();
6. Debugging Using the Android Profiler
Android Studio में Android Profiler का इस्तेमाल CPU, Memory, Network Usage और Battery Consumption को Analyze करने के लिए किया जाता है।
Android Profiler कैसे खोलें?
- Run → Profiler को select करें।
- यहाँ से CPU, Memory, और Network Activity को live monitor कर सकते हैं।
- अगर कोई Process बहुत ज्यादा Memory खा रही है, तो उसे Optimize कर सकते हैं।
Development of Android Applications Notes in Hindi
Request:
हैलो दोस्तों! उम्मीद करता हूं आपको हमारा यह content/post पसंद आया होगा। अगर आपको हमारा ये content/post पसंद आई हो तो अपने दोस्तों के पास भी share करे। और अगर आपको कोई problem या कोई specific content हिन्दी में चाहिए है तो आप हमें नीचे दिए गए Email या whatsapp number के जरिए बता सकते है।
अगर आप CCC/diploma/polytechnic/MCA/BCA etc कर रहे है तो ये website स्पेशली आपके लिए ही है, जो student हिंदी में पढ़ाई करते है।
Contact Us
Email: deepanshuranjan8057@gmail.com
Whatsapp: +91 8057754706
Follow Us