iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 10
0
自我挑戰組

練習程式系列 第 10

android 簡介

  • 分享至 

  • xImage
  •  

看網路上大大們的文章和影片,做些紀錄。
以下內容來自網路上大大們的文章。

Android

基於Linux核心的開放原始碼行動作業系統,由Google成立的Open Handset Alliance(OHA,開放手機聯盟)持續領導與開發。

Android是執行於Linux kernel之上,但並不是GNU/Linux(一種作業系統)。

Android系統原始碼下載:
https://www.itread01.com/p/118037.html

2017年3月,Android全球網路流量和裝置超越Microsoft Windows,正式成為全球第一大作業系統

應用程式(簡稱apps)是擴展裝置功能的軟體,都是利用Android軟體開發工具包(SDK)編寫的,通常是Java程式語言[。Java可以與C語言或C++結合使用。
2017年5月,Google宣布支援Kotlin程式語言

Android擁有越來越多第三方應用程式的選擇,用戶可以透過下載和安裝應用程式的APK(Android應用程式包),或利用應用程式商店來下載,允許用戶在那裡進行安裝、更新和移除。

Android的主要硬體平台為ARM架構,在更高階版本的Android中也正式支援x86及x86-64的架構

在早期的Android應用程式開發中,通常通過在Android SDK(Android軟體開發包)中使用Java作為程式語言來開發應用程式。開發者亦可以通過在Android NDK(Android Native開發包)中使用C語言或者C++語言來作為程式語言開發應用程式。

Android Studio

Android Studio是一個為Android平台開發程式的整合式開發環境。2013年5月16日在Google I/O上發布,可供開發者免費使用。

Kotlin

是一種在Java虛擬機上執行的靜態型別程式語言,它也可以被編譯成為JavaScript原始碼。
雖然與Java語法並不相容,但Kotlin被設計成可以和Java程式碼相互運作,並可以重複使用如Java集合框架等的現有Java類別庫。

Google Nexus

(android studio的AVD常常看到Nexus這個字)

Google Nexus是一個使用Android作業系統的消費電子產品系列,由Google設計、開發、銷售並提供支援,並由與Google合作的原始裝置製造商製造並進行部分的開發。
Nexus 4、Nexus 5由LG代工

整理:
1 可以用Vysor在電腦操作手機。
簡單幾個步驟,Vysor 讓你在電腦上操控 Android 裝置外加遠端遙控!

2 直接從官網學習最方便直接,搜尋:
https://ithelp.ithome.com.tw/upload/images/20190918/201119946clokOIb5d.png

這邊就可以看到常見的activity介紹:
https://ithelp.ithome.com.tw/upload/images/20190918/20111994fGeQNTeKax.png

3 學習android程式,看youtube一步一步學

4 android的架構,理論教學:
What is Android?

apk

步驟
1 先用android studio獲得該app的apk:
build --> bulid bundles /apks --> bulid apks 。 (或是sign apk要填密碼公司之類的)

2 apk檔案的目錄:
C:\Users\AndroidStudioProjects\APPNAME\app\build\outputs\apk\debug
會有app-debug.apk檔案

3
下載Apktool:
https://ibotpeaches.github.io/Apktool/install/
照著windows的步驟

4
Cmd移動到目錄,執行:

apktool d app-debug.apk

產生app-debug資料夾

5
app-debug資料夾裡的smali 和 smali_class2 就是原始碼,只是看不太懂,所以要再把它換成一般的java code

6
下載jd-gui
https://sourceforge.net/projects/dex2jar/
下載的資料夾有這個檔案:d2j-dex2jar.bat

7
在app-debug資料夾會有classes.dex或是classes2.dex檔案。(app-debug\build\apk)
(最近發現看不到classes.dex ,是因為baksmaling classes.dex ?,先不管,找到一個方法,直接把.apk改成.zip解壓縮,就會發現classes.dex和classes2.dex檔案,參考:apk包的破解与反编译
)

在jd-gui目錄下執行

d2j-dex2jar.bat classes.dex

不過會看到:

Detail Error Information in File .\classes-error.zip

會有classes-dex2jar.jar 檔案

8
下載JD-GUI
http://java-decompiler.github.io/
會有jd-gui-1.6.5.jar
開啟jd-gui-1.6.5.jar,然後jd-gui-1.6.5.jar開啟classes-dex2jar.jar
就會看到java原始碼,有些東西不一樣,不過大部分一樣,像是會看到網址。

參考:
https://blog.csdn.net/katrinawj/article/details/80016315
http://huli.logdown.com/posts/661513-android-apk-decompile
ApkTool – Decompile and Edit APK (Windows, Mac & Linux)
How to Install APK Using ADB Commands
Android App Security Fundamentals ( Part 2 ) | Bypass ROOT Detection || Demo

android studio 產生apk

[Hindi] How to create APK file of your android project | Android Studio

產生release版本有一堆錯誤,產生debug版本就沒,因為release版本是發行版本?
(直接build APK產生的APK,不用管加密鑰匙(.jks) 或 公司名稱)

Android Studio Could not get resource ‘https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0/gradle-3.1.0.pom
解答:

File | Settings | Build, Execution, Deployment | Gradle
但是沒有找到 Android Studio -> Enable embedded maven repository
android studio版本:3.5.2,所以放棄這方法。

嘗試增加:
Could not find com.android.tools.lint:lint-gradle Android Studio 3
改成這樣

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com'
            name 'Google'
        }
        maven {
            url 'https://mvnrepository.com/artifact/com.android.tools.lint/lint-gradle-api'
        }
        
    }

