Use updated android tools? I don't know. Ugg.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4222 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-03-15 03:21:20 +00:00
parent 2b0962f087
commit a5da17e1b1
2 changed files with 24 additions and 23 deletions

View File

@ -20,11 +20,11 @@ CFLAGS += \
-g -g
LDFLAGS += -Wl,--gc-sections LDFLAGS += -Wl,--gc-sections
ANDROID_SDK ?= /usr/lib/android-sdk ANDROID_SDK ?= ~/Android/Sdk
ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/29.0.3 ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/33.0.1
ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-23 ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-33
ANDROID_NDK ?= /usr/lib/android-sdk/ndk-bundle ANDROID_NDK ?= $(ANDROID_SDK)/ndk/23.1.7779620
ANDROID_NDK_API_VERSION := 30 ANDROID_NDK_API_VERSION := 33
ANDROID_MIN_SDK_VERSION := 26 ANDROID_MIN_SDK_VERSION := 26
ANDROID_ARM64_TARGETS := \ ANDROID_ARM64_TARGETS := \
@ -37,11 +37,9 @@ ANDROID_TARGETS := \
$(ANDROID_X86_64_TARGETS) \ $(ANDROID_X86_64_TARGETS) \
$(ANDROID_ARM64_TARGETS) $(ANDROID_ARM64_TARGETS)
$(info $(ANDROID_TARGETS))
debug windebug $(ANDROID_TARGETS): CFLAGS += -Og debug windebug $(ANDROID_TARGETS): CFLAGS += -Og
debug release out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends: LDFLAGS += -rdynamic debug release out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends: LDFLAGS += -rdynamic
$(ANDROID_TARGETS): CFLAGS += --sysroot $(ANDROID_SDK)/ndk-bundle/sysroot -fPIC $(ANDROID_TARGETS): CFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC
release winrelease: CFLAGS += -DNDEBUG -O3 release winrelease: CFLAGS += -DNDEBUG -O3
windebug winrelease: CC = x86_64-w64-mingw32-gcc-win32 windebug winrelease: CC = x86_64-w64-mingw32-gcc-win32
windebug winrelease: AS = $(CC) windebug winrelease: AS = $(CC)
@ -398,22 +396,25 @@ endef
$(foreach build_type,$(BUILD_TYPES),$(eval $(call build_rules,$(build_type)))) $(foreach build_type,$(BUILD_TYPES),$(eval $(call build_rules,$(build_type))))
# Android support. # Android support.
out/gen/com/unprompted/tildefriends/R.java: $(wildcard src/android/res/layout/*) src/android/AndroidManifest.xml out/res/layout_activity_main.xml.flat: src/android/res/layout/activity_main.xml
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@echo [aapt] R.java @echo [aapt2] $@
@$(ANDROID_BUILD_TOOLS)/aapt package -f -m -J out/gen/ -S src/android/res/ -M src/android/AndroidManifest.xml -I $(ANDROID_PLATFORM)/android.jar $(ANDROID_BUILD_TOOLS)/aapt2 compile -o out/res/ src/android/res/layout/activity_main.xml
out/res.apk out/gen/com/unprompted/tildefriends/R.java: out/res/layout_activity_main.xml.flat src/android/AndroidManifest.xml
$(ANDROID_BUILD_TOOLS)/aapt2 link -I $(ANDROID_PLATFORM)/android.jar out/res/layout_activity_main.xml.flat --manifest src/android/AndroidManifest.xml -o out/res.apk --java out/gen/
JAVA_FILES := out/gen/com/unprompted/tildefriends/R.java $(wildcard src/android/com/unprompted/tildefriends/*.java) JAVA_FILES := out/gen/com/unprompted/tildefriends/R.java $(wildcard src/android/com/unprompted/tildefriends/*.java)
CLASS_FILES := $(foreach src,$(JAVA_FILES),out/classes/com/unprompted/tildefriends/$(notdir $(src:.java=.class))) CLASS_FILES := $(foreach src,$(JAVA_FILES),out/classes/com/unprompted/tildefriends/$(notdir $(src:.java=.class)))
$(CLASS_FILES) &: $(JAVA_FILES) $(CLASS_FILES) &: $(JAVA_FILES)
@echo [javac] $(CLASS_FILES) @echo [javac] $(CLASS_FILES)
@javac --release 8 -classpath $(ANDROID_PLATFORM)/android.jar -d out/classes $(JAVA_FILES) @javac --release 8 -Xlint:deprecation -classpath $(ANDROID_PLATFORM)/android.jar -d out/classes $(JAVA_FILES)
out/apk/classes.dex: $(CLASS_FILES) out/apk/classes.dex: $(CLASS_FILES)
@mkdir -p $(dir $@) mkdir -p $(dir $@)
@echo [dx] $@ echo [d8] $@
@$(ANDROID_BUILD_TOOLS)/dx --dex --min-sdk-version=$(ANDROID_MIN_SDK_VERSION) --output=$@ out/classes/ $(ANDROID_BUILD_TOOLS)/d8 --lib $(ANDROID_PLATFORM)/android.jar --output $(dir $@) out/classes/com/unprompted/tildefriends/*.class
PACKAGE_DIRS := \ PACKAGE_DIRS := \
apps/ \ apps/ \
@ -422,19 +423,18 @@ PACKAGE_DIRS := \
deps/split/ \ deps/split/ \
deps/smoothie/ deps/smoothie/
# deps/speedscope/ \
RAW_FILES := $(shell find $(PACKAGE_DIRS) -type f) RAW_FILES := $(shell find $(PACKAGE_DIRS) -type f)
out/TildeFriends.unsigned.apk: out/apk/classes.dex out/androiddebug/tildefriends out/androiddebug-x86_64/tildefriends $(RAW_FILES) out/TildeFriends.unsigned.apk: out/apk/classes.dex out/androiddebug/tildefriends out/androiddebug-x86_64/tildefriends $(RAW_FILES) out/res.apk
@mkdir -p $(dir $@) out/apk/lib/arm64-v8a/ out/apk/lib/x86_64/ @mkdir -p $(dir $@) out/apk/lib/arm64-v8a/ out/apk/lib/x86_64/
@echo [aapt] $@ @echo [aapt] $@
@cp out/androiddebug/tildefriends out/apk/lib/arm64-v8a/ @cp out/androiddebug/tildefriends out/apk/lib/arm64-v8a/
@cp out/androiddebug-x86_64/tildefriends out/apk/lib/x86_64/ @cp out/androiddebug-x86_64/tildefriends out/apk/lib/x86_64/
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk/lib/arm64-v8a/tildefriends @/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk/lib/arm64-v8a/tildefriends
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk/lib/x86_64/tildefriends @/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk/lib/x86_64/tildefriends
@$(ANDROID_BUILD_TOOLS)/aapt package -f -M src/android/AndroidManifest.xml -S src/android/res/ -I $(ANDROID_PLATFORM)/android.jar -F $@ out/apk/ @cp out/res.apk $@
@zip -u $@ -q -9 -r $(PACKAGE_DIRS) @cd out/apk && zip -u ../../$@ -q -9 -r . && cd ../../
@zip -u $@ -q -9 -r $(PACKAGE_DIRS) $(RAW_FILES)
out/TildeFriends.apk: out/TildeFriends.unsigned.apk out/TildeFriends.apk: out/TildeFriends.unsigned.apk
@echo [apksigner] $(notdir $@) @echo [apksigner] $(notdir $@)

View File

@ -13,6 +13,7 @@ import android.view.KeyEvent;
import android.view.Window; import android.view.Window;
import android.webkit.JsResult; import android.webkit.JsResult;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import java.lang.Process; import java.lang.Process;
@ -112,12 +113,12 @@ public class MainActivity extends Activity {
web_view.setWebViewClient(new WebViewClient() { web_view.setWebViewClient(new WebViewClient() {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
{ {
if (url != null && url.startsWith("http://127.0.0.1:12345/")) { if (request.getUrl() != null && request.getUrl().toString().startsWith("http://127.0.0.1:12345/")) {
return false; return false;
} else { } else {
view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, request.getUrl()));
return true; return true;
} }
} }