Android: static stl, getting deps using gradle, some fixes

This commit is contained in:
MoNTE48 2019-11-19 12:50:05 +01:00
parent 1dd11bdc04
commit d014f94141
12 changed files with 77 additions and 42 deletions

View File

@ -8,21 +8,6 @@ fi
FOLDER=$(pwd)/app/src/main/assets
DEST=$(mktemp -d)
echo
echo "*** Starting build MultiCraft for Android... ***"
echo
echo "=> Getting precompiled dependencies:"
if [ ! -d native/deps ]; then
echo
git clone --depth 1 https://github.com/MultiCraft/deps native/deps
echo
echo "* Done!"
else
echo
echo "Already available, skipping..."
fi
echo
echo "=> Creating Assets:"

View File

@ -7,7 +7,7 @@ android {
applicationId 'com.multicraft.game'
minSdkVersion 16
targetSdkVersion 29
versionCode 23
versionCode 25
/*multiDexEnabled true*/
}
Properties props = new Properties()

View File

@ -5,6 +5,7 @@
android:installLocation="auto"
android:versionName="@string/ver">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

View File

@ -24,12 +24,11 @@ import static com.multicraft.game.AdManager.stopAd;*/
public class GameActivity extends NativeActivity {
static {
try {
System.loadLibrary("c++_shared");
System.loadLibrary("MultiCraft");
} catch (UnsatisfiedLinkError e) {
Bugsnag.notify(e);
} catch (IllegalArgumentException e) {
Bugsnag.notify(e);
} catch (IllegalArgumentException i) {
Bugsnag.notify(i);
} catch (OutOfMemoryError e) {
Bugsnag.notify(e);
} catch (Error | Exception error) {
@ -51,6 +50,7 @@ public class GameActivity extends NativeActivity {
Bundle bundle = getIntent().getExtras();
height = bundle != null ? bundle.getInt("height", 0) : getResources().getDisplayMetrics().heightPixels;
width = bundle != null ? bundle.getInt("width", 0) : getResources().getDisplayMetrics().widthPixels;
/*consent = bundle == null || bundle.getBoolean("consent", true);*/
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
messageReturnCode = -1;
messageReturnValue = "";
@ -138,9 +138,9 @@ public class GameActivity extends NativeActivity {
}
}
public void notifyServerConnect(boolean isMultiPlayer) {
/*isMultiPlayer = isMultiPlayer;
if (isMultiPlayer) stopAd();*/
public void notifyServerConnect(boolean isMultiplayer) {
/*isMultiPlayer = isMultiplayer;
if (isMultiplayer) stopAd();*/
}
public void notifyAbortLoading() {
@ -149,22 +149,20 @@ public class GameActivity extends NativeActivity {
}
public void notifyExitGame() {
/*if (isMultiPlayer)
startAd(this, false, true);*/
/*if (isMultiPlayer) startAd(this, false, true);*/
}
@SuppressLint("StaticFieldLeak")
/*@SuppressLint("StaticFieldLeak")
class AdInitTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
/*initAd(GameActivity.this, consent);*/
initAd(GameActivity.this, consent);
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
/*setAdsCallback(GameActivity.this);*/
setAdsCallback(GameActivity.this);
}
}
}*/
}

View File

@ -2,7 +2,6 @@ package com.multicraft.game;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
@ -34,13 +33,12 @@ public class InputDialogActivity extends AppCompatActivity {
editText.requestFocus();
editText.setHint(hint);
editText.setText(current);
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
Objects.requireNonNull(imm).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
if (editType == 3) {
if (editType == 3)
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else {
else
editText.setInputType(InputType.TYPE_CLASS_TEXT);
}
editText.setOnKeyListener((view, KeyCode, event) -> {
if (KeyCode == KeyEvent.KEYCODE_ENTER) {
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);

View File

@ -232,12 +232,11 @@ class WVersionManager implements DialogsCallback {
if (result != null) {
try {
String content;
if (!result.startsWith("{")) { // for response who append with unknown char
if (!result.startsWith("{")) // for response who append with unknown char
result = result.substring(1);
}
String mResult = result;
// json format from server:
JSONObject json = (JSONObject) new JSONTokener(mResult).nextValue();
JSONObject json = new JSONObject(new JSONTokener(mResult));
mVersionCode = json.optInt("version_code");
String lang = Locale.getDefault().getLanguage();
if (lang.equals("ru"))

View File

@ -7,6 +7,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
//noinspection GradleDependency
classpath 'org.ajoberstar:gradle-git:0.6.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

Binary file not shown.

View File

@ -1 +1,6 @@
#Sun Nov 17 19:50:29 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

22
build/android/gradlew vendored
View File

@ -1,5 +1,21 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

View File

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
import org.ajoberstar.gradle.git.tasks.*
android {
compileSdkVersion 29
@ -9,7 +10,7 @@ android {
externalNativeBuild {
ndkBuild {
arguments '-j',
'APP_STL=c++_shared',
'APP_STL=c++_static',
'COMPILER_VERSION=clang',
'APP_SHORT_COMMANDS=true'
}
@ -41,3 +42,17 @@ android {
}
}
}
task cloneGitRepo(type: GitClone) {
def destination = file('deps')
uri ='https://github.com/MultiCraft/deps'
destinationPath = destination
bare = false
enabled = !destination.exists()
}
dependencies {
implementation 'com.android.support:appcompat-v7'
}
preBuild.dependsOn cloneGitRepo