Transcript Android
Android Studio IDE Tools
Operation Summary
• http://www.vogella.com/tutorials/Android/art
icle.html
Project and File Structure-Android
• Shows the most important source directories at
the top level of the module hierarchy.
• Groups the build files for all modules in a
common folder.
• Groups all the manifest files for each module in a
common folder.
• Shows resource files from all Gradle source sets.
• Groups resource files for different locales,
orientations, and screen types in a single group
per resource type.
Project and File Structure-Android
Project and File Structure- Gradle Scripts
• The Android project view shows all the build files
at the top level of the project hierarchy
under Gradle Scripts. Each project module
appears as a folder at the top level of the project
hierarchy and contains these four elements at the
top level:
• java/ - Source files for the module.
• manifests/ - Manifest files for the module.
• res/ - Resource files for the module.
• Gradle Scripts/ - Gradle build and property files.
Project and File Structure- Gradle Scripts
Project and File Structure-Project
• When you use the Project view in Android
Studio, you should notice that the project
structure appears different than you may be
used to in Eclipse. Each instance of Android
Studio contains a project with one or more
application modules. Each application module
folder contains the complete source sets for
that module,
including src/main/ andsrc/androidTest/ direc
tories, resources, build file and the Android
manifest. For the most part, you will need to
modify the files under each
module's src/main/ directory for source code
updates, the gradle.build file for build
specification and the files
under src/androidTest/ directory for test case
creation.
Memory and CPU monitor
Android Studio provides a memory and CPU monitor view so
you can more easily monitor your app's performance and
memory usage to track CPU usage, find deallocated objects,
locate memory leaks, and track the amount of memory the
connected device is using. With your app running on a device
or emulator, click the Android tab in the lower left corner of
the runtime window to launch the Android runtime window.
Click the Memory or CPU tab.
1. Initiate GC 2. Dump Java Heap 3. Start Allocation Tracking
Data file access
• The Android SDK tools, such as Systrace, logcat,
and Traceview, generate performance and
debugging data for detailed app analysis.
• To view the available generated data files,
click Captures in the left corner of the runtime
window. In the list of the generated files, doubleclick a file to view the data. Right-click
any .hprof files to convert them to a
standard .hprof file format.
Analyzing UI Performance with
Systrace
• https://developer.android.com/tools/help/sys
trace.html
• https://developer.android.com/tools/debuggi
ng/systrace.html
Code inspections
• Android Studio enables several lint checks to ensure:
• Cipher.getInstance() is used with safe values
• In custom Views, the associated declare-styleable for the
custom view uses the same base name as the class name
• Security check for fragment injection
• Where ever property assignment no longer works as
expected
• Gradle plugin version is compatible with the SDK
• Right to left validation
• Required API version
• many others
• With Android Studio, you can also
run lint inspections for a specific build variant,
or for all build variants. You can configure
the lint inspections that run by adding
a lintOptions property to the Android settings
in the build.gradlefile.
• android {
lintOptions {
// set to true to turn off analysis progress
reporting by lint
quiet true
// if true, stop the gradle build if errors are
found
abortOnError false
// if true, only report errors
ignoreWarnings true
}
• You can also manage inspection profiles and
configure inspections within Android Studio.
Choose File > Settings >, expand
the Editor options, and select Inspections.
The Inspection Configuration page appears
with the supported inspections.
Icon Function
Run
Debug
AVD Manager
Setting
Run with
coverage
Attach
debugger to
Android
Process
Project
Structure
Sync Project
with Gradle
Files
SDK Manager
Android Device Monitor
Run Menu
Run App/Debug App
Run App
Debug App
Run
Edit Configuration
選擇目標活動(EX: Mainactivity)
1. 選擇模擬器
2. 載入活動
3. 啟動模擬器
Debug
• 與Run相似但結果為顯示Debug結果
Edit Configuration
Tools
AVD Manager
按右鍵
SDK Manager
How do I add a library project to the
Android Studio?
• http://stackoverflow.com/questions/1658806
4/how-do-i-add-a-library-project-to-theandroid-studio
專案同步鈕
Features
• https://developer.android.com/tools/studio/st
udio-features.html#git-samples
Android Code Samples on GitHub
• Clicking Import Samples from the File menu
or Welcome page provides seamless access to
Google code samples on GitHub.
Imported code sample
4.4. Install support library
• The support library allows you to use functionality provided
by higher Android releases in lower Android versions.
• In the Android SDK Manager select Extras and install
the Android Support Repository. The Android Support
Library is for the usage of the Eclipse ADT tooling.
• Android currently has several versions of the library, the v4, v7
and v13 version which are valid as of the respective API level
of Android. For example, the support library v7 works as of
Android devices with version API 7. Higher versions of the
support library require also the lower versions to work. For
example, support library v7 requires the v4 library.
•
Import Project from Eclipse
• 可直接在Android Studio介面直接Import
Eclipse發展之專案
• 可能會發生版本相容性錯誤
• 請依指示安裝相容之SDK版本套件