:wq source ~/.bash_profile
-Xmx4096m
。gradle.properties
…org.gradle.daemon=true
org.gradle.parallel=true
/data/local/tmp/test.apk note
keytool -genkey -v -keystore adam.keystore -alias adam -storepass 123456 -keypass 123456 -keyalg RSA -validity 36000
apksigner sign --ks adam.keystore --ks-key-alias adam test.apk
apktool+dex2jar+jd-gui 一直是一个比较流行的 Android 反编译组合。 在使用过 jadx 之后觉得 jadx 相比上面的组合具有如下两个优点:
查看源码时直接显示资源名称,而不是像 jd-gui 里显示的资源 ID
E:\kSource\pythonx\orange\dexapk.py
E:\kSource\pythonx\orange\dex-tools\apktool_2.6.1.jar E:\kSource\pythonx\orange\apktool.bat E:\kSource\pythonx\orange\jd-gui-windows-1.6.6\jd-gui.exe E:\kSource\pythonx\orange\dex-tools-2.2-SNAPSHOT\d2j-dex2jar.bat E:\kSource\pythonx\orange\dex-tools\baksmali-2.5.2.jar E:\kSource\pythonx\orange\dex-tools\smali-2.5.2.jar E:\kSource\dist\Bytecode-Viewer-2.11.2.jar C:\Users\ADMIN\Downloads\jadx-gui-1.4.4-with-jre-win\jadx-gui-1.4.4.exe
E:\kSource\pythonx\orange\dex-tools-2.2-SNAPSHOT\d2j-dex2jar.bat classes.dex –output classes.jar E:\kSource\pythonx\orange\dex-tools-2.2-SNAPSHOT\d2j-dex2jar.bat classes2.dex –output classes2.jar E:\kSource\pythonx\orange\dex-tools-2.2-SNAPSHOT\d2j-dex2jar.bat classes3.dex –output classes3.jar E:\kSource\pythonx\orange\dex-tools-2.2-SNAPSHOT\d2j-dex2jar.bat classes4.dex –output classes4.jar
反编译命令:
apktool.bat d 2020_12_12_5.31.0.20201211_dbg.apk -f
apktool.bat d 2020_12_12_5.31.0.20201211_official.apk -f
W: Cant find 9patch chunk in file: "drawable-xxhdpi-v4/umcsdk_exception_bg.9.png". Renaming it to *.png.
打包命令:
apktool.bat b 2020_12_12_5.31.0.20201211_dbg
dex2jar.bat 反编译命令:
d2j-dex2jar.bat [classes.dex 文件]
d2j-dex2jar.bat xyz.apk
jadx?
https://www.cnblogs.com/yyq-quan/archive/2011/07/08/2101434.html https://blog.csdn.net/weixin_34726945/article/details/113044682
E:\android-studio-ide-181.5014246-windows\android-studio\jre\bin\keytool.exe chcp 65001 chcp 936 E:\android-studio-ide-181.5014246-windows\android-studio\jre\bin\keytool.exe -genkey -v -keystore androidguy-test.keystore -alias androidguy -keyalg RSA -validity 30000 testguy
正在为以下对象生成 2,048 位 RSA 密钥对和自签名证书 (SHA256withRSA) ( 有效期为 30,000 天 ):
CN=hai, OU=cf, O=cf, L=zh, ST=zh, C=cn
输入 <androidguy> 的密钥口令(如果和密钥库口令相同,按回车):
[正在存储 androidguy-test.keystore]
Warning:
JKS 密钥库使用专用格式。建议使用 "keytool -importkeystore -srckeystore androidguy-test.keystore -destkeystore androidguy-test.keystore -deststoretype pkcs12" 迁移到行业标准格式 PKCS12。
E:\android-studio-ide-181.5014246-windows\android-studio\jre\bin\jarsigner.exe chcp 936 E:\android-studio-ide-181.5014246-windows\android-studio\jre\bin\jarsigner.exe -verbose -keystore androidguy-test.keystore 2020_12_12_5.31.0.20201211_dbg2.apk androidguy
AndroidStudio 代码达到指定字符长度时自动换行。
local.properties 不完整,造成的问题。
sdk.dir=D\:\\Android\\Sdk
# NDK was located by using ndk.dir property.
# This method is deprecated and will be removed in a future release.
# Please delete ndk.dir from local.properties and set android.ndkVersion
# to [21.1.6352462] in all native modules in the project.
# https://developer.android.com/r/studio-ui/ndk-dir
# Affected Modules: app
ndk.dir=D\:\\Android\\Sdk\\ndk-bundle # 最新版已经不需要了。
ERROR: ABIs [arm64-v8a] are not supported for platform. Supported ABIs are [armeabi-v7a, x86]. Affected Modules: app
当我使用的 compileSdkVersion 19 时,就会报上面的错,改成 compileSdkVersion 26 就可以了。 说明不同的编译版本,它们所支持的平台不一样。
$(call import-add-path, $(LOCAL_PATH)) # 没有这一行,下面这行会报错。
$(call import-module, box2d)
allprojects {
repositories {
maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
maven { url "http://maven.aliyun.com/nexus/content/repositories/jcenter" }
maven { url "https://dl.bintray.com/umsdk/release" }
google()
jcenter()
}
}
android {
defaultConfig {
externalNativeBuild {
cmake {
cppFlags "-std=c++11"
}
}
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
}
cmake_minimum_required(VERSION 3.4.1)
find_library(log-lib log)
add_library(native-lib SHARED native-lib.cpp)
target_link_libraries(native-lib ${log-lib})
认识 Android.mk 和 Application.mk Android: NDK 中的 Android.mk 和 Application.mk
android {
defaultConfig {
ndk {
moduleName "gamedemo"
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}
app/src/main/jni/Application.mk & Android.mk。like hawkhai/IrrGameDemo.git。
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := calculator
LOCAL_SRC_FILES := calculator.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/irrlicht/include $(LOCAL_PATH)/SDL/include
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
# __android_log_print(ANDROID_LOG_INFO, "log", message);
# error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
# APP_CLAGS:列出编译器标识,在编译任何模块的 C 和 C++ 源文件时这些标志都会被传给编译器
# APP_CPPFLAGS:列出编译器标识,在编译任何模块的 C++ 源文件时这些标志都会被传给编译器
LOCAL_CFLAGS += -Wno-error=format-security -Wreturn-type
LOCAL_CPPFLAGS += -Wno-error=c++11-narrowing -Wno-error=format-security -Wreturn-type
# 增加对 异常 和 rtti 的支持
LOCAL_CPPFLAGS += -fexceptions -frtti
LOCAL_SHORT_COMMANDS := true # ndk 编译报 make (e=87): 参数错误
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../include/
Application.mk
NDK_TOOLCHAIN_VERSION := 4.9
APP_ABI := armeabi-v7a arm64-v8a # 这玩意貌似无效了。
APP_STL := stlport_static # 这个也不行了。c++_static/c++_shared
APP_PLATFORM := android-21
APP_CPPFLAGS += -fexceptions -frtti
APP_PLATFORM := android-10
APP_STL := c++_static
APP_SHORT_COMMANDS := true # ndk 编译报 make (e=87): 参数错误
APP_ABI := armeabi-v7a arm64-v8a # 感觉没用,尴尬。android/defaultConfig/ndk 里面指定才有用。
APP_CPPFLAGS += -Wno-error=format-security
APP_CFLAGS += -Wno-error=format-security
Android Studio: “Error initializing ADB: Android Debug Bridge not found” 且找不到 Project Structure
删除了本地的 .idea 文件夹 ,然后重启 Android Studio。
发生这种情况,估计是创建项目时,gitignore 中没有忽略 .idea 文件夹,导致 git 拉取项目后用的是别人项目的 .idea 文件夹。
在项目中的 gradle.properties 全局配置中设置:
android.injected.testOnly=false
buildTypes {
debug {
minifyEnabled false
debuggable true
jniDebuggable true
}
}
巨坑。NDK 里面带了 python.exe,和本机的 python 冲突, LLDB server
成功起来后就好了。
02/05 16:41:05: Launching 'app' on Galaxy Nexus API 30.
Install successfully finished in 680 ms.
$ adb shell am start -n "com.cfgame.myapp/com.cfgame.myapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.cfgame.myapp.test | com.cfgame.myapp
Waiting for application to come online: com.cfgame.myapp.test | com.cfgame.myapp
Waiting for application to come online: com.cfgame.myapp.test | com.cfgame.myapp
Connecting to com.cfgame.myapp
Now Launching Native Debug Session
$ adb shell cat /data/local/tmp/lldb-server | run-as com.cfgame.myapp sh -c 'cat > /data/data/com.cfgame.myapp/lldb/bin/lldb-server && chmod 700 /data/data/com.cfgame.myapp/lldb/bin/lldb-server'
$ adb shell cat /data/local/tmp/start_lldb_server.sh | run-as com.cfgame.myapp sh -c 'cat > /data/data/com.cfgame.myapp/lldb/bin/start_lldb_server.sh && chmod 700 /data/data/com.cfgame.myapp/lldb/bin/start_lldb_server.sh'
Starting LLDB server: /data/data/com.cfgame.myapp/lldb/bin/start_lldb_server.sh /data/data/com.cfgame.myapp/lldb unix-abstract /com.cfgame.myapp-0 platform-1612514467397.sock "lldb process:gdb-remote packets"
Executing commands in 'E:\android-studio-ide-181.5014246-windows\android-studio\bin\lldb\shared\stl_printers\load_script'.
(lldb) script import sys
(lldb) script import os
(lldb) script ...