-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9ef66ad
Showing
21 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
#!/bin/bash | ||
# <---IMPORTANT NOTE! if you dont have | ||
# termux-exec package installed, that line needs to be: | ||
# #!$PREFIX/bin/bash | ||
|
||
# This guy simply prevents the chain of events from | ||
# continuing idiotically, if one step fails. The script | ||
# will stop there. | ||
function catch_error() { | ||
local error_code="$?" | ||
echo "Error: $error_code" | ||
} | ||
trap catch_error ERR | ||
set -e | ||
|
||
# You may need to change this if you found the need | ||
# to locate your project files outside the hierarchy | ||
# of the termux 'home' dir | ||
dir=$PWD/$* | ||
echo "Work Dir: $dir" | ||
|
||
if [ ! -d "$dir" ]; then | ||
echo "Directory does not exist"; exit 1; | ||
else | ||
echo "Directory exists, continuing..."; fi | ||
|
||
cd $dir | ||
|
||
#its likely these arent executable at first download | ||
chmod a+x toolz/* | ||
|
||
export JAVA_HOME="$PREFIX/opt/openjdk" | ||
export PATH="$PATH:$JAVA_HOME/bin" | ||
export BUILD_TOOLS="$dir/toolz" | ||
export PATH="$BUILD_TOOLS:$PATH" | ||
|
||
# Clean up junk from last build: | ||
rm -rf build | ||
mkdir build | ||
mkdir build/classes | ||
|
||
# Begin compilation! | ||
|
||
echo "---------------aapt2: " | ||
aapt2 compile -v\ | ||
--dir res \ | ||
-o build/resources.zip | ||
|
||
# -I gives the path to the android platform’s android.jar, | ||
# --manifest specifies the android manifest, | ||
# --java specifies the path to generate the R.java file. | ||
# --o specifies the output path. | ||
|
||
aapt2 link -v \ | ||
-I $dir/toolz/android.jar \ | ||
--manifest AndroidManifest.xml \ | ||
--java build/ \ | ||
-o build/link.apk \ | ||
build/resources.zip \ | ||
--auto-add-overlay | ||
|
||
# This will compile our code to java bytecode | ||
# and place the .class files in build/classes | ||
# directory. Take note of the R.java file which | ||
# is the one that was generated in the previous step. | ||
# Without --release=9 nothing will work and | ||
# puppies will die | ||
|
||
echo "---------------- Using `$JAVA_HOME/bin/javac --version` ---------------" | ||
$JAVA_HOME/bin/javac --release=9 -verbose \ | ||
-d build/classes \ | ||
--class-path \ | ||
$dir/toolz/android.jar \ | ||
src/com/helloworld/MainActivity.java \ | ||
build/com/helloworld/R.java | ||
|
||
# Once we have java bytecode we now convert it to | ||
# DEX bytecode that runs on android devices. | ||
# This is done using android’s d8 commandline tool. | ||
|
||
# d8 uses '/bin/ls' which is not where it is, in termux. | ||
# this..i found out you could get termux-ready versions of | ||
# both these tools so these arent being used anymore. | ||
#sed -i 's/\/bin\/ls/ls/g' $BUILD_TOOLS/dx | ||
#sed -i 's/\/bin\/ls/ls/g' $BUILD_TOOLS/d8 | ||
|
||
# IF you dont include that 'cd' below, the fails will be monumental. | ||
# it took me 60% of the time i spent on this to figure out | ||
# that this tool WILL NOT FUNCTION unless the directory structure | ||
# matches the package name, ie com/helloworld com.helloworld. | ||
# if it even catches a glimpse that its actually src/com/helloworld | ||
# itll uncompromisingly refuse to communicate or function | ||
|
||
# To convert into dex : | ||
echo "---------------d8: " | ||
cd $dir/build/classes | ||
dx --dex --verbose --debug\ | ||
--output=classes.dex \ | ||
com/helloworld/*.class \ | ||
|
||
# This is the same step as above (you only need | ||
# but one of them) but uses d8 instead of dx. | ||
# I chose dx only because its debug output is better | ||
# (d8 is completely silent and impossible to troubleshoot, | ||
# however in the end I got them both to work.) | ||
#$BUILD_TOOLS/d8 --classpath $ANDROID_HOME/platforms/$TARGET_PLATFORM/android.jar \ | ||
# --output build/dex/ \ | ||
# $(ls -1 build/classes/com/helloworld |\ | ||
# xargs -I{} printf "%s "\ | ||
# "build/classes/com/helloworld/{}") | ||
|
||
|
||
# The output will be a file called classes.dex. | ||
# We then need to add this file into our link.apk | ||
# that was generated in the linking stage: | ||
# (notice that zip comes from your system and isn't | ||
# in android sdk): | ||
|
||
echo "---------------zip: " | ||
zip -v -u ../link.apk classes.dex | ||
|
||
|
||
# Next we need to zip align our apk using the | ||
# zipalign tool and then sign the apk using the | ||
# apksigner tool. | ||
|
||
echo "---------------zipalign: " | ||
$BUILD_TOOLS/zipalign -v -f -p 4 ../link.apk ../zipout.apk | ||
|
||
# (To sign the application you will need to have a | ||
# public-private key pair. You can generate one | ||
# using java’s keytool. This you only do once, so | ||
# if its your first time thru, uncomment the 'keytool' | ||
# line and answer the questions: | ||
# I used 'password' when asked for one | ||
#keytool -genkeypair -keystore key.keystore -keyalg RSA | ||
|
||
|
||
# And sign! --ks-pass pass:<YOUR PASS HERE> if you change it. | ||
echo "---------------apksigner: " | ||
$BUILD_TOOLS/apksigner sign \ | ||
--verbose \ | ||
--ks $dir/key.keystore \ | ||
--ks-pass pass:password \ | ||
--out ../final.apk ../zipout.apk | ||
|
||
# The output of this command is an apk final.apk. | ||
echo | ||
echo | ||
echo "...if success, result is $dir/build/final.apk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.helloworld" | ||
android:versionCode="1" | ||
android:versionName="1.11" > | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-sdk | ||
android:minSdkVersion="17" | ||
android:targetSdkVersion="30" /> | ||
<application | ||
android:label="The big dumb title at the top." | ||
android:debuggable="true" | ||
android:allowBackup="true" | ||
android.minifyEnabled="false" > | ||
<activity android:name="com.helloworld.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* AUTO-GENERATED FILE. DO NOT MODIFY. | ||
* | ||
* This class was automatically generated by the | ||
* aapt tool from the resource data it found. It | ||
* should not be modified by hand. | ||
*/ | ||
|
||
package com.helloworld; | ||
|
||
public final class R { | ||
public static final class id { | ||
public static final int webview=0x7f010000; | ||
} | ||
public static final class layout { | ||
public static final int activity_main=0x7f020000; | ||
} | ||
public static final class string { | ||
public static final int app_name=0x7f030000; | ||
public static final int hello_world=0x7f030001; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" > | ||
<WebView | ||
android:id="@+id/webview" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerHorizontal="true" | ||
android:layout_centerVertical="true" | ||
android:text="@string/hello_world" | ||
tools:context=".MainActivity" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<resources> | ||
<string name="app_name">HelloWorld</string> | ||
<string name="hello_world">Hello world!</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.helloworld; | ||
|
||
import android.os.*; | ||
import android.app.*; | ||
import android.webkit.*; | ||
|
||
|
||
public class MainActivity extends Activity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
WebView myWebView = (WebView) findViewById(R.id.webview); | ||
WebSettings webSettings = myWebView.getSettings(); | ||
webSettings.setJavaScriptEnabled(true); | ||
myWebView.loadUrl("https://github.com"); | ||
} | ||
|
||
} //close of MainActivity | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (C) 2016 The Android Open Source Project | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Set up prog to be the path of this script, including following symlinks, | ||
# and set up progdir to be the fully-qualified pathname of its directory. | ||
prog="$0" | ||
while [ -h "${prog}" ]; do | ||
newProg=`/bin/ls -ld "${prog}"` | ||
newProg=`expr "${newProg}" : ".* -> \(.*\)$"` | ||
if expr "x${newProg}" : 'x/' >/dev/null; then | ||
prog="${newProg}" | ||
else | ||
progdir=`dirname "${prog}"` | ||
prog="${progdir}/${newProg}" | ||
fi | ||
done | ||
oldwd=`pwd` | ||
progdir=`dirname "${prog}"` | ||
cd "${progdir}" | ||
progdir=`pwd` | ||
prog="${progdir}"/`basename "${prog}"` | ||
cd "${oldwd}" | ||
|
||
jarfile=apksigner.jar | ||
libdir="$progdir" | ||
|
||
if [ ! -r "$libdir/$jarfile" ]; then | ||
# set apksigner.jar location for the SDK case | ||
libdir="$libdir/lib" | ||
fi | ||
|
||
|
||
if [ ! -r "$libdir/$jarfile" ]; then | ||
# set apksigner.jar location for the Android tree case | ||
libdir=`dirname "$progdir"`/framework | ||
fi | ||
|
||
if [ ! -r "$libdir/$jarfile" ]; then | ||
echo `basename "$prog"`": can't find $jarfile" | ||
exit 1 | ||
fi | ||
|
||
# By default, give apksigner a max heap size of 1 gig. This can be overridden | ||
# by using a "-J" option (see below). | ||
defaultMx="-Xmx1024M" | ||
|
||
# The following will extract any initial parameters of the form | ||
# "-J<stuff>" from the command line and pass them to the Java | ||
# invocation (instead of to apksigner). This makes it possible for you to add | ||
# a command-line parameter such as "-JXmx256M" in your scripts, for | ||
# example. "java" (with no args) and "java -X" give a summary of | ||
# available options. | ||
|
||
javaOpts="" | ||
|
||
while expr "x$1" : 'x-J' >/dev/null; do | ||
opt=`expr "x$1" : 'x-J\(.*\)'` | ||
javaOpts="${javaOpts} -${opt}" | ||
if expr "x${opt}" : "xXmx[0-9]" >/dev/null; then | ||
defaultMx="no" | ||
fi | ||
shift | ||
done | ||
|
||
if [ "${defaultMx}" != "no" ]; then | ||
javaOpts="${javaOpts} ${defaultMx}" | ||
fi | ||
|
||
if [ "$OSTYPE" = "cygwin" ]; then | ||
# For Cygwin, convert the jarfile path into native Windows style. | ||
jarpath=`cygpath -w "$libdir/$jarfile"` | ||
else | ||
jarpath="$libdir/$jarfile" | ||
fi | ||
|
||
exec java $javaOpts -jar "$jarpath" "$@" |
Binary file not shown.
Binary file not shown.