Error: Execution failed for task ':app: lintVitalRelease' any one can solve it?
Error when generate signed apk
加這個,忽略掉錯誤,就可以了:

lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

ProGuard

Add documentation for proguard configuration
Android Studio ProGuard使用與注意事項
Activity has leaked window at alertDialog show() method
Debug your app
Debugging in Android Studio: Android Programming
How to hide API URL and parameters in Android APP?

android studio的Event Log問題

1

Unsupported Modules Detected: Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project

Change project name on Android Studio

2

NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN error

3

Disable Android resource / image / PNG optimization

4

Configure Android Studio

有兩項:

Your anti-virus(防毒) program might be impacting your build performance. Android Studio checked the following directories

offline build dependencies
How to set Android Studio Project Gradle Offline. Android Studio Not work Offline.

NDK

Install and configure the NDK and CMake
Native C/ C++ Android application development (part 2): [Passing Complex Data Types]
Android逆向從入門到入土(smali修改,so修改)
KotlinWithAndroidNdk
Android NDK: The Interaction Between Kotlin and C/C++

Missing Android platform(s) detected:'android-29'

遇到這個錯誤,導致不能用模擬器或手機跑app

把 C 槽 的 SDK (C:\Users\ted5\Android\sdk) 遷移到 D槽後 ,就發生的錯誤 。

因為發現SDK 的容量有51 GB ,這樣下去放到C槽會爆,所以把檔案剪下到 D槽 。

之後就不能開模擬器會連手機了 。

參考:
How to fix Android Studio emulator is not working !!! 100% Fix Process finished with exit code 1
Fix Android Emulator Error Message: “PANIC: Missing emulator engine program for 'x86' CPUS.”

加了路徑到環境變數 ,也重啟電腦的,但還是錯誤 。

後來解決了,可能是這個問題 :

Android Studio is using the following JDK location when running Gradle:
					C:\Program Files\Android\Android Studio\jre
					Using different JDK locations on different processes might cause Gradle to
					spawn multiple daemons, for example, by executing Gradle tasks from a terminal
					while using Android Studio.

之後把java
C:\Program Files\Android\Android Studio\jre
也移到D槽 ,就解決問題了。

其他:

1 在cmd輸入

emulator -list-avds

可以看到有哪些AVD:

Nexus_4_API_25_2
Nexus_5X_API_27
Nexus_5_API_26
Nexus_5_API_27
Pixel_XL_API_29

2
輸入

emulator -avd Pixel_XL_API_29

可以開啟模擬器


上一篇
java,mysql、jdbc
下一篇
java,單向連結串列
系列文
練習程式37
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